Committing in PDCP code 25/925/1
authorBalaji Shankaran <balaji.shankaran@radisys.com>
Tue, 10 Sep 2019 10:38:46 +0000 (16:08 +0530)
committerBalaji Shankaran <balaji.shankaran@radisys.com>
Tue, 10 Sep 2019 10:51:08 +0000 (16:21 +0530)
Change-Id: I71c30a52460688da29e75738623e55eaa715dc01
Signed-off-by: Balaji Shankaran <balaji.shankaran@radisys.com>
49 files changed:
src/5gnrpdcp/pj.h [new file with mode: 0755]
src/5gnrpdcp/pj.x [new file with mode: 0755]
src/5gnrpdcp/pj_cfg_dl.c [new file with mode: 0755]
src/5gnrpdcp/pj_cfg_ul.c [new file with mode: 0755]
src/5gnrpdcp/pj_dbm.c [new file with mode: 0755]
src/5gnrpdcp/pj_dbm_dl.c [new file with mode: 0755]
src/5gnrpdcp/pj_dbm_ul.c [new file with mode: 0755]
src/5gnrpdcp/pj_dl.h [new file with mode: 0755]
src/5gnrpdcp/pj_dl.x [new file with mode: 0755]
src/5gnrpdcp/pj_dl_ex_ms.c [new file with mode: 0755]
src/5gnrpdcp/pj_dl_utl.c [new file with mode: 0755]
src/5gnrpdcp/pj_dlm.c [new file with mode: 0755]
src/5gnrpdcp/pj_env.h [new file with mode: 0755]
src/5gnrpdcp/pj_err.h [new file with mode: 0755]
src/5gnrpdcp/pj_id.c [new file with mode: 0755]
src/5gnrpdcp/pj_lib.c [new file with mode: 0755]
src/5gnrpdcp/pj_lib.h [new file with mode: 0755]
src/5gnrpdcp/pj_lib.x [new file with mode: 0755]
src/5gnrpdcp/pj_lim.c [new file with mode: 0755]
src/5gnrpdcp/pj_lmm.c [new file with mode: 0755]
src/5gnrpdcp/pj_ptli.c [new file with mode: 0755]
src/5gnrpdcp/pj_ptlib.c [new file with mode: 0755]
src/5gnrpdcp/pj_ptmi.c [new file with mode: 0755]
src/5gnrpdcp/pj_ptsec.h [new file with mode: 0755]
src/5gnrpdcp/pj_ptsec.x [new file with mode: 0755]
src/5gnrpdcp/pj_ptui.c [new file with mode: 0755]
src/5gnrpdcp/pj_sec.h [new file with mode: 0755]
src/5gnrpdcp/pj_tenb_stats.c [new file with mode: 0755]
src/5gnrpdcp/pj_tmr.c [new file with mode: 0755]
src/5gnrpdcp/pj_udx.c [new file with mode: 0755]
src/5gnrpdcp/pj_udx.h [new file with mode: 0755]
src/5gnrpdcp/pj_udx.x [new file with mode: 0755]
src/5gnrpdcp/pj_udx_dl.c [new file with mode: 0755]
src/5gnrpdcp/pj_udx_ptdl.c [new file with mode: 0755]
src/5gnrpdcp/pj_udx_ptul.c [new file with mode: 0755]
src/5gnrpdcp/pj_udx_ul.c [new file with mode: 0755]
src/5gnrpdcp/pj_uim.c [new file with mode: 0755]
src/5gnrpdcp/pj_ul.h [new file with mode: 0755]
src/5gnrpdcp/pj_ul.x [new file with mode: 0755]
src/5gnrpdcp/pj_ul_ex_ms.c [new file with mode: 0755]
src/5gnrpdcp/pj_ul_utl.c [new file with mode: 0755]
src/5gnrpdcp/pj_ulm.c [new file with mode: 0755]
src/5gnrpdcp/pj_utl.c [new file with mode: 0755]
src/cm/cpj.h [new file with mode: 0755]
src/cm/cpj.x [new file with mode: 0755]
src/cm/lpj.h [new file with mode: 0755]
src/cm/lpj.x [new file with mode: 0755]
src/cm/pju.h [new file with mode: 0755]
src/cm/pju.x [new file with mode: 0755]

diff --git a/src/5gnrpdcp/pj.h b/src/5gnrpdcp/pj.h
new file mode 100755 (executable)
index 0000000..fad0430
--- /dev/null
@@ -0,0 +1,1545 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:     LTE PDCP file 
+    
+        Type:     C include file
+  
+        Desc:     This file contain the hash definations for PDCP 
+        File:     pj.h
+
+  
+*********************************************************************21*/
+/** @file pj.h
+@brief PDCP Hash definitions
+*/
+
+#ifndef __PJH__
+#define __PJH__
+
+#include "rl_interface.h"
+#include "rl_common.h"
+#include "rl_rlog.h"
+
+\f 
+#define PJLAYERNAME   "LTE PDCP"     /* Layer Name */
+
+#define EPJxxx 1
+#define PJ_TMR_LEN                     10
+#define PJ_MAX_KWUSAPS        2     /*!< Maximum number of KWU Saps. */
+#define PJ_MAX_UDXSAPS        1     
+#define PJ_MAX_RB_PER_CELL          10
+#define PJ_MAX_SRB_PER_UE           3
+#define PJ_MAX_DRB_PER_UE           32
+#define PJ_MAX_LCH_PER_UE           12
+#define PJ_MAX_LCH_PER_CELL         6
+#define PJ_MAX_NUM_RB               24
+#define PJ_MAX_UE                   0xffffffff 
+#define PJ_UE_LIST_BUCKET_SIZE      128 
+#define PJ_CELL_LIST_BUCKET_SIZE    10 
+#define PJ_MAX_RB                   32
+#define PJ_DEF_SEQ_NUM 0
+#define PJ_ASYNC_WIN                 16
+
+#define PJ_MAX_CPJSAPS        1     /*!< Maximum number of CPJ Saps. */
+#define PJ_MAX_PJUSAPS        2     /*!< Maximum number of PJU Saps. */
+
+#define PJ_LMM_GENCFG_DONE    2     /*!< PDCP LM general configuraiton done. */
+
+#define PJ_PDCP_MODE_DL     1  
+#define PJ_PDCP_MODE_UL     2
+
+/* Direction defines */
+#define PJ_DIR_UL        1     /*!< Unlink direction */
+#define PJ_DIR_DL        2     /*!< Downlink direction */
+#define PJ_DIR_BOTH      3     /*!< Both Downlink and Unlink */
+
+#define PJ_DBG_SUB_MASK   DBGMASK_MI               /* Use for sub-mask */
+#define PJ_DBGMASK_DETAIL (PJ_DBG_SUB_MASK << 0)   /* Parameters, It will give
+                                                      in depth info */
+#define PJ_DBGMASK_BRIEF  (PJ_DBG_SUB_MASK << 1)   /* Info, It will give info at
+                                                      entry and exit places along
+                                                      with certain state changes */
+#define PJ_DBGMASK_ERROR  (PJ_DBG_SUB_MASK << 2)   /* Error information */
+#define PJ_DBGMASK_FATAL  (PJ_DBG_SUB_MASK << 3)   /* FATAL errors like memory
+                                                      resource failure etc., */
+
+
+#define PJ_DBG_MDL_MASK   (PJ_DBG_SUB_MASK << 4) 
+
+#define PJ_DBGMASK_DLM         (PJ_DBG_MDL_MASK << 0) /* DL */
+#define PJ_DBGMASK_ULM         (PJ_DBG_MDL_MASK << 1) /* UL */
+#define PJ_DBGMASK_UTL         (PJ_DBG_MDL_MASK << 2) /* DBM, UTL, TMR */
+#define PJ_DBGMASK_CFG         (PJ_DBG_MDL_MASK << 3) /* LMM and CFG */
+#define PJ_DBGMASK_LIB         (PJ_DBG_MDL_MASK << 4) /* LIB - means software
+                                                               or offboard hooks */
+#define PJ_DBGMASK_INF         (PJ_DBG_MDL_MASK << 5)
+#define PJ_DBGMASK_LMM         (PJ_DBG_MDL_MASK << 6)
+#define PJ_DBGMASK_DL         (PJ_DBG_MDL_MASK << 7)
+#define PJ_DBGMASK_UL         (PJ_DBG_MDL_MASK << 8)
+
+
+#ifdef TENB_T2K3K_SPECIFIC_CHANGES
+
+#define ICC_POOL_ZERO_SIZE 384
+#define ICC_POOL_ONE_SIZE  1920
+#define ICC_POOL_TWO_SIZE  3968
+#define ICC_POOL_THREE_SIZE  16256
+#endif /* TENB_T2K3K_SPECIFIC_CHANGES */
+
+#ifdef DEBUGP
+#define _pjPBuf   pjCb.init.prntBuf
+
+#define PJ_PRNT(_cb,_prntbuf)      \
+{                              \
+   sprintf _prntbuf;           \
+   SPrint(_cb->init.prntBuf);            \
+}
+
+#else  /* DEBUGP */ 
+#define PJ_PRNT_HLINE(_pMsg)
+#define PJ_PRNT(_cb,_prntbuf)
+#define PJ_PRNT_TSTAMP
+#define PJ_PRNT_MBUF(_mBufPtr)
+#define PJ_PRNT_MEMINFO
+#endif /* DEBUGP */
+
+#ifdef DEBUGP
+#define PJ_PRNT_HLINE(_pMsg)                                        \
+{                                                                   \
+   sprintf(_pjPBuf, "[PDCP_LAYER: %s:%d]::", __FILE__, __LINE__);  \
+   SPrint(_pjPBuf);                                                 \
+   sprintf(_pjPBuf, _pMsg);                                         \
+   SPrint(_pjPBuf);                                                 \
+}
+
+#define PJDBGP(_cb,_mask, _arg)                               \
+do                                                            \
+{                                                             \
+   if (!((_cb->init.dbgMask & _mask) ^ _mask))                \
+   {                                                          \
+      PJ_PRNT(_cb,_arg);                                          \
+   }                                                          \
+}while(0)
+#else /* DEBUGP */
+#define PJ_PJ_PRNT_HLINE(_pMsg)
+#define PJDBGP(_cb,_mask, _arg) 
+#endif /* DEBUGP */
+
+
+\f 
+/************************************************************************
+ *                            SAP States
+ ************************************************************************/
+/* ############################PDCP DEFINES ############################# */
+
+#define PJ_SAP_NOT_CFG        0     /*!< SAP Not Configured */
+#define PJ_SAP_CFG            1     /*!< SAP Configured but not not bound */
+#define PJ_SAP_BND            2     /*!< SAP Bound */
+#define PJ_SAP_BINDING        3     /*!< SAP Bind initiated */
+#define PJ_SAP_UBND           4     /*!< SAP Unbind */
+#define PJ_MAX_SAP_BND_RETRY  3     /*!< Maximum SAP Bin Retries */
+
+/* Times related */
+#define PJ_RB_MAX_TIMERS       1       /* No of timers */
+#define PJ_MAX_OBD_TMR         3       /* Number of OBD Timers */
+#define PJ_MAX_DISC_TMR        1       /* Number of Discard Timers */
+#define PJ_MAX_KWUSAP_TMR      1     /*!< Maximum number of KWU SAP Timers. */
+#define PJ_EVT_WAIT_BNDCFM     0x01    /* Bind confirm timer */
+#define PJ_MAX_UDXSAP_TMR      1     /*!< Maximum number of UDX SAP Timers. */
+#define PJ_EVT_DL_OBD_TMR      0x11
+#define PJ_EVT_UL_OBD_TMR      0x12
+#define PJ_EVT_OBD_TMR         0x13
+#define PJ_EVT_TMR_NONE        0x14
+#define PJ_EVT_OBD_WAIT_TMR    0x15
+#define PJ_EVT_UE_DEL_WAIT_TMR 0x16
+/* kw005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+#define PJ_EVT_L2_TMR          0x20
+#define PJ_EVT_L2_MEAS_TMR     0x17
+#endif /* LTE_L2_MEAS */
+#define PJ_EVT_UL_REORD_TMR    0x21
+#define PJ_MAX_UL_REORD_TMRS   1 
+#define PJ_EVT_WAIT_KWU_BNDCFM 0x18    
+#define PJ_EVT_WAIT_UDX_BNDCFM 0x19
+#define PJ_DRB_12BIT_SN_HDR    0x8000
+#define PJ_DRB_18BIT_SN_HDR    0x800000 /*!<18 bit SN setting the hdr for DRB */
+#define PJ_ROHC_FEEDBACK_HDR   0x0010
+#define PJ_FIRST_BIT           0x80
+
+#define PJ_DATA_PDU            0x01
+#define PJ_ROHC_FEEDBACK       0x02
+#define PJ_STA_PDU             0x03
+
+#define PJ_INTG_KEY_LEN        16
+#define PJ_CIPHER_KEY_LEN      16
+
+/*#define PJ_MAX_DAT_CFM         512 */
+/* changed from 512 to 1024 */
+#define PJ_MAX_DAT_CFM         1024
+
+#define PJ_SDU_RECEIVED        0x01
+#define PJ_WAIT_FOR_INTPROT    0x02
+#define PJ_WAIT_FOR_CMP        0x03
+#define PJ_WAIT_FOR_CIPHER     0x04
+#define PJ_PDU_CONSTRUCTED     0x05
+#define PJ_PDU_SUBMITTED       0x06
+#define PJ_TX_ENT_TO_DEL       0x07
+
+#define PJ_12_BIT_SN           12
+#define PJ_18_BIT_SN           18
+
+#define PJ_TX_BUF_LEN          256
+#define PJ_MAX_SDU_SIZE        8188
+
+#define PJ_SRB                 PJ_SRB_SAP
+#define PJ_DRB                 PJ_DRB_SAP
+
+#define PJ_SRB_SAP             0
+#define PJ_DRB_SAP             1
+
+#define PJ_DRB_UM              2
+#define PJ_DRB_AM              3
+
+#define PJ_CFM_NOK             1
+#define PJ_CFM_OK              0
+
+#define PJ_GET_PJCB(_inst) pjCb[_inst];  
+#define PJ_BYTE_LEN            8
+
+
+#define PJ_SEC_DIR_UL          0
+#define PJ_SEC_DIR_DL          1
+
+#define PJ_PDU_CONSTRUCT_FAILED  1
+#define PJ_HDR_COMP_FAILED       2
+#define PJ_INTG_PROT_FAILED      3
+#define PJ_CIPHER_FAILED         4
+#define PJ_CPY_MSG_FAILED        5
+#define PJ_REM_MSG_FAILED        6
+#define PJ_DISC_TMR_EXP          7
+#define PJ_OBD_TIMEOUT           8
+
+#define PJ_CFG_RLC             1
+#define PJ_CFG_PDCP            2
+#define PJ_CFG_BOTH            3
+#define PJ_TRANS_ID_LST_BKT_SIZE   10  
+
+/* PJ_MS_KENB_LEN: Its the max lenght of the key for derivation of CK and IK */
+/* PJ_MS_STR_S_LEN: Length of "STR S" which is one of the inputs for CK and IK dervation */ 
+#define PJ_MS_KENB_LEN  32
+#define PJ_MS_STR_S_LEN 9
+#define PJ_NUM_BYTES_FRESH   4      /*<!Number of Bytes for FRESH variable */
+
+#define PJ_KDF_SAP      0       /*!<Dummy SAP for KDF functionality*/
+
+
+#define PJ_VALIDATE_RBID(_ueId, _rbId, _rbType, _ret)          \
+{                                                              \
+   _ret = ROK;                                                 \
+   if (_ueId == 0)                                             \
+   {                                                           \
+      if (_rbId >= PJ_MAX_RB_PER_CELL)                         \
+      {                                                        \
+         _ret = RFAILED;                                       \
+      }                                                        \
+   }                                                           \
+   else                                                        \
+   {                                                           \
+      if ((_rbType != CM_LTE_SRB) && (_rbType != CM_LTE_DRB))  \
+      {                                                        \
+         _ret = RFAILED;                                       \
+      }                                                        \
+      else if (_rbType == CM_LTE_SRB &&_rbId >= PJ_MAX_SRB_PER_UE)  \
+      {                                                        \
+         _ret = RFAILED;                                       \
+      }                                                        \
+      else if (_rbType == CM_LTE_DRB &&_rbId >= PJ_MAX_DRB_PER_UE)  \
+      {                                                        \
+         _ret = RFAILED;                                       \
+      }                                                        \
+   }                                                           \
+}
+
+#define PJ_DBM_FETCH_RBCB(_rbId, _rbType, _ueCb, _rbCb)     \
+{                                                           \
+  PjRbCb  **_rbCbLst;                                         \
+   _rbCbLst = (_rbType==CM_LTE_SRB)?_ueCb->srbCb:_ueCb->drbCb;\
+   if (_rbCbLst[_rbId] != NULLP)                            \
+   {                                                        \
+      _rbCb = _rbCbLst[_rbId];                              \
+   }                                                        \
+   else                                                     \
+   {                                                        \
+      _rbCb = NULLP;                                        \
+   }                                                        \
+}
+#define PJ_DBM_FETCH_CELL_RBCB(_rbId, _rbCbLst, _rbCb)     \
+{                                                           \
+   if (_rbCbLst[_rbId] != NULLP)                            \
+   {                                                        \
+      _rbCb = _rbCbLst[_rbId];                              \
+   }                                                        \
+   else                                                     \
+   {                                                        \
+      _rbCb = NULLP;                                        \
+   }                                                        \
+}
+
+#define PJ_GET_UL_UDX_SAP(_cb) (&(_cb->u.ulCb->udxUlSap[0])) 
+
+/* LMM Module Macros */
+#define PJ_LMM_RB_STS_INC(_cb)                                    \
+{                                                              \
+   _cb->pjGenSts.numOfRb++;                                      \
+}
+
+#define PJ_LMM_RB_STS_DEC(_cb)                                    \
+{                                                              \
+   _cb->pjGenSts.numOfRb--;                                      \
+}
+
+
+
+
+/* kw005.201 moved the definition from kw_pj_dlm.c file */
+#define PJ_PJ_ASYNC_WIN        16
+#ifdef LTE_L2_MEAS
+/* L2 Measurement index to be used in rbCb to store measData */                                       
+#define PJ_L2MEAS_UL_LOSS 0
+#define PJ_L2CPU_PERCORE_STATS 1
+#define PJ_L2MEM_PERPOOL_STATS 2
+#define PJ_L2MEAS_ACT_UE        3
+#define PJ_L2MEAS_DL_DELAY      4
+#define PJ_L2MEAS_DL_DISC       5
+#define PJ_MAX_L2MEAS_INRB      6
+#define PJ_L2MEAS_UU_LOSS      7
+#define PJ_L2MEAS_DL_IP        8
+#define PJ_L2MEAS_UL_IP        9
+
+#define PJ_L2_MAX_TIMERS        1
+
+#define PJ_MAX_L2MEAS_EVT       10
+#define PJ_INIT_RB_L2CB(_measVal, _measCb, _pjRbCb)                       \
+{                                                                         \
+   cmLListAdd2Tail(&_measCb->rbList, &_pjRbCb->rbL2Cb.listNode[_measVal]);\
+   _pjRbCb->rbL2Cb.l2Sts[_measVal] = &_measCb->measData[_pjRbCb->qci];    \
+}
+
+#define PJ_RMV_RB_FRM_L2LIST(_measVal, _measCb, _pjRbCb)          \
+cmLListDelFrm(&_measCb->rbList,                                    \
+     &_pjRbCb->rbL2Cb.listNode[_measVal]);
+
+#define PJ_UPD_L2_DLDELAY_STS(_pjRbCb, _val)                      \
+{                                                                 \
+   _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DELAY]->dlDelay.numPkts++;          \
+   _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DELAY]->dlDelay.val += _val;        \
+}                                          
+#define PJ_UPD_L2_DLDISC_PKT_STS(_pjCb, _pjRbCb)                         \
+{                                                                 \
+   if((_pjRbCb->rbType == PJ_DRB) &&                              \
+      ((_pjCb)->u.dlCb->pjL2Cb.measOn[_pjRbCb->qci] & LPJ_L2MEAS_DL_DISC))   \
+   {                                                              \
+      _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DISC]->dlDisc.numPkts++;     \
+   }                                                              \
+}                                              
+
+#define PJ_UPD_L2_DLDISC_STS(_pjCb, _pjRbCb)                             \
+{                                                                 \
+   if((_pjRbCb->rbType == PJ_DRB) &&                              \
+      ((_pjCb)->u.dlCb->pjL2Cb.measOn[_pjRbCb->qci] & LPJ_L2MEAS_DL_DISC))   \
+   {                                                              \
+      _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DISC]->dlDisc.val++;      \
+   }                                                              \
+}                                      
+
+#define PJ_SEND_SAPID_ALARM(_cb,_sapId, _evnt, _cause) \
+{ \
+   pjLmmSendAlarm(_cb,LCM_CATEGORY_INTERFACE, _evnt, _cause, _sapId, 0, 0); \
+}
+#define PJ_SEND_UEID_ALARM(_ueId, _qci, _evnt, _cause) \
+{ \
+   pjLmmSendAlarm(LCM_CATEGORY_INTERFACE, _evnt, _cause, 0, _ueId, _qci); \
+}
+
+#define PJ_UPD_L2_DECR_PER_QCI_RB_COUNT(_pjCb, _pjRbCb)                 \
+{                                                                 \
+   if(((_pjRbCb)->rbType == CM_LTE_DRB) &&                    \
+      ((_pjCb)->u.dlCb->pjL2Cb.measOn[_pjRbCb->qci] & LPJ_L2MEAS_DL_DISC))   \
+   {                                                              \
+      U32 idx1;                                                    \
+      for (idx1 = 0; idx1 < LPJ_MAX_L2MEAS; idx1++)                  \
+      {                                                           \
+         if(_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measType & LPJ_L2MEAS_DL_DISC)                 \
+         {                                                        \
+            if(_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci].totDrbsPerQci > 0) \
+            {                                                                                               \
+               _pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci].totDrbsPerQci--;   \
+               if (_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci].totDrbsPerQci == 0) \
+               {                                                                                                 \
+                  _pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.qci[(_pjRbCb)->qci] = 0;                      \
+                  cmMemset((U8 *)&_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci], 0,  \
+                     sizeof(_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci]));            \
+               }                                                                                                 \
+            }                                                                                                    \
+         }                                                                                                       \
+      }                                                                                                          \
+   }                                                                                                             \
+}
+
+#define PJ_GET_SN_DIFF(_expSn, _rcvdSn, _snLen, _diff)  \
+{                                                       \
+   if(_expSn > _rcvdSn)                                 \
+   {                                                    \
+      _diff = _rcvdSn + (1 << _snLen) - _expSn;         \
+   }                                                    \
+   else                                                 \
+   {                                                    \
+      _diff = _rcvdSn - _expSn;                         \
+   }                                                    \
+}
+
+#define PJ_UPD_L2_ULLOSS_CNTRS(_cb,_count, _pjRbCb)                                  \
+{                                                                                \
+   PjSn _sn;                                                                     \
+   U32 _hfn;                                                                     \
+   PJ_GET_SN_HFN(_count, _pjRbCb->snLen, _sn, _hfn)                              \
+   if(_cb->u.ulCb->pjL2Cb.measOn[_pjRbCb->qci] & LPJ_L2MEAS_UL_LOSS)                               \
+   {                                                                             \
+       U32 _diff;                                                                \
+       PJ_GET_SN_DIFF(_pjRbCb->ulCb.nxtSubSn, _sn, _pjRbCb->snLen, _diff)        \
+      _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->ulLoss.numPkts += _diff + 1;     \
+      _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->ulLoss.val += _diff;             \
+   }                                                                             \
+   _pjRbCb->ulCb.nxtSubSn = (_sn + 1) % (1 << _pjRbCb->snLen);                   \
+}
+
+#else /* LTE_L2_MEAS */
+#define PJ_UPD_L2_DLDELAY_STS(_pjRbCb, _val)
+#define PJ_UPD_L2_ULLOSS_PKT_STS(_pjRbCb) 
+#define PJ_UPD_L2_ULLOSS_STS(_pjRbCb)
+#define PJ_UPD_L2_DLDISC_PKT_STS(_pjCb,_pjRbCb)  
+#define PJ_UPD_L2_DLDISC_STS(_pjCb,_pjRbCb)      
+#define PJ_SEND_SAPID_ALARM(_cb,_sapId, _evnt, _cause)
+#define PJ_SEND_UEID_ALARM(_ueId, _qci, _evnt, _cause)
+#define PJ_UPD_L2_DECR_PER_QCI_RB_COUNT(_pjCb, _pjRbCb)
+#define PJ_UPD_L2_ULLOSS_CNTRS(_cb, _count, _pjRbCb)
+#endif /* LTE_L2_MEAS */
+/* kw005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS 
+#if (ERRCLASS & ERRCLS_INT_PAR)
+#define PJ_VALDATE_SAP(_cb, _chkSpId, _sap, _ret)                    \
+{                                                                    \
+   if (_chkSpId != _sap->spId)                                       \
+   {                                                                 \
+      RLOG0(L_ERROR,"Sap Id Validation Failed.");                    \
+      _ret = RFAILED;                                                \
+   }                                                                 \
+   /* SAP state validation */                                        \
+   if(_sap->state != PJ_SAP_BND)                                     \
+   {                                                                 \
+      RLOG0(L_ERROR,"Sap State Invalid.");                           \
+      pjLmmSendAlarm(_cb, LCM_CATEGORY_INTERFACE, LCM_EVENT_UI_INV_EVT,   \
+            LCM_CAUSE_INV_STATE, 0, 0, 0);                           \
+      _ret = RFAILED;                                                \
+   }                                                                 \
+}
+#else /* ERRCLASS & ERRCLS_INT_PAR */
+#define PJ_VALDATE_SAP(_cb, _chkSpId, _sap, _ret)                    \
+{                                                                    \
+   /* SAP state validation */                                        \
+   if(_sap->state != PJ_SAP_BND)                                     \
+   {                                                                 \
+      RLOG0(L_ERROR,"Sap State Invalid.");                            \
+      pjLmmSendAlarm(_cb, LCM_CATEGORY_INTERFACE, LCM_EVENT_UI_INV_EVT,   \
+            LCM_CAUSE_INV_STATE, 0, 0, 0);                           \
+      _ret = RFAILED;                                                \
+   }                                                                 \
+}
+#endif /* ERRCLASS & ERRCLS_INT_PAR */                              
+#else /* LTE_L2_MEAS */
+#if (ERRCLASS & ERRCLS_INT_PAR)
+#define PJ_VALDATE_SAP(_cb, _chkSpId, _sap, _ret)                    \
+{                                                                    \
+   if (_chkSpId != _sap->spId)                                       \
+   {                                                                 \
+      RLOG0(L_ERROR,"Sap Id Validation Failed.");                     \
+      _ret = RFAILED;                                                \
+   }                                                                 \
+   /* SAP state validation */                                        \
+   if(_sap->state != PJ_SAP_BND)                                     \
+   {                                                                 \
+      RLOG0(L_ERROR,"Sap State Invalid.");                            \
+      pjLmmSendAlarm(_cb, LCM_CATEGORY_INTERFACE, LCM_EVENT_UI_INV_EVT,   \
+            LCM_CAUSE_INV_STATE, 0, 0);                              \
+      _ret = RFAILED;                                                \
+   }                                                                 \
+}
+#else /* ERRCLASS & ERRCLS_INT_PAR */
+#define PJ_VALDATE_SAP(_cb, _chkSpId, _sap, _ret)                         \
+{                                                                    \
+   /* SAP state validation */                                        \
+   if(_sap->state != PJ_SAP_BND)                                     \
+   {                                                                 \
+      RLOG0(L_ERROR,"Sap State Invalid.");                            \
+      pjLmmSendAlarm(_cb, LCM_CATEGORY_INTERFACE, LCM_EVENT_UI_INV_EVT,   \
+            LCM_CAUSE_INV_STATE, 0, 0);                              \
+      _ret = RFAILED;                                                \
+   }                                                                 \
+}
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+#endif/* LTE_L2_MEAS */
+
+#ifdef TENB_DPDK_BUF
+#define PJ_FREE_FLAT_BUF(_cb, _buf)                                 \
+{                                                                   \
+   if(((_buf)->len != 0) && ((_buf)->startAddr != NULLP))           \
+   {                                                                \
+      (Void) SPutSBufDpdk((Data *) (_buf)->startAddr);                \
+   }                                                                \
+}
+#else /* TENB_DPDK_BUF */
+#ifdef INTEL_WLS
+
+#define PJ_FREE_FLAT_BUF(_cb, _buf)                                 \
+{                                                                   \
+   if(((_buf)->len != 0) && ((_buf)->startAddr != NULLP))           \
+   {                                                                \
+      (Void) SPutSBufWls(_cb->init.region, _cb->init.pool,             \
+            (Data *) (_buf)->startAddr, (Size)(2048));              \
+   }\
+}
+#else
+#ifdef FLAT_BUFFER_OPT
+#define PJ_FREE_FLAT_BUF(_cb, _buf) \
+{ \
+   if(((_buf)->len != 0) && ((_buf)->startAddr != NULLP))\
+   {\
+      (Void) SPutStaticBuffer(_cb->init.region, _cb->init.pool,   \
+            (Data *) (_buf)->startAddr, (Size)((_buf)->ptr - (_buf)->startAddr + (_buf)->len) , 0);                 \
+   }\
+}
+#endif /* FLAT_BUFFER_OPT */
+#endif /* INTEL_WLS */
+#endif /* TENB_DPDK_BUF */
+
+
+#define PJ_FREE_SHRABL_BUF(_cb,_buf, _size)                          \
+{                                                         \
+   if (_buf != NULLP)                                     \
+   {                                                      \
+      (Void) SPutStaticBuffer(_cb->init.region, _cb->init.pool,   \
+            (Data *) _buf, (Size) _size, 0);                 \
+      _buf = NULLP;                                       \
+   }                                                      \
+}
+
+#define PJ_ALLOC_SHRABL_BUF(_cb,_buf, _size)                                    \
+{                                                                    \
+ if (SGetStaticBuffer(_cb->init.region, _cb->init.pool, (Data **)&_buf,      \
+                (Size) _size, 0) == ROK)                                \
+   {                                                                 \
+      cmMemset((U8 *)(_buf), 0, _size);                              \
+   }                                                                 \
+   else                                                              \
+   {                                                                 \
+      (_buf) = NULLP;                                                \
+   }                                                                 \
+}
+
+#define PJ_ALLOC_SHRABL_BUF_WM(_cb,_buf, _size)                                    \
+{                                                                    \
+ SGetStaticBuffer(_cb->init.region, _cb->init.pool, (Data **)&_buf,      \
+                (Size) _size, 0);                                \
+}
+
+#ifndef XEON_SPECIFIC_CHANGES
+#define PJ_FREE_SHRABL_BUF_PST(_region, _pool, _buf, _size)                          \
+{                                                         \
+   if (_buf != NULLP)                                     \
+   {                                                      \
+      (Void) SPutStaticBuffer(_region, _pool,   \
+            (Data *) _buf, (Size) _size, 0);                 \
+      _buf = NULLP;                                       \
+   }                                                      \
+}
+#else
+#define PJ_FREE_SHRABL_BUF_PST(_region, _pool, _buf, _size)           \
+{                                                          \
+   if (_buf != NULLP)                                      \
+   {                                                       \
+      (Void) SPutSBuf(_region, _pool,                      \
+                      (Data *) _buf, (Size) _size);        \
+      _buf = NULLP;                                        \
+   }                                                       \
+}     
+#endif
+
+#define PJ_ALLOC_SHRABL_BUF_PST(_region, _pool, _buf, _size)                                    \
+{                                                                    \
+ SGetStaticBuffer(_region, _pool, (Data **)&_buf,      \
+                (Size) _size, 0);                                \
+}
+
+#ifndef XEON_SPECIFIC_CHANGES                                       
+#define PJ_ALLOC_BUF_SHRABL(_pst, _buf, _size, _ret)                   \
+{                                                                   \
+      if(SGetStaticBuffer(_pst.region, _pst.pool, (Data **)&_buf,   \
+               (Size) _size, 0) != ROK)                             \
+      {                                                             \
+         _ret = RFAILED;                                            \
+      }                                                             \
+}
+#else
+#define PJ_ALLOC_BUF_SHRABL(_pst, _buf, _size, _ret)                   \
+{                                                                   \
+      if(SGetSBuf(_pst.region, _pst.pool, (Data **)&_buf,   \
+               (Size) _size) != ROK)                             \
+      {                                                             \
+         _ret = RFAILED;                                            \
+      }                                                             \
+}
+#endif
+
+#define PJ_PJDBM_CREATE_RBCB(_rbCb,_rbCbLst, _rbId, _rbType)    \
+{                                                               \
+    /* Allocate memory for rbCb */                              \
+   PJ_ALLOC(_rbCb, sizeof(RbCb));                               \
+                                                                \
+   if ( rbCb != NULLP)                                          \
+   {                                                            \
+      _rbCbLst[_rbId] = (_rbCb);                                \
+      _rbCb->kwRbCb.rlcId.rbId = _rbId;                         \
+   }                                                            \
+}                                                               
+
+/* Macros for configuration module */
+#define PJ_CFG_FILL_CFG_CFM(_entCfm, _rbId, _rbType, _status, _reason)   \
+{                                                                        \
+   _entCfm->rbId  = _rbId;                                               \
+   _entCfm->rbType  = _rbType;                                           \
+   _entCfm->status = _status;                                            \
+   _entCfm->reason = _reason;                                            \
+}
+
+#define PJ_CFG_FILL_SECCFG_CFM(_entCfm, _ueId, _cellId, _transId, _status, _reason)  \
+{                                                               \
+   _entCfm->ueId   = _ueId;                                     \
+   _entCfm->cellId = _cellId;                                   \
+   _entCfm->transId = _transId;                                 \
+   _entCfm->status = _status;                                   \
+   _entCfm->reason = _reason;                                   \
+}
+
+#define PJ_CFG_FILL_SDUSTA_CFM(_entCfm, _ueId, _cellId, _transId, _status, _reason)  \
+{                                                               \
+   _entCfm->ueId   = _ueId;                                     \
+   _entCfm->cellId = _cellId;                                   \
+   _entCfm->transId = _transId;                                 \
+   _entCfm->status = _status;                                   \
+   _entCfm->reason = _reason;                                   \
+}
+
+#define PJ_CFG_FILL_REESTREQ_CFM(_entCfm, _ueId, _cellId, _transId, _status)  \
+{                                                               \
+   _entCfm->ueId   = _ueId;                                     \
+   _entCfm->cellId = _cellId;                                   \
+   _entCfm->transId = _transId;                                 \
+   _entCfm->status = _status;                                   \
+}
+/*
+#define PJ_UPD_COUNT(_pjRbCb, _sn, _txHfn, _count)         \
+{                                                          \
+   _count = _txHfn << (_pjRbCb->snLen);                    \
+   _count |= _sn;                                       \
+} */
+#define PJ_ADD_PST_MSG(_pdu, _hdr, _size, _ret)            \
+{                                                          \
+   Data _liByte;                                           \
+   S16  _bytes;                                            \
+   _bytes = _size - 1;                                     \
+   while (_bytes >= 0 )                                    \
+   {                                                       \
+      _liByte = (U8) (_hdr >> (8*_bytes));                 \
+      _ret = SAddPstMsg((Data )_liByte, _pdu);             \
+      if ( _ret != ROK )                                   \
+      {                                                    \
+         break;                                            \
+      }                                                    \
+      _bytes--;                                            \
+   }                                                       \
+}
+
+#define PJ_RESET_ALL_VAR(_pjRbCb)                          \
+{                                                          \
+   _pjRbCb->dlCb.cfmExp   = 0;                             \
+   _pjRbCb->dlCb.count    = 0;                             \
+   _pjRbCb->dlCb.txNext  =  0;                             \
+}
+
+#define PJ_ALLOC(_cb, _buf, _size)                         \
+{                                                          \
+ if (SGetSBuf(_cb->init.region, _cb->init.pool, (Data **)&_buf,\
+                (Size) _size) == ROK)                      \
+   {                                                       \
+      cmMemset((U8 *)(_buf), 0, _size);                    \
+   }                                                       \
+   else                                                    \
+   {                                                       \
+      (_buf) = NULLP;                                      \
+   }                                                       \
+}
+
+#define PJ_ALLOC_WC(_cb, _buf, _size)\
+{ \
+ if (SGetSBuf(_cb->init.region, _cb->init.pool, (Data **)&_buf,\
+                (Size) _size) != ROK)                      \
+   {                                                       \
+      (_buf) = NULLP;                                      \
+   }                                                       \
+}
+
+
+#define PJ_FREE_BUF(_buf)                                  \
+{                                                          \
+   if (_buf != NULLP)                                      \
+   {                                                       \
+      SPutMsg(_buf);                                       \
+   }                                                       \
+   _buf = NULLP;                                           \
+}
+
+#define PJ_FREE(_cb, _buf, _size)                               \
+{                                                          \
+   if (_buf != NULLP)                                      \
+   {                                                       \
+      (Void) SPutSBuf(_cb->init.region, _cb->init.pool,    \
+                         (Data *) _buf, (Size) _size);     \
+      _buf = NULLP;                                        \
+   }                                                       \
+}     
+
+#define PJ_PST_FREE(_region, _pool, _buf, _size)           \
+{                                                          \
+   if (_buf != NULLP)                                      \
+   {                                                       \
+      (Void) SPutSBuf(_region, _pool,                      \
+                      (Data *) _buf, (Size) _size);        \
+      _buf = NULLP;                                        \
+   }                                                       \
+}     
+                                                                                        
+#define PJ_MEM_CPY(_dst, _src, _size)                      \
+{                                                          \
+   cmMemcpy((U8*)_dst, (U8 *)_src, _size);                 \
+}
+
+#define PJ_DLM_UPD_VAR(_pjRbCb, _count)               \
+{                                                          \
+   PjDlCb    *_dlCb;                                       \
+                                                           \
+   _dlCb   = &_pjRbCb->dlCb;                              \
+   _count  = _dlCb->txNext;                               \
+   if ( (++_dlCb->txNext) ==  0xFFFFFFFF)                 \
+   {                                                       \
+      _dlCb->txNext = 0;                                   \
+   }                                                       \
+}
+#define PJ_DLM_GET_SN(_pjRbCb, _count,_sn) \
+{\
+   _sn    = (_count % ( _pjRbCb->maxTxSn));      \
+}
+
+
+#define PJ_FILL_CFM_OK(_cb,_pjRbCb, _fms, _datCfm)             \
+{                                                          \
+   U32     _startCount = _pjRbCb->dlCb.cfmExp;             \
+   U32     _stopCount  = _pjRbCb->dlCb.cfmExp;             \
+   PjTxEnt *_ent;                                          \
+   _ent = (PjTxEnt *)pjDbmGetTxEntSn(_cb, &(_pjRbCb->dlCb.txBuf), _fms); \
+   if ( _ent != NULLP )                                    \
+   {                                                       \
+      _stopCount = _ent->count;                            \
+      _pjRbCb->dlCb.cfmExp = _ent->count;                  \
+      _pjRbCb->dlCb.nxtToSub = _ent->count;                \
+   }                                                       \
+   while ( _startCount < _stopCount )                      \
+   {                                                       \
+      _ent = (PjTxEnt *)pjDbmGetTxEnt(_cb, &(_pjRbCb->dlCb.txBuf), _startCount);\
+      if ( _ent != NULLP )                                 \
+      {                                                    \
+         if ( _pjRbCb->dlCb.cfmReqd)                       \
+         {                                                 \
+            _datCfm->cfmSta[_datCfm->numSdus].sduId  = _ent->sduId;\
+            _datCfm->cfmSta[_datCfm->numSdus].status = PJ_CFM_OK;\
+            _datCfm->numSdus++;                            \
+         }                                                 \
+         pjDbmDelTxEnt(_cb, &(pjRbCb->dlCb.txBuf), _ent->count);\
+      }                                                    \
+      _startCount++;                                       \
+   }                                                       \
+}
+
+#define PJ_UPD_CFM_EXP(_cb,_dlCb)                              \
+{                                                          \
+   U32 _curCount = _dlCb->count;                            \
+   U32 _count    = _dlCb->cfmExp;                           \
+   PjTxEnt *_txEnt = NULLP;                                \
+   while ( _count <= _curCount )                           \
+   {                                                       \
+      _txEnt = (PjTxEnt *)pjDbmGetTxEnt(_cb,&(_dlCb->txBuf), _count);\
+      if ( _txEnt != NULLP )                               \
+      {                                                    \
+         break;                                            \
+      }                                                    \
+      _count++;                                            \
+   }                                                       \
+   _dlCb->cfmExp = _count;                                  \
+}
+
+#define PJ_UPD_DL_VAR(_cb, _pjRbCb, _curCnt)                    \
+{                                                          \
+   U32   _count = _curCnt + 1;                             \
+   if ( _pjRbCb->dlCb.nxtToSub == _curCnt )                \
+   {                                                       \
+      _pjRbCb->dlCb.nxtToSub = _count;                     \
+   }                                                       \
+   if ( _pjRbCb->dlCb.cfmExp  == _curCnt )                 \
+   {                                                       \
+      _pjRbCb->dlCb.cfmExp = _count;                       \
+   }                                                       \
+}
+
+#define PJ_CREATE_NEW_LIST(_cb,_pjRbCb, _tmpTxBuf, _ret)       \
+{                                                          \
+   _tmpTxBuf.datQ  = _pjRbCb->dlCb.txBuf.datQ;             \
+   _tmpTxBuf.numEntries =  pjRbCb->dlCb.txBuf.numEntries;  \
+   _tmpTxBuf.numBins =  pjRbCb->dlCb.txBuf.numBins;        \
+   _tmpTxBuf.sduSubmitQ = pjRbCb->dlCb.txBuf.sduSubmitQ;   \
+   pjDbmDlBufInit(_cb,&pjRbCb->dlCb.txBuf,_cb->pjGenCfg.nmbDlBins);\
+   if ( _pjRbCb->dlCb.txBuf.datQ == NULLP )                \
+   {                                                       \
+      RLOG0(L_ERROR,"PJ_CREATE_NEW_LIST: PJ_ALLOC Failed.");          \
+      _ret = RFAILED;                                      \
+   }                                                       \
+}
+
+#define PJ_SND_ROHC_FDB(_cb,_pjRbCb, _rohcFdbPdu, _ret)        \
+{                                                          \
+   Data _hdr = 0;                                          \
+   U32  _count = 0;                                        \
+   _hdr |= PJ_ROHC_FEEDBACK_HDR;                           \
+   _ret = SAddPreMsg((Data) _hdr, _rohcFdbPdu);            \
+   if ( _ret != ROK )                                      \
+   {                                                       \
+      RLOG0(L_ERROR,"PJ_SND__ROHC_FDB: SAddPreMsg failed for pdu ");\
+      PJ_FREE_BUF(_rohcFdbPdu);                            \
+      _ret  =  RFAILED;                                    \
+   }                                                       \
+   if ( _pjRbCb->mode == PJ_DRB_UM )                       \
+   {                                                       \
+      _count = _pjRbCb->dlCb.nxtToSub - 1;                 \
+   }                                                       \
+   else                                                    \
+   {                                                       \
+      _count = _pjRbCb->dlCb.cfmExp - 1;                   \
+   }                                                       \
+   if ( _ret == ROK )                                      \
+   {                                                       \
+      pjDlmSendDatReq(_cb, _pjRbCb, _count, _rohcFdbPdu);           \
+   }                                                       \
+}
+
+#define PJ_MAX_HASH_BINS 255
+
+/* Defines used in gp_pj_dbm.c */
+#define PJ_HASH_FN(_buf, _cnt) (_cnt % PJ_MAX_HASH_BINS)
+
+/* Defines used in gp_pj_ulm.c */
+#define MAX_BMAP_SIZE         2048
+#define PJ_WINSIZE(_snLen) (1 << (_snLen - 1))    
+#define PJ_MAX_HFN(_snLen) ((1 << (32 - _snLen)) - 1)
+#define PJ_U16_BIT_SIZE       16
+#define PJ_BYTE_SIZE          8
+//#define PJ_SRB_SN_LEN         12
+#define PJ_SRB_SN_LEN         12
+#define PJ_DRBAM_SN_LEN       12
+#define PJ_TYPE_DRB_DATA      0x80
+#define PJ_TYPE_STATUS_REPORT  0x00
+#define PJ_TYPE_ROHC_FEEDBACK 0x01
+#define PJ_PDU_BIT_MASK       0x70
+#define PJ_12_BIT_SN_MSB_MASK 0x0F
+#define PJ_18_BIT_SN_MSB_MASK 0x03
+#define PJ_CPDU_RES_VAL_MASK       0x0F
+#define PJ_MACI_LEN           4
+
+#define PJ_RDY_TO_DCIPHER      1
+#define PJ_SENT_TO_DCIPHER     2
+#define PJ_RDY_TO_INTVER       3
+#define PJ_SENT_TO_INTVER      4
+#define PJ_RDY_TO_DCOMP        5
+#define PJ_SENT_TO_DCOMP       6
+#define PJ_RDY_TO_SUBMIT       7
+#define PJ_RX_ENT_TO_DEL       8
+#define PJ_RX_INTVER_FAIL      9
+
+#define PJ_STATE_NORMAL       1
+#define PJ_STATE_REEST        2
+#define PJ_STATE_REEST_HO     3
+#define PJ_STATE_HO           4
+#define PJ_TMR_ULM_OBD        10
+
+/* Defines used in gp_pj_utl.c */
+#define PJ_LIB_COMP_BIT_MASK     0x00000001
+#define PJ_LIB_INT_BIT_MASK      0x00000002
+#define PJ_LIB_CP_CIP_BIT_MASK   0x00000004
+#define PJ_LIB_UP_CIP_BIT_MASK   0x00000008
+
+#define PJ_MAX_SDU_IN_DAT_FWD_IND      5
+/* Defines used for multi cfg confirms */
+#define PJ_MAX_ASYNC_CFM   2
+
+#define PJ_SEC_ASYNC_CFM         0x01
+#define PJ_CFG_ASYNC_CFM         0x02
+#define PJ_CFG_REEST_ASYNC_CFM   0x04
+#define PJ_CFG_UEDEL_ASYNC_CFM   0x08
+#define PJ_REEST_ASYNC_CFM       0x10
+
+#define  PJ_SEC_INIT_CFM   1
+#define  PJ_CMP_INIT_CFM   2
+
+#define PJ_GET_MEM_REGION(_cb) (_cb->init.region)
+
+#define PJ_GET_MEM_POOL(_cb) (_cb->init.pool)
+
+#define PJ_GET_MEM_POOL_ADDRESS(_cb) (&_cb->init.pool)
+
+#define PJ_GET_DBG_MASK(_cb) (_cb->init.dbgMask)
+
+/* Memset to value */
+#define PJ_MEM_SET(_arg, _val, _size) \
+{ \
+  cmMemset((U8 *)_arg, (U8)_val, _size); \
+}
+
+/* Set the unsolictated Status flag */
+#define PJ_SET_USTA_FLAG(_cb, _value) \
+{ \
+   _cb->init.usta = _value; \
+}
+
+#define PJ_DATA_FWD_PKT   1
+#define PJ_DATA_NRM_PKT   2
+
+#define PJ_CHK_RESTART_OBD_TIMER(_cb,_ueCb, _cfgTxId)                    \
+{                                                                             \
+   U16 _idx;                                                                  \
+   if(_ueCb->libInfo.crntTmrTxId == _cfgTxId)                                 \
+   {                                                                          \
+      pjStopTmr(_cb,(PTR)_ueCb, PJ_EVT_OBD_WAIT_TMR);                         \
+   }                                                                          \
+                                                                              \
+   if(pjChkTmr(_cb,(PTR)_ueCb, PJ_EVT_OBD_WAIT_TMR) == FALSE)                 \
+   {                                                                          \
+      for(_idx = 0; _idx < (PJ_MAX_ASYNC_CFM - 1) ; _idx++)                   \
+      {                                                                       \
+         _ueCb->libInfo.crntTmrTxId =                                         \
+               (U16)((_ueCb->libInfo.crntTmrTxId + 1) % PJ_MAX_ASYNC_CFM);          \
+         if((_ueCb->libInfo.asyncCfm[_ueCb->libInfo.crntTmrTxId] != NULLP) && \
+            (_ueCb->libInfo.asyncCfm[_ueCb->libInfo.crntTmrTxId]->startTmr    \
+                                                      == TRUE))               \
+         {                                                                    \
+            pjStartTmr(_cb,(PTR)_ueCb, PJ_EVT_OBD_WAIT_TMR);                 \
+            break;                                                            \
+         }                                                                    \
+      }                                                                       \
+   }                                                                          \
+}                                                                             \
+
+#define PJ_CLEAN_AND_UPD_ASYNCINFO(_cb,_ueCb, _txIdx)                 \
+{                                                                 \
+   PJ_FREE(_cb,_ueCb->libInfo.asyncCfm[_txIdx], sizeof(PjAsyncCfm));  \
+   _ueCb->libInfo.asyncCfm[_txIdx]=NULLP;                         \
+   if(_ueCb->libInfo.nxtAvlbTxId  == PJ_MAX_ASYNC_CFM)            \
+   {                                                              \
+      _ueCb->libInfo.nxtAvlbTxId  = _txIdx;                       \
+   }                                                              \
+}                                                                 \
+
+#define PJ_FILL_TIMEOUT_CFG_CFM_INFO(_cb,_cfgCfm, _asyncCfm)               \
+{                                                                            \
+      U16 _idx;                                                              \
+      PJ_ALLOC(_cb,_cfgCfm, sizeof(CpjCfgCfmInfo));                         \
+      if (_cfgCfm != NULLP)                                                  \
+      {                                                                      \
+         for ( _idx = 0; _idx < _asyncCfm->numEnt ; _idx++)                  \
+         {                                                                   \
+            if ( _asyncCfm->cmpInitBitMask &                                 \
+                           (1 << (_asyncCfm->cfmEnt[_idx].rbId - 1)))        \
+            {                                                                \
+               _cfgCfm->cfmEnt[_idx].status =  CPJ_CFG_CFM_NOK;              \
+               _cfgCfm->cfmEnt[_idx].reason = CPJ_CFG_REAS_OBD_TIMEOUT;      \
+            }                                                                \
+            else                                                             \
+            {                                                                \
+               _cfgCfm->cfmEnt[_idx].status = _asyncCfm->cfmEnt[_idx].status;\
+               _cfgCfm->cfmEnt[_idx].reason = _asyncCfm->cfmEnt[_idx].reason;\
+            }                                                                \
+            _cfgCfm->cfmEnt[_idx].rbId   = _asyncCfm->cfmEnt[_idx].rbId;     \
+            _cfgCfm->cfmEnt[_idx].rbType = _asyncCfm->cfmEnt[_idx].rbType;   \
+         }                                                                   \
+         _cfgCfm->ueId    = _asyncCfm->ueId;                                 \
+         _cfgCfm->cellId  = _asyncCfm->cellId;                               \
+         _cfgCfm->transId = _asyncCfm->transId;                              \
+         _cfgCfm->numEnt  = _asyncCfm->numEnt;                               \
+      }                                                                      \
+}                                                                            \
+
+#ifdef PJ_SEC_ASYNC
+/* In the case when all the elements in the reception buffer have already
+ * been sent to the dcomp unit or sent up, our nxtSubDcomp will be pointing to 
+ * NEXT_PDCP_RX_SN. So if there is a jump, this has to be updated accordingly */
+#define PJ_ULM_UPD_NXT2DCOMP(_ulCb, _snLen, _rcvdCount, _oldRxCnt)        \
+{                                                                  \
+   if(_oldRxCnt == _ulCb->nxtSubDeCmp)                             \
+   {                                                               \
+      _ulCb->nxtSubCnt = _rcvdCount;                               \
+   }                                                               \
+}
+#else  /* !PJ_SEC_ASYNC */
+#define PJ_ULM_UPD_NXT2DCOMP(_ulCb, _snLen, _sn, _oldRxCnt) 
+#endif /* PJ_SEC_ASYNC */
+
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+/* There can be a case where the first PDU that you receive *
+ * does not match with the NEXT_PDCP_RX_SN. If nxtSubCnt is also
+ * pointing to NETX_PDCP_RX_SN, it has to be updated. */
+#define PJ_ULM_UPD_NXT2SUB(_ulCb, _cnt)                      \
+{                                                            \
+   if(_ulCb->recBuf.numEntries == 0)                         \
+   {                                                         \
+      _ulCb->nxtSubCnt = _cnt;                               \
+      _ulCb->nxtSubDeCmp = _cnt;                             \
+   }                                                         \
+}
+#define PJ_INC_OBD_COUNT(_pjRbCb, _count)                                \
+{                                                                        \
+   if(_pjRbCb->state == PJ_STATE_REEST ||                                \
+         _pjRbCb->state == PJ_STATE_REEST_HO)                            \
+   {                                                                     \
+      _pjRbCb->ulCb.obdCnt ++;                                           \
+   }                                                                     \
+}
+
+/* Notes: This will be called only for DRBs */
+#define PJ_DEC_OBD_COUNT(_cb, _pjRbCb, _count)                                \
+{                                                                        \
+   if(_pjRbCb->state == PJ_STATE_REEST ||                                \
+         _pjRbCb->state == PJ_STATE_REEST_HO)                            \
+   {                                                                     \
+      if((_count >= _pjRbCb->ulCb.firstReEstCnt)&&                       \
+         (_pjRbCb->mode = PJ_DRB_AM))                                    \
+      {                                                                  \
+         _pjRbCb->ulCb.obdCnt --;                                        \
+      }                                                                  \
+   }                                                                     \
+}
+#else /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
+/* Dummy defines */
+#define PJ_ULM_UPD_NXT2SUB(_ulCb, _cnt)    
+#define PJ_INC_OBD_COUNT(_pjRbCb, _count)  
+#define PJ_DEC_OBD_COUNT(_cb,_pjRbCb, _count)  
+#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
+
+
+#define PJ_INC_SN(_sn, _snLen) ((++_sn) % (1 << _snLen))                      \
+
+#define PJ_GET_SN_HFN(_count, _snLen, _sn, _hfn)             \
+{                                                            \
+   _sn   = (_count % (1 << _snLen));                          \
+   _hfn  =  (_count >> _snLen);                              \
+}                                                            \
+
+#define PJ_GET_HFN(_count,_snLen,_hfn)\
+{\
+   _hfn = (_count >> _snLen);\
+}
+#define PJ_GET_SN(_count, _snLen, _sn)  (_sn   =  _count % (1 << _snLen));
+
+#define PJ_ULM_REEST_DRB_AM(_pjRbCb)                         \
+{                                                            \
+   _pjRbCb->frstReEstCnt =  _pjRbCb->rxDeliv;         \
+   _pjRbCb->obdCnt  =  0;                                    \
+                                                             \
+}                                                            
+
+
+/* kw005.201,replaced macro with function */
+#define PJ_SND_PJU_STA_IND(_cb,_pjRbCb, _rxEnt)              \
+{                                                        \
+   CmLtePdcpId  _pdcpId;                                \
+   Buffer   *_mBuf = NULLP;                              \
+   PjuStaIndInfo  _staInd;                              \
+   PjPjuSapCb  *_pjuSap;                                 \
+                                                         \
+   if (_pjRbCb->rbType == PJ_SRB)                        \
+      _pjuSap   = &(_cb->u.ulCb->pjuSap[PJ_SRB_SAP]);                \
+   else                                                  \
+      _pjuSap   = &(_cb->u.ulCb->pjuSap[PJ_DRB_SAP]); \
+                                                                     \
+                                                         \
+                                                         \
+      _pdcpId.ueId   =  _pjRbCb->ueCb->key.ueId;        \
+      _pdcpId.cellId =  _pjRbCb->ueCb->key.cellId;      \
+      _pdcpId.rbId   =  _pjRbCb->rbId;                  \
+      _pdcpId.rbType =  _pjRbCb->rbType;                \
+                                                         \
+      switch (_rxEnt->state)                             \
+      {                                                  \
+         case PJ_RDY_TO_DCIPHER:                         \
+         case PJ_SENT_TO_DCIPHER:                        \
+         {                                               \
+            _staInd.cause  =  PJU_DCIP_FAILED;          \
+            break;                                       \
+         }                                               \
+         case PJ_RDY_TO_INTVER:                          \
+         case PJ_SENT_TO_INTVER:                         \
+         {                                               \
+            _staInd.cause  =  PJU_INTVER_FAILED;        \
+               _mBuf          =  _rxEnt->mBuf;           \
+               _rxEnt->mBuf    =  NULLP;                 \
+            break;                                       \
+         }                                               \
+         case PJ_RDY_TO_DCOMP:                           \
+         case PJ_SENT_TO_DCOMP:                          \
+         {                                               \
+            _staInd.cause  =  PJU_DCOMP_FAILED;         \
+            if(_pjRbCb->ulCb.discReqd == FALSE)          \
+            {                                            \
+               _mBuf          =  _rxEnt->mBuf;           \
+               _rxEnt->mBuf    =  NULLP;                 \
+            }                                            \
+            break;                                       \
+         }                                               \
+         default:                                        \
+            break;                                       \
+      }                                                  \
+      PjUiPjuStaInd(&(_pjuSap->pst), _pjuSap->suId,      \
+                    &_pdcpId, &_staInd, _mBuf);            \
+}
+
+
+
+#define PJ_SND_PJU_DAT_IND(_cb,_pjRbCb, _rxEnt)         \
+{                                                   \
+   CmLtePdcpId  _pdcpId;                   \
+   Buffer        *_mBuf;                            \
+   PjPjuSapCb  *_pjuSap;                            \
+                                                    \
+   if (_pjRbCb->rbType == PJ_SRB)                   \
+   {                                                \
+      _pjuSap   = &(_cb->u.ulCb->pjuSap[PJ_SRB_SAP]);       \
+   }                                                \
+   else                                             \
+   {                                                \
+      PJ_UPD_L2_ULLOSS_CNTRS(_cb,_rxEnt->count, _pjRbCb)        \
+      _pjuSap   = &(_cb->u.ulCb->pjuSap[PJ_DRB_SAP]);       \
+   }                                               \
+                                                    \
+      _pdcpId.ueId   =  _pjRbCb->ueCb->key.ueId;   \
+      _pdcpId.cellId =  _pjRbCb->ueCb->key.cellId; \
+      _pdcpId.rbType =  _pjRbCb->rbType;           \
+      _pdcpId.rbId   =  _pjRbCb->rbId;             \
+      _mBuf       =  _rxEnt->mBuf;                  \
+      _rxEnt->mBuf =  NULLP;                        \
+                                                    \
+      /* If trace flag is enabled send the trace indication */\
+      if(_cb->init.trc == TRUE)                     \
+      {                                             \
+         /* Populate the trace params */            \
+         pjLmmSendTrc(_cb,EVTPJUDATIND, _mBuf);         \
+      }                                             \
+                                                    \
+      PjUiPjuDatInd(&(_pjuSap->pst), _pjuSap->suId, \
+             &_pdcpId, _mBuf);                       \
+      PJ_STS_INC_PJU_CNT(_cb,_pjRbCb->rbType, txSdus)   \
+}
+
+
+#define  PJ_FILL_REEST_CFM_INFO(_reEstCfm, _asyncCfm, _status)  \
+{                                                               \
+   _reEstCfm->ueId    =  _asyncCfm->ueId;                       \
+   _reEstCfm->cellId  =  _asyncCfm->cellId;                     \
+   _reEstCfm->transId =  _asyncCfm->transId;                    \
+   _reEstCfm->status  =  _status;                               \
+}
+
+#define  PJ_FILL_SEC_CFM_INFO(_secCfgCfm, _asyncCfm)  \
+{                                                     \
+   _secCfgCfm->ueId    =  _asyncCfm->ueId;            \
+   _secCfgCfm->cellId  =  _asyncCfm->cellId;          \
+   _secCfgCfm->transId =  _asyncCfm->transId;         \
+   _secCfgCfm->status  =  UDX_CFG_CFM_OK;             \
+   _secCfgCfm->reason  =  UDX_CFG_REAS_NONE;          \
+}
+
+#define  PJ_FILL_REEST_CFG_CFM_INFO(_cfmInfo, _asyncCfm)               \
+{                                                                      \
+   U8 _idx;                                                            \
+   for (_idx = 0; _idx < _asyncCfm->numEnt ; _idx++)                   \
+   {                                                                   \
+      if (_asyncCfm->cfmEnt[_idx].cfgType == CPJ_CFG_REESTABLISH)      \
+      {                                                                \
+         _cfmInfo->cfmEnt[_idx].status = CPJ_CFG_CFM_OK;               \
+         _cfmInfo->cfmEnt[_idx].reason = LCM_REASON_NOT_APPL;          \
+      }                                                                \
+      else                                                             \
+      {                                                                \
+         _cfmInfo->cfmEnt[_idx].status = _asyncCfm->cfmEnt[_idx].status;\
+         _cfmInfo->cfmEnt[_idx].reason = _asyncCfm->cfmEnt[_idx].reason;\
+      }                                                                \
+      _cfmInfo->cfmEnt[_idx].rbId  = _asyncCfm->cfmEnt[_idx].rbId;      \
+      _cfmInfo->cfmEnt[_idx].rbType  = _asyncCfm->cfmEnt[_idx].rbType; \
+   }                                                                   \
+   _cfmInfo->ueId    = _asyncCfm->ueId;                                \
+   _cfmInfo->cellId  = _asyncCfm->cellId;                              \
+   _cfmInfo->transId = _asyncCfm->transId;                             \
+   _cfmInfo->numEnt  = _asyncCfm->numEnt;                              \
+}
+
+
+#define PJ_PERFORM_ERR_UPDATES(_cb, _pjRbCb, _count) \
+{                                               \
+   PjUlCb   *_upCb;                             \
+                                                \
+   _upCb =  &_pjRbCb->ulCb;                  \
+   if(_upCb->recBuf.numEntries != 0)            \
+   {                                            \
+      PJ_CALC_NXT2SUB(_cb, _upCb);        \
+   }                                            \
+   PJ_CHK_RDY_TO_DELIVER(_cb, _pjRbCb);              \
+}
+
+
+#define PJ_CALC_NXT2SUB(_cb, __ulCb)                                             \
+{                                                                          \
+   PjRxEnt  *_rxEnt;                                                       \
+   U32  _nxtToSub;                                                         \
+   _nxtToSub = __ulCb->nxtSubCnt;                                           \
+   if(__ulCb->recBuf.numEntries != 0)                                       \
+   {                                                                       \
+      _nxtToSub ++;                                                        \
+      while( (_rxEnt = (PjRxEnt *)pjDbmGetRxEnt(_cb, &ulCb->recBuf, _nxtToSub)) != NULLP)\
+      {                                                                 \
+         __ulCb->nxtSubCnt++;                                            \
+      }                                                                 \
+   }                                                                       \
+   __ulCb->nxtSubCnt  =  _nxtToSub;                                         \
+}
+
+
+#define PJ_CHK_RDY_TO_DELIVER(_cb, _pjRbCb)                     \
+{                                                          \
+   PjUlCb   *_ulCb;                                       \
+   PjRxEnt  *_rxEnt;                                      \
+                                                           \
+   _ulCb  =  &_pjRbCb->ulCb;                                     \
+   if(_ulCb->recBuf.numEntries == 0)                       \
+   {                                                       \
+      if((_pjRbCb->rbType   ==  PJ_DRB)&&                  \
+         (_pjRbCb->state != PJ_STATE_NORMAL))              \
+      {                                                    \
+            if((_ulCb->transCmp)                          \
+                  && (_ulCb->obdCnt == 0)                \
+              )                                            \
+            {                                              \
+               pjUlmReEstDrbAm(_cb, _pjRbCb);                     \
+            }                                              \
+      }                                                    \
+   }                                                       \
+   else                                                    \
+   {                                                       \
+     _rxEnt  =  (PjRxEnt *)pjDbmGetRxEnt(_cb, &_ulCb->recBuf, ulCb->nxtSubCnt);\
+     if( _rxEnt && _rxEnt->state == PJ_RDY_TO_SUBMIT)      \
+     {                                                     \
+        if(_pjRbCb->rbType == PJ_SRB)                      \
+        {                                                  \
+           pjUlmDeliverSrb(_cb, _pjRbCb, _rxEnt);                \
+        }                                                  \
+        else                                               \
+        {                                                  \
+           if(_pjRbCb->mode   == PJ_DRB_UM)                \
+           {                                               \
+              pjUlmDeliverDrbUm(_cb, _pjRbCb, _rxEnt);           \
+           }                                               \
+           else                                            \
+           {                                               \
+              pjUlmDeliverDrbAm(_cb, _pjRbCb, _rxEnt);           \
+           }                                               \
+        }                                                  \
+     }                                                     \
+   }                                                       \
+}                                                          
+
+#define PJ_GET_COUNT(_count, _snLen, _sn, _hfn)              \
+{                                                            \
+   _count   = ((_hfn << _snLen) | _sn);                       \
+}
+                                                            
+
+#define PJ_CALC_RCVD_HFN(_rcvdSn,_snLen,_rxDeliv,_rcvdHfn)     \
+{                                                              \
+   U32  _hfn;                                                  \
+   U32  _sn;                                                   \
+   S32  _winSize;                                              \
+   PJ_GET_SN_HFN(_rxDeliv,_snLen,_sn,_hfn);                    \
+   _winSize = _sn - PJ_WINSIZE(_snLen);                        \
+   if((_winSize > 0) && (_rcvdSn < _winSize))                  \
+   {                                                           \
+       _rcvdHfn = _hfn + 1;                                    \
+   }                                                           \
+   else if(_rcvdSn >= (_sn + PJ_WINSIZE(_snLen)))              \
+   {                                                           \
+       _rcvdHfn = _hfn - 1;                                    \
+   }                                                           \
+   else                                                        \
+   {                                                           \
+       _rcvdHfn = _hfn;                                        \
+   }                                                           \
+}                                                              
+
+
+#ifdef LTE_L2_MEAS
+#define PJ_ULM_DRBUM_REEST(_cb,_pjRbCb)       \
+{                                         \
+   _pjRbCb->ulCb.rxNext   = 0;            \
+   _pjRbCb->ulCb.rxDeliv  = 0;            \
+   pjUtlUlHdlRbReEstComplete(_cb, _pjRbCb);         \
+}
+#else
+#define PJ_ULM_DRBUM_REEST(_cb,_pjRbCb)       \
+{                                         \
+   _pjRbCb->ulCb.rxNext   = 0;            \
+   _pjRbCb->ulCb.rxDeliv  = 0;            \
+   pjUtlUlHdlRbReEstComplete(_cb, _pjRbCb);         \
+}
+#endif
+
+
+/* Update state and call the respective delivery 
+ * function */
+#define PJ_ULM_DELIVER_DRB(_cb,_pjRbCb, _rxEnt)  \
+{                                            \
+   if(_pjRbCb->mode == PJ_DRB_AM)            \
+   {                                         \
+      pjUlmDeliverDrbAm(_cb,_pjRbCb, _rxEnt);    \
+   }                                         \
+   else                                      \
+   {                                         \
+      pjUlmDeliverDrbUm(_cb,_pjRbCb, _rxEnt);    \
+   }                                         \
+}
+
+/*update the state variable RX_NEXT */
+#define PJ_ULM_UPDATE_RX_NEXT(_pjRbCb,_rxEnt) \
+{                                             \
+   U32 _diffRxNext;\
+   U32 _diffRcvdCount;\
+   _diffRxNext    = ((_pjRbCb->ulCb.rxNext - _pjRbCb->ulCb.rxDeliv) % PJ_WINSIZE(_pjRbCb->snLen));\
+   _diffRcvdCount = ((_rxEnt->count - _pjRbCb->ulCb.rxDeliv) %  PJ_WINSIZE(_pjRbCb->snLen));\
+   if(_diffRcvdCount >= _diffRxNext)       \
+   {                                          \
+      _pjRbCb->ulCb.rxNext = _rxEnt->count + 1;    \
+   }                                          \
+}                                              
+/* Update state and call the respective delivery 
+ * function */
+#define PJ_ULM_DELIVER_PDU(_cb,_pjRbCb, _rxEnt)  \
+{                                            \
+                                             \
+   if(_pjRbCb->rbType == PJ_SRB)             \
+   {                                         \
+      pjUlmDeliverSrb(_cb,_pjRbCb, _rxEnt);      \
+   }                                         \
+   else                                      \
+   {                                         \
+      PJ_ULM_DELIVER_DRB(_cb,_pjRbCb, _rxEnt);   \
+   }                                         \
+}
+/* There is case that all PDUs in the recv Buf can be back from off board 
+ * but not sent up. In that case, though the the recvBuf has entries the 
+ * obd timer should not be restarted. This works with the PJ_ULM_GET_DRBAM_SUBCNT
+ * macro to acheive this. */
+#define PJ_DRBAM_ALL_PDU_RECVD(_pjRbCb)\
+((pjRbCb->rbType == PJ_DRB) &&         \
+ (pjRbCb->mode == PJ_DRB_AM) &&        \
+ ((ulCb->rxDeliv - 1) == ulCb->obdPdu))   \
+
+
+#define PJ_ULM_GET_DRBAM_SUBCNT(_pjUlRbCb, _nxtSubCnt, _pjCb)                          \
+{                                                                             \
+   U32 _count    = _pjUlRbCb->ulCb.rxDeliv - 1;                                  \
+   U32 _nxtRxCnt  =  (_pjUlRbCb->ulCb.rxNext) ;\
+   PjRxEnt *_rxEnt = NULLP;                                                   \
+   _nxtSubCnt      = _count;                                                  \
+   if(((_pjUlRbCb->state != PJ_STATE_NORMAL) &&                                 \
+       (_pjUlRbCb->ulCb.obdCnt != 0)) ||                                        \
+      ((_pjUlRbCb->state == PJ_STATE_NORMAL) &&                                 \
+       (_pjUlRbCb->ulCb.recBuf.numEntries != 0)))                               \
+   {                                                                          \
+      _count ++;                                                              \
+      for(;_count < _nxtRxCnt; _count ++)                                     \
+      {                                                                       \
+         _rxEnt   = (PjRxEnt *)pjDbmGetRxEnt(_pjCb, &_pjUlRbCb->ulCb.recBuf, _count);  \
+         if((_rxEnt != NULLP) && (_rxEnt->state != PJ_RDY_TO_SUBMIT))         \
+         {                                                                    \
+            _nxtSubCnt  =  _count;                                            \
+            break;                                                            \
+         }                                                                    \
+      }                                                                       \
+   }                                                                          \
+}                                                                                   
+
+
+#define PJ_ULM_GET_SUBCNT(_pjUlRbCb, _subPdu, _pjCb)                        \
+{                                                                  \
+   if((_pjUlRbCb->rbType == PJ_DRB) && (_pjUlRbCb->mode  == PJ_DRB_AM))\
+   {                                                               \
+      PJ_ULM_GET_DRBAM_SUBCNT(_pjUlRbCb, _subPdu, _pjCb);                   \
+   }                                                               \
+   else                                                            \
+   {                                                               \
+      _subPdu =  _pjUlRbCb->ulCb.nxtSubCnt;                           \
+   }                                                               \
+}
+
+
+#define PJ_STS_INC_GEN_CNT(_cb, _cntr)       \
+{                                            \
+   _cb->pjGenSts._cntr++;                    \
+}                                            \
+
+#define PJ_STS_INC_PJU_CNT(_cb, _rbType, _cntr)   \
+{                                            \
+   if (_rbType == PJ_SRB)                    \
+      _cb->u.ulCb->pjuSap[PJ_SRB_SAP].sts._cntr++;   \
+   else                                      \
+      _cb->u.ulCb->pjuSap[PJ_DRB_SAP].sts._cntr++;   \
+}                                            \
+
+#define PJ_PK_U8(_msg, _val, _ret)                                     \
+{                                                                      \
+   (_ret) = SAddPstMsg((Data) (_val), (_msg));                         \
+}
+
+#define PJ_PK_U16(_msg, _val, _ret)                                    \
+{                                                                      \
+   PJ_PK_U8(_msg, (U8) GetHiByte(_val), _ret)                          \
+   if ((_ret) == ROK)                                                  \
+      PJ_PK_U8(_msg, (U8) GetLoByte(_val), _ret)                       \
+}
+
+#define PJ_PK_U32(_msg, _val, _ret)                                    \
+{                                                                      \
+   U16 _tmp16;                                                         \
+   _tmp16 = (U16) GetHiWord(_val);                                     \
+   PJ_PK_U16(_msg, _tmp16, _ret)                                       \
+   if ((_ret) == ROK)                                                  \
+   {                                                                   \
+      _tmp16 = (U16) GetLoWord(_val);                                  \
+      PJ_PK_U16(_msg, _tmp16, _ret)                                    \
+   }                                                                   \
+}
+
+#define PJ_PACK_MACI(_mBuf, _macI)              \
+{                                               \
+   U16 _tmp;                                    \
+   Data _pkArray[4];                            \
+   _tmp = (U16) GetHiWord(_macI);               \
+   _pkArray[0] = (Data) GetHiByte(_tmp);        \
+   _pkArray[1] = (Data) GetLoByte(_tmp);        \
+   _tmp = (U16) GetLoWord(_macI);               \
+   _pkArray[2] = (Data) GetHiByte(_tmp);        \
+   _pkArray[3] = (Data) GetLoByte(_tmp);        \
+   SAddPstMsgMult(_pkArray, (MsgLen) 4, _mBuf); \
+}
+
+#define PJ_UNPK_MACI(_mBuf, _macI)                          \
+{                                                           \
+   U16 _tmp16 = 0;                                          \
+   Data _unPkArray[4] = {0};                                      \
+   SRemPstMsgMult(_unPkArray, (MsgLen)4, _mBuf);            \
+   _tmp16 = (U16) PutHiByte(_tmp16, (U8) _unPkArray[3]);    \
+   _tmp16 = (U16) PutLoByte(_tmp16, (U8) _unPkArray[2]);    \
+   _macI  = (U32) PutHiWord(_macI, (U16) _tmp16);           \
+   _tmp16 = (U16) PutHiByte(_tmp16, (U8) _unPkArray[1]);    \
+   _tmp16 = (U16) PutLoByte(_tmp16, (U8) _unPkArray[0]);    \
+   _macI  = (U32) PutLoWord(_macI, (U16) _tmp16);           \
+}
+
+/*@def PJ_SEC_FILL_COUNT
+*
+*  This macro fills the COUNT value. COUNT value is composed 
+*  of a HFN and the PDCP SN. Refer to 36.323 for details.
+* 
+*@param[in]_secInp      Count Value as Input 
+*@param[in]_pSecInfo    Variable into which count value needs to be populated
+*
+*/
+#define PJ_SEC_FILL_COUNT(_secInp, _pSecInfo)              \
+{                                               \
+   U16 _tmp;                                    \
+   _tmp = (U16) GetHiWord(_secInp);               \
+   _pSecInfo[0] = (Data) GetHiByte(_tmp);        \
+   _pSecInfo[1] = (Data) GetLoByte(_tmp);        \
+   _tmp = (U16) GetLoWord(_secInp);               \
+   _pSecInfo[2] = (Data) GetHiByte(_tmp);        \
+   _pSecInfo[3] = (Data) GetLoByte(_tmp);        \
+}
+
+/*@def PJ_SEC_FILL_FRESH
+*
+*  This macro fills the FRESH value. FRESH [0], . FRESH [3]
+*  is set as BEARER[0] . BEARER[4] | 0 pow(27). Refer to 33.401 for details.
+* 
+*@param[in]_fresh   Variable into which o/p needs to be set.
+*@param[in]_rbId    RbId of the RB to be filled in FRESH
+*
+*/
+#define PJ_SEC_FILL_FRESH(_fresh, _rbId)              \
+{                                               \
+   _fresh[0] = 0;        \
+   _fresh[1] = 0;        \
+   _fresh[2] = 0;        \
+   _fresh[3] = _rbId;        \
+}
+
+#define PJ_TIME_DIFF(cur,prev)                  \
+   (cur<prev ? ((0xffffffff - prev) + cur ): (cur - prev)) 
+#define PJ_MAX_CNT_RB_OVERLOAD 10
+#endif /* __PJH__ */
+\f  
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj.x b/src/5gnrpdcp/pj.x
new file mode 100755 (executable)
index 0000000..47d7b88
--- /dev/null
@@ -0,0 +1,604 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE PDCP file 
+    
+        Type:    C include file
+  
+        Desc:    This file contains all the data structures and 
+                 prototypes for LTE PDCP.
+        File:    pj.x
+
+*********************************************************************21*/
+/** @file pj.x
+@brief PDCP Product Structures, prototypes
+*/
+
+#ifndef __PJX__
+#define __PJX__
+
+\f
+/*
+ *     The structures and variables declared in this file
+ *     correspond to structures and variables used by
+ *     the following TRILLIUM software:
+ *
+ *     part no.             description
+ *     --------     ----------------------------------------------
+ *     1000371      LTE-RLC
+ *
+*/
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef U32   PjSn;                        /*!< Sequence Number length */
+
+/* pj005.201 added support for L2 Measurement */
+/** @defgroup l2meas L2Meas Module Info 
+*/
+/** @addtogroup l2meas */
+/*@{*/
+#ifdef LTE_L2_MEAS
+
+/** @struct PjL2Cntr
+ * PDCP L2 Counter  */
+typedef struct pjL2Cntr
+{
+   struct 
+   {
+       U32      numPkts; /*!< Number of packet monitired in dlDelay */        
+       EpcTime  val;     /*!< L2 Measurement value in dlDelay */
+   }dlDelay;
+   struct
+   {
+       U32      numPkts; /*!< Number of packet monitired in ulLoss */        
+       U32      val;     /*!< L2 Measurement value in ulLoss */
+   }ulLoss;
+   struct
+   {
+       U32      numPkts;  /*!< Number of packet monitired in ulLoss */        
+       U32      val;     /*!< L2 Measurement value in dlDisc */
+   }dlDisc;
+   U32    totDrbsPerQci;     /*!< Total Count of DRB's for this QCI */
+}PjL2Cntr;
+
+/** @struct PjL2MeasCb
+ * PDCP L2 Measurement CB */
+typedef struct pjL2MeasCb
+{
+   U16           measType;               /*!< Bit-wise set measurement types */ 
+   U16           numQci;                 /*!< number of valid qcI */            
+   U8            qci[LPJ_MAX_QCI];       /*!< list of valid qcI */     
+   PjL2Cntr      measData[LPJ_MAX_QCI];  /*!< Measurement CB */             
+   CmLteMemInfo       memInfo;
+   CmCpuStatsInfo  cpuInfo;
+}PjL2MeasCb;
+
+/** @struct PjL2MeasEvtCb
+ * PDCP L2 Measurement Evt CB */
+typedef struct pjL2MeasEvtCb
+{
+   U32           transId;  /*!< TransId of Measurement Req */
+   U32           cbIdx;    /*!< TransId of Measurement Req */
+   CmTimer       l2Tmr;    /*!< L2 Timer per request */
+   TmrCfg        l2TmrCfg; /*!< Time period of measurement */
+   PjL2MeasCb    measCb;   /*!< Measurement CB */ 
+}PjL2MeasEvtCb;
+
+/** @struct PjL2Cb
+ * PDCP L2  CB */
+typedef struct pjL2Cb
+{
+   U16           pjNumMeas;                       /*!< Number of measurements going on */
+   PjL2MeasEvtCb pjL2EvtCb[PJ_MAX_L2MEAS_EVT]; /*!< Pointers to Measurement Cb */
+   U8           measOn[LPJ_MAX_QCI];              /*!< Measurement on */
+   U16           memUtilizationMask;             /*!< Memory mask */
+   U16           cpuUtilizationMask;            /*!< CPU Mask */
+   CmTimer      measTmr; /* !< measurement timer */ 
+   TmrCfg       measTmrCfg; /*!< Time period of measurement */
+}PjL2Cb;
+
+/** @struct PjL2MeasRbCb
+ * PDCP L2 Measurement Rb CB */
+typedef struct pjL2MeasRbCb
+{
+   PjL2Cntr      *l2Sts[PJ_MAX_L2MEAS_INRB + 1];    /*!< Dl Delay counter */     
+}PjL2MeasRbCb;
+#endif /* LTE_L2_MEAS */
+/*@}*/
+
+typedef struct pjCfmEnt
+{
+   U8             rbId;                  /*!< RB ID */
+   U8             rbType;                /*!< RB Type */
+   U8             cfgType;               /*!< CfgType for the Cfm */
+   U8             res1;
+   Status         status;                /*!< ROK or RFAILED */
+   Reason         reason;                /*!< Reason for failure */
+}PjCfmEnt;
+
+/**
+ *  @brief
+ *  When the libraries are offboarded, the confirms are sent
+ *  asynchronously. This is to store them.
+ */
+typedef struct pjAsyncCfm
+{
+   U8             cfmType;                  /*!< PJ_SEC_ASYNC_CFM, PJ_CFG_ASYNC_CFM, 
+                                                 PJ_REEST_ASYNC_CFM, PJ_CFG_REEST_ASYNC_CFM
+                                                 PJ_CFG_UEDEL_ASYNC_CFM */
+   U8             startTmr;                 /*!< Whether to start the timer or not */
+   U8             entity;                   /*!< Entity */
+   U8             numEnt;                   /*!< Number of entities */
+   U32            libInitBitMask;           /*!< Bitmask to maintain the cfm for Init req */
+   U32            cmpInitBitMask;           /*!< Bitmask to track cfm for compression */
+   CmLteRnti      ueId;                     /*!< UE ID */
+   CmLteCellId    cellId;                   /*!< Cell ID */
+   U32            transId;                  /*!< Transcation ID */
+   PjCfmEnt       cfmEnt[CPJ_MAX_CFM];      /*!< Confirm parameter for
+                                                 PDCP entity. */
+}PjAsyncCfm;
+/**
+ *  @brief
+ *  Hook information maintainned during processing
+ */
+typedef struct pjLibInfo
+{
+   U8         state;                        /*!< State of the UE- Normal or ReEst. */
+   U8         res[1];                    
+   U16        numReEstCmp;                  /*!< Number of RBs reestablishment received */
+   U16        numReEstDrb;                /*!< Number of RBs under reestablishment*/
+   CmTimer    obdTmr;                       /*!< Timer to wait for InitCfm and UE Delete */
+   U32        tLibInitBitMask;              /*!< Bitmask to maintain the cfm for Init req */
+   U32        tCmpInitBitMask;              /*!< Bitmask to track cfm for compression */
+   PjAsyncCfm *asyncCfm[PJ_MAX_ASYNC_CFM];  /*!< Confirm list to handle multiple simultaneous
+                                                 config requests when cfm is sent asynchronously */
+   U16        nxtAvlbTxId;                  /*!< Next available transaction Id for entry 
+                                                 in the async Cfm list */
+   U16        crntTmrTxId;                  /*!< Transaction id for which the timer is started */
+   Bool       onlySrb1;
+   Bool       waitForReEstTrig;
+#ifdef PJ_SEC_ASYNC
+   Bool       reEstCfmSent;
+#endif
+}PjLibInfo;
+
+/** @struct PjSecInp
+Input parameters for security algorithm */
+typedef struct pjSecInp
+{
+   U32         count;                       /*!< COUNT associated with SDU/PDU */ 
+   CmLteRbId   rbId;                        /*!< RB Identifier */
+   U8          dir;                         /*!< Direction UL/DL/biderectional */
+   U8          res[2];                      /*!< reserved */
+}PjSecInp;
+
+/** @struct PjCmpCxt
+Context for ROHC */
+typedef struct pjCmpCxt
+{
+   CmLteCellId cellId;                      /*!< Cell Identifier */
+   CmLteRnti   ueId;                        /*!< UE Identifier */
+   CmLteRbId   rbId;                        /*!< RB Identifier */
+   U8          rbType;                      /*!< RB Type */
+   U16         cfgTxId;                     /*!< Tx Idx of config confirm */
+}PjCmpCxt;
+
+/** @struct PjSecCxt
+Context for Security Algorithm */
+typedef struct pjSecCxt
+{
+   CmLteCellId cellId;                      /*!< Cell Identifier */
+   CmLteRnti   ueId;                        /*!< UE Identifier */
+   U16         cfgTxId;                     /*!< Tx Idx of config confirm */
+   U16         res;                         /*!< reserved */
+   U8          dir;                         /*!< direction DL/UL */
+}PjSecCxt;
+
+/** @struct PjLibTrans
+Transaction Id for Security Algorithm */
+typedef struct pjLibTrans
+{
+   /* New parameters added from PjMsSecInfo to avoid multiple copy of parameters */
+   CmLteCellId cellId;                      /*!< cell ID */
+   CmLteRnti   ueId;                        /*!< UE ID */
+   U8          pdcpInstance;                /*!< PDCP instance UL/DL */
+   U8          hash_key[PJ_MS_KENB_LEN];    /*!< Current eNodeB key at App */
+   U8          strS[PJ_MS_STR_S_LEN];
+   U8          strSlen;
+   U8          intAlgoType;                 /*!< Integ algo type  */
+   U8          fresh[PJ_NUM_BYTES_FRESH];
+   U8          ciphAlgoType;                /*!< Ciph algo type */
+   U8          *key;                        /*!< Integrity key */
+   U32         count;                       /*!< COUNT associated with SDU/PDU */
+   CmLteRbId   rbId;                        /*!< PDCP RbCb */
+   U8          rbType;                      /*!< RB Type : 0 - PJ_SRB, 1 - PJ_DRB */
+   U16         res;                         /*!< Reserved */
+   PTR         ueCb;                        /*!< UE control block */
+#ifdef L3_OPTMZ   
+   U32         sduId;
+#endif   
+   U8          dir;                          /*!< Direction */
+   U8          snLen;                       /*!< SN Length */
+   #ifdef INTEL_QAT_DP
+   Void        *instHndl;
+   Void        *sessCxtId;
+   #endif
+}PjLibTrans;
+
+/** @struct PjIntInfo
+PDCP Integrity Algo Information */
+typedef struct pjIntInfo
+{
+   U32          algoType;                    /*!< Type of the algorithm */
+   U8          intKey[PJ_INTG_KEY_LEN];      /*!< Integrity key */
+}PjIntInfo;
+
+/** @struct PjCipherInfo
+PDCP Ciphering Algo Information */
+typedef struct pjCipherInfo
+{
+   U32          algoType;                    /*!< Type of the algorithm */
+   U8          cpKey[PJ_CIPHER_KEY_LEN];    /*!< Control plane ciphering key */
+   U8          upKey[PJ_CIPHER_KEY_LEN];    /*!< User plane ciphering key */
+}PjCipherInfo;
+
+/** @struct PjSec
+PDCP Security Info */
+typedef struct pjSec
+{
+   Bool          secAct;                    /*!< Flag to indicate if security is 
+                                                 activated for this UE */ 
+   Bool          selSecAct;                 /*!< Flag to indicate if selective 
+                                                 security activation is set */ 
+   Bool          firstMsg;                   /*!< Flag to indicate the first DL
+                                                 SRB msg received */
+   PjIntInfo     intInfo;                   /*!< Integrity Algo Information */
+   Bool          intProtEnbForDrb;          /*1< 5G NR Integrity protection is enbaled or not for DRB*/
+   PjIntInfo     intInfoForDrb;             /*!< 5G NR Integrity Algo Information for DRB */
+   PjCipherInfo  cipherInfo;                /*!< Ciphering Algo Information */
+   PjSecCxt      secCxt;                    /*!< Context for security algorithm */
+
+   Void          *intCxtId;                  /*!< Context Id for Integrity
+                                                 protection / verification */
+   Void          *cpCxtId;                   /*!< Context Id for cntrl plane 
+                                                 ciphering / deciphering */
+   Void          *upCxtId;                   /*!< Context Id for user plane
+                                                 ciphering / deciphering */
+#ifdef INTEL_QAT_DP
+#ifdef ALT1
+   Void          *cpSessCxtId;        /*!<  Session Context Id for Integrity protection / verification for first packet
+                                                                  And it will get replaced with chained integrity and ciphering session later */
+#else
+   Void          *cpIntSessCxtId;        /*!<  Session Context Id for Integrity protection / verification */
+   Void          *cpCiphSessCxtId;         /*!< Session Context Id for cntrl plane ciphering / deciphering */
+#endif
+   Void          *upCiphSessCxtId;         /*!< Session Context Id for user plane ciphering / deciphering */
+#endif
+}PjSec;
+
+/** @struct PjBuf
+PDCP Tx/Rx Buffer */
+typedef struct pjBuf
+{
+   U8          numBins;                     /*!< Number of lists for datQ */   
+   U8          res1[3];                     /*!< Reserved */
+   U32         numEntries;                  /*!< Total number of entries in the datQ */   
+   CmLListCp   *datQ;                       /*!< Array of lists for Tx SDUs/Rx PDUs */
+   CmLListCp   datCfmQ;
+   CmLListCp   sduSubmitQ;
+   CmLListCp   reEstPktQ;
+   CmLListCp   datPktQ;
+#ifdef L2_L3_SPLIT
+   U32         pduState[8];                 /*!< Added for debugging purpose */
+#endif
+}PjBuf;
+
+typedef struct pjUeKey
+{
+   CmLteRnti     ueId;                      /*!< UE Id */
+   CmLteCellId   cellId;                    /*!< Cell Id */
+}PjUeKey;
+
+/** @struct PjCpjSapCb
+ * CPJ Sap Control Block */
+typedef struct pjCpjSapCb
+{
+   Pst           pst;                       /*!< Service user post structure */
+   SpId          spId;                      /*!< Service provider Id */
+   SuId          suId;                      /*!< Service user Id */
+   U8            state;                     /*!< Sap Status */
+   U8            res[3];                    /*!< reserved  */
+}PjCpjSapCb;
+
+/** @struct PjPjuSapCb
+ * PJU Sap Control Block */
+typedef struct pjPjuSapCb
+{
+   SpId          spId;                      /*!< Service provider Id */
+   SuId          suId;                      /*!< Service user Id */
+   U8            state;                     /*!< Sap Status */
+   U8            res[3];                    /*!< Reserved */
+   PjPjuSts      sts;                       /*!< Statistics */
+   Pst           pst;                       /*!< Service user post structure */
+}PjPjuSapCb;
+
+typedef struct pjUdxDlSapCb
+{
+   SpId          spId;                      /*!< Service provider Id */
+   SuId          suId;                      /*!< Service user Id */
+   U8            state;                     /*!< Sap Status */
+   U8            res[3];                    /*!< Reserved */
+   PjPjuSts      sts;                       /*!< Statistics */
+   Pst           pst;                       /*!< Service user post structure */
+}PjUdxDlSapCb;
+
+
+typedef struct pjUdxUlSapCb
+{
+   Pst           pst;                       /*!< Service user post structure */
+   SpId          spId;                      /*!< Service provider Id */
+   SuId          suId;                      /*!< Service user Id */
+   U8            state;                     /*!< Sap Status */
+   U8            retryCnt;                  /*!< Bind Retry Count */
+   U16           bndTmrInt;                 /*!< Timer Interval */
+   CmTimer       bndTmr;                    /*!< Bind Timer */
+}PjUdxUlSapCb;
+
+
+typedef struct pjKwuSapCb
+{
+   Pst           pst;                       /*!< Service user post structure */
+   SpId          spId;                      /*!< Service provider Id */
+   SuId          suId;                      /*!< Service user Id */
+   U8            state;                     /*!< Sap Status */
+   U8            retryCnt;                  /*!< Bind Retry Count */
+   U16           bndTmrInt;                 /*!< Timer Interval */
+   CmTimer       bndTmr;                    /*!< Bind Timer */
+}PjKwuSapCb;
+
+/** @struct PjHdrCmp
+  Robust header compression Information */
+typedef struct pjRohc
+{
+        Bool        hdrCmpUsed;                  /*!< Header Compression Used/Not */
+        U8          res[3];                      /*!< reserved */
+        U16         maxCid;                      /*!< Max CID */
+        U16         profId;                      /*!< ROHC Profile Id */
+}PjRohc; 
+typedef struct pjCfgInfo
+{
+   CmHashListEnt     transHlEnt;
+   U32               transId;
+   U32               uprLyrTransId;
+   U8                cfgType;
+   CpjCfgReqInfo     *cfgInfo;
+   CpjUeInfo         *ueInfo;
+   CpjUeInfo         *newUeInfo;
+   CpjSecCfgReqInfo  *secCfgInfo;
+   CpjReEstReqInfo   *reEstReq;
+   CpjCountReqInfo   *cntReq;
+   CpjSduStaReqInfo  *staReq;
+   CpjDatResumeReqInfo *datResReq;
+} PjCfgInfo;
+
+/** @struct PjPerfStats
+PDCP performance stats */
+typedef struct _pjPerfSts
+{
+   U32           pjSduRcvCnt;               /*!< Number of SDUs received at PDCP */
+}PjPerfSts;
+
+
+/** @struct PjCb
+RLC global control block */
+typedef struct _pjUlCb
+{
+   U32           transId;                   /*!< next available TransId */
+   PjCpjSapCb    cpjSap;                    /*!< CPJ Sap Conrol Block */ 
+   PjUdxUlSapCb  udxUlSap[PJ_MAX_UDXSAPS];  /*!< UDX Sap Control Block */
+   PjPjuSapCb    pjuSap[PJ_MAX_PJUSAPS];    /*!< PJU Sap Conrol Block */ 
+   PjKwuSapCb    kwuSap[PJ_MAX_KWUSAPS];    /*!< kwu Sap Control Block */
+   CmHashListCp  transIdLstCp;              /*!< Hashlist of cfg trans */
+   CmHashListCp  ueLstCp;                   /*!< Hashlist of UeCb */
+#ifdef LTE_L2_MEAS
+   PjL2Cb        pjL2Cb;             /*!< Control block of L2 Measurements in PDCP */
+#endif /* LTE_L2_MEAS */
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+   Void          *instHndl;
+#endif
+#endif
+
+}PjUlgCb; 
+
+
+/** @struct PjCb
+RLC global control block */
+typedef struct _pjDlCb
+{
+   PjUdxDlSapCb  udxDlSap[PJ_MAX_UDXSAPS];  /*!< Udx Sap Control Block */
+   PjPjuSapCb    pjuSap[PJ_MAX_PJUSAPS];    /*!< PJU Sap Conrol Block */ 
+   PjKwuSapCb    kwuSap[PJ_MAX_KWUSAPS];    /*!< kwu Sap Control Block */
+   PjGenSts      pjGenSts;                  /*!< PDCP General Statistics */
+   CmHashListCp  ueLstCp;                   /*!< Hashlist of UeCb */
+#ifdef LTE_L2_MEAS
+   PjL2Cb        pjL2Cb;             /*!< Control block of L2 Measurements in PDCP */
+#endif /* LTE_L2_MEAS */
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+   Void          *instHndl;
+#endif
+#endif
+}PjDlgCb; 
+
+#ifdef INTEL_QAT_DP
+typedef U64 (*funcVirtToPhys)(void * virtAddr);
+#endif
+
+
+/** @struct PjCb
+RLC global control block */
+typedef struct _pjCb
+{
+   CmTqType      pjTq[PJ_TMR_LEN];  /*!< Timer queue */
+   CmTqCp        pjTqCp;            /*!< Timer queue control point */
+   S16           trcLen;            /*!< Trace Length */
+   U8            trcMask;           /*!< Trace Mask */
+   TskInit       init;              /*!< Task Initialization Info */
+   PjGenCfg      pjGenCfg;          /*!< PDCP General Configuration Structure */
+   PjGenSts      pjGenSts;          /*!< PDCP General Statistics */
+   PjPerfSts     pjPerfSts;         /*!< PDCP Performance Statistics */
+   union
+   {
+      PjUlgCb      *ulCb;            /*!< Ul Control Block */ 
+      PjDlgCb      *dlCb;            /*!< Dl Control Block */ 
+   } u; 
+#ifdef INTEL_QAT_DP
+   Void                        *instHndl;
+   funcVirtToPhys va2pa;
+#endif
+}PjCb;
+
+typedef struct _pdcpStats
+{
+    U32  numPdcpSdusDiscarded;
+    U32  numPdcpSdusDiscMem;
+    U32  numPdcpCellReorderTmrExp;
+}PDCPStats;
+
+EXTERN PDCPStats gPdcpStats;
+
+/* Extern variable declaration */
+EXTERN PjCb *pjCb[PJ_MAX_PDCP_INSTANCES];  /*!< PDCP global control block */ 
+
+/* TMR Module */
+EXTERN S16 pjStartTmr  ARGS ((
+PjCb     *gCb,
+PTR       cb,           
+S16       tmrEvnt   
+));
+
+EXTERN S16 pjStopTmr ARGS ((
+PjCb  *gCb,
+PTR    cb,              
+U8     tmrType         
+));
+
+EXTERN Bool pjChkTmr ARGS ((
+PjCb     *gCb,
+PTR       cb,         
+S16       tmrEvnt       
+));
+
+EXTERN S16 pjTmrExpiry ARGS ((
+PTR cb,
+S16 tmrEvnt
+)); 
+EXTERN S16 pjDbmBufInit ARGS ((
+PjCb     *gCb,
+PjBuf       *buf,          
+U8          numBins          
+));
+
+EXTERN S16 pjLmmSendTrc ARGS ((PjCb *gCb, Event event, Buffer *mBuf));
+#ifdef LTE_L2_MEAS
+EXTERN Void pjLmmSendAlarm ARGS ((PjCb *gCb, U16 category, U16 event, 
+U16 cause, SuId suId, U32 ueId, U8 qci));
+#else /* LTE_L2_MEAS */
+EXTERN Void pjLmmSendAlarm ARGS ((PjCb *gCb, U16 category, 
+                                 U16 event, U16 cause, 
+                                   SuId suId, U32 ueId));
+#endif /* LTE_L2_MEAS */
+EXTERN S16 pjUtlCmpClose ARGS((
+PjCb    *gCb,
+PTR      cmpCxtId                 /* ROHC Context to be closed */
+));
+
+
+/* Activation functions */
+EXTERN S16 pjDlActvInit ARGS ((
+Ent    ent,                 /* entity */
+Inst   inst,                /* instance */
+Region region,              /* region */
+Reason reason               /* reason */
+));
+
+EXTERN S16 pjDlActvTsk ARGS ((
+Pst *pst,              /* pst structure */
+Buffer *mBuf            /* message buffer */
+));
+
+/* Activation functions */
+EXTERN S16 pjUlActvInit ARGS ((
+Ent    ent,                 /* entity */
+Inst   inst,                /* instance */
+Region region,              /* region */
+Reason reason               /* reason */
+));
+
+EXTERN S16 pjUlActvTsk ARGS ((
+Pst *pst,              /* pst structure */
+Buffer *mBuf            /* message buffer */
+));
+
+#ifndef XEON_SPECIFIC_CHANGES
+EXTERN U32 pjMsCheckSpaccQueue ARGS ((Bool isUl));
+#else
+EXTERN U32 pjMsCheckSpaccQueue ARGS ((Void));
+#endif
+EXTERN Void pjProcessSpaccRdWr ARGS ((
+U32 ttitick
+));
+
+#ifdef INTEL_QAT_DP
+EXTERN Void pjPollQatDat ARGS ((
+PjCb  *tPjCb,
+U32 ttitick
+));
+#endif
+#ifdef LTE_L2_MEAS
+EXTERN Void UpdateMemInfo ARGS ((
+PjL2Cb *tPjL2Cb /* l2Cb structure */
+));
+EXTERN S16 UpdateCpuInfo ARGS ((
+PjL2Cb *tPjL2Cb /* l2Cb structure */
+));
+
+EXTERN S16 pjUtlMemCpuHdlTmrExp ARGS((
+PjCb          *tPjCb,/*pjCb structure */
+PjL2Cb *tPjL2Cb /*l2Cb structure */
+));
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __PJX__ */
+
+\f  
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_cfg_dl.c b/src/5gnrpdcp/pj_cfg_dl.c
new file mode 100755 (executable)
index 0000000..9243767
--- /dev/null
@@ -0,0 +1,1512 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+
+        Name:    LTE PDCP - Configuration Manager file
+
+        Type:    C source file
+
+        Desc:    It contains the following configuraiton primtives
+                    -- pjCfgAddRb 
+                    -- pjCfgReCfgRb 
+                    -- pjCfgDelRb 
+                    -- pjCfgReEstRb 
+                    -- pjCfgDelUe 
+                    -- pjCfgPrcSecCfg 
+                    -- pjCfgUeIdChng 
+                    -- pjCfgPrcCount 
+                    -- pjCfgPrcSduSta 
+
+*********************************************************************21*/
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=212;
+/** @file gp_pj_cfg.c
+@brief LTE PDCP Configuration Module
+**/
+
+\f
+/* header (.h) include files */
+#include "envopt.h"             /* environment options */
+#include "envdep.h"             /* environment dependent */
+#include "envind.h"             /* environment independent */
+
+#include "gen.h"                /* general */
+#include "ssi.h"                /* system services interface */
+#include "cm5.h"                /* Timer Functions */
+#include "cm_lte.h"             /* common LTE header file */
+#include "cm_hash.h"            /* common hash module  file */
+#include "cm_llist.h"           /* common list header file */
+#include "cpj.h"                /* RRC layer */
+#include "pju.h"                /* PDCP service user */
+#include "lpj.h"                /* RRC layer */
+#include "pj_env.h"             /* RLC environment options */
+#include "pj.h"                 /* RLC layer */
+#include "pj_dl.h"
+#include "pj_udx.h"
+#include "pj_err.h"
+
+
+
+/* header/extern include files (.x) */
+
+#include "gen.x"                /* general */
+#include "ssi.x"                /* system services interface */
+#include "cm_lib.x"             /* common library */
+#include "cm5.x"                /* Timer Functions */
+#include "cm_hash.x"            /* common hash module */
+#include "cm_lte.x"             /* common LTE file */
+#include "cm_llist.x"           /* common list header file */
+#include "cpj.x"                /* RRC layer */
+#include "pju.x"                /* PDCP service user */
+#include "lpj.x"                /* LM Interface */
+#include "pj.x"                 /* RLC layer */
+#include "pj_udx.x"
+#include "pj_dl.x"
+
+/* Proto types declarations for local functions */
+PRIVATE S16 pjCfgFillPjDlRbCb ARGS ((
+PjCb                *gCb,
+PjDlRbCb            *rbCb,
+PjDlUeCb          *ueCb,
+U8                 isHo,
+UdxCfgEnt       *cfgEnt,
+UdxCfmEnt       *cfmEnt
+));
+
+PRIVATE S16 pjCfgUpdDlCompInfo  ARGS ((
+PjCb                   *gCb, 
+PjDlRbCb               *rbCb,
+PjDlUeCb               *ueCb,
+UdxHdrCompCfg        *rohcCfg
+));
+
+#ifdef LTE_L2_MEAS
+PRIVATE S16 pjAddToDlL2Meas ARGS ((
+PjCb *gCb, 
+PjDlRbCb *kwRbCb,
+U8 cellId,
+U16 ueId
+));
+#endif
+/* Store the Profile ID into array index */
+/* RRC is not sending the profile id directly. It will give
+   the for all the profiles with True/False. PDCP will derive the profile
+   based on this profile Id list */
+
+PRIVATE U16  rohcProfId[CPJ_MAX_ROHC_PROF_LIST]=    { 0x0001, 0x0002, 0x0003, 0x0004,
+                                              0x0006, 0x0101, 0x0102, 0x0103, 
+                                              0x0104};
+/** @addtogroup cfgdata */
+/*@{*/
+/** 
+* @brief
+* 
+*   Hanlder to process the configuration recieved from the upper layer and update the pdcp
+*   data base.
+*
+* @b Description: 
+*     1. This function create a new  PDCP RB Cb. @n
+*     2. Newly created PDCP RB Cb will be placed in Data base with the  configuration
+*     informtion received.  @n
+*     3. Return Success or Failure to the caller with reason and status
+*     information. @n
+ * @param [in]    ueId     -  UE Identifier
+ * @param [in]    cellId   -  CELL Identifier
+ * @param [in]    entCfg   -  Entity Configuration to be done.
+ * @param [out]   entCfm   -  Entity Confirmation.
+ * 
+ * @return  ROK
+ */
+#ifdef ANSI
+PUBLIC S16 pjCfgAddDlRb
+(
+PjCb              *gCb,
+CmLteRnti         ueId,
+CmLteCellId       cellId,
+U8                 isHo,
+UdxCfgEnt         *entCfg,
+PjDlUeCb          **ueCb,
+UdxCfmEnt         *entCfm
+)
+#else
+PUBLIC S16 pjCfgAddDlRb (gCb, ueId, cellId,isHo, entCfg, ueCb, entCfm)
+PjCb              *gCb;
+CmLteRnti         ueId;
+CmLteCellId       cellId;
+U8                 isHo;
+CpjCfgEnt         *entCfg;
+PjDlUeCb          **ueCb; 
+CpjCfmEnt         *entCfm;
+#endif
+{
+   S16               ret;
+   PjDlRbCb          *rbCb;  /* Rb Cb Pointer */
+
+   TRC3(pjCfgAddDlRb);  
+
+   /* Initialization */
+   ret  = ROK;
+
+   RLOG2(L_DEBUG, "pjCfgAddRb- Received with -- cellId(%d),ueId(%d)",
+                   cellId, ueId);
+
+   if( NULLP == *ueCb)
+   { 
+      /* Ue Cb is not present, Create Ue Cb */   
+      if ( pjDbmCreateDlUeCb(gCb, ueId, cellId, ueCb) != ROK)
+      {
+         /* Ue Cb allocation failed  */   
+         PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+               CPJ_CFG_REAS_UE_CREAT_FAIL);
+
+         RLOG_ARG1(L_ERROR,DBG_UEID,ueId, "CellId[%d] Creating DL UeCb Failed",
+                            cellId);
+         RETVALUE(ret);
+      } 
+   }
+   (*ueCb)->inst = gCb->init.inst;
+
+   /* Rb Id is allowed range or not */   
+   PJ_VALIDATE_RBID(ueId, entCfg->rbId, entCfg->rbType, ret);
+   if ( ROK != ret)
+   { 
+      PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+         CPJ_CFG_REAS_INVALID_RBID);
+
+      RLOG_ARG2(L_ERROR,DBG_UEID,ueId, "CellId[%u]:RbId[%d] - "
+            "Invalid RB ID,RbCb Creation Failed ", cellId, entCfg->rbId);
+      RETVALUE(ret);
+   }
+
+   /* Find Rb Cb already exist or not */   
+   PJ_DBM_FETCH_DL_RBCB(entCfg->rbId, entCfg->rbType, (*ueCb), rbCb);
+   if (NULLP != rbCb)
+   {
+      RLOG_ARG2(L_WARNING, DBG_UEID,ueId, "CellId [%u]:RbId[%d] already exists",
+            cellId,entCfg->rbId);
+      /* Rb Cb already exist for pdpcp */   
+      PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+            CPJ_CFG_REAS_SAME_RBID);
+
+      RLOG_ARG2(L_ERROR,DBG_UEID,ueId, "RB Id already present-- cellId(%d), rbId(%d)",
+                      cellId, entCfg->rbId);
+      RETVALUE(RFAILED);
+   }
+   else if (NULLP == rbCb)
+   {
+      /* Create Rb Cb and place in Ue Cb */   
+      rbCb =   pjDbmCreateDlRbCb(gCb, entCfg->rbId, entCfg->rbType, *ueCb, PJ_CFG_PDCP); 
+      if(NULLP == rbCb)
+      {
+         /* Create Rb Cb Failed*/   
+         PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+               CPJ_CFG_REAS_ENT_CREAT_FAIL);
+
+         RLOG_ARG2(L_ERROR,DBG_UEID,ueId, "Failed to Create RB CB -- cellId(%d) rbId(%d)",
+                         cellId, entCfg->rbId);
+         RETVALUE(RFAILED);
+      } 
+   }
+
+   /* Copy the Recived information into RbCb */ 
+   ret = pjCfgFillPjDlRbCb(gCb, rbCb, *ueCb,isHo, entCfg , entCfm);
+
+   /* Fill the Cfm status and Reason */
+   PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
+         CPJ_CFG_REAS_NONE);
+
+   RETVALUE(ret);
+} /* pjCfgAddRb */
+
+/**
+* @brief 
+*
+*   Hanlder to update the PJRB with the received infromation during
+*   configuration or re configuration. 
+*
+* @b Description: 
+*     1. update the data base with the  new configuration informtion received.  @n
+*     2. update the data base with the  new re-configuration informtion received.  @n
+*     3. If required Initiliaze the tx/rx Buffers and Timers. @n
+*     4. Return Success or Failure to the caller with reason and status
+*     information. @n
+*
+ * @param [out]   rbCb     -  RB Control Block
+ * @param [out]   entCfm   -  PDCP Entiry Confirmation 
+ * @param [in]    ueCb     -  UE Control Block
+ * @param [in]    entCfg   -  PDCP Entity Configuration
+ *
+ * @return  ROK
+ */
+#ifdef ANSI
+PRIVATE S16 pjCfgFillPjDlRbCb
+(
+PjCb            *gCb,
+PjDlRbCb        *pjRbCb,
+PjDlUeCb        *ueCb,
+U8              isHo,
+UdxCfgEnt       *cfgEnt,
+UdxCfmEnt       *cfmEnt
+)
+#else
+PRIVATE S16 pjCfgFillPjDlRbCb(gCb, pjRbCb, ueCb,isHo, cfgEnt, cfmEnt)
+PjCb            *gCb;
+PjDlRbCb        *pjRbCb;
+PjDlUeCb        *ueCb;
+U8              isHo,
+CpjCfgEnt       *cfgEnt;
+CpjCfmEnt       *cfmEnt;
+#endif
+{
+   S16            tmrVal;    /* Timer Value */
+   /* kw005.201 added support for L2 measurement */
+   TRC3(pjCfgFillPjDlRbCb);
+
+   /* Initialization */
+   tmrVal  = 0; 
+
+   RLOG_ARG3(L_DEBUG,DBG_UEID,ueCb->key.ueId, "Received Fill Req cellId(%d), rbId(%d),cfgType(%d)",
+                           ueCb->key.cellId,
+                       cfgEnt->rbId, cfgEnt->cfgType);
+
+   switch (cfgEnt->cfgType)
+   {
+      /* Cfg Type received as ADD RB */
+      case CPJ_CFG_ADD:
+         {
+            pjRbCb->state  =   PJ_STATE_NORMAL;
+            pjRbCb->rbId   =   cfgEnt->rbId;
+            pjRbCb->rbType =   cfgEnt->rbType;
+            pjRbCb->mode   =   cfgEnt->m.addCfg.rlcInfo.mode;
+            pjRbCb->dir    =   cfgEnt->m.addCfg.rlcInfo.dir;
+            pjRbCb->ueCb   =   ueCb;
+
+            if(PJ_SRB == pjRbCb->rbType)
+            {
+               /* SN length is fixed for SRB */
+               pjRbCb->snLen  = PJ_SRB_SN_LEN;
+               ueCb->numSrbs++;
+            }
+            else
+            {
+               if (CM_LTE_MODE_UM == pjRbCb->mode)
+               {
+                  /* SN length can be 12 bit or 18 bit in UM mode */
+                  pjRbCb->snLen  =   cfgEnt->m.addCfg.rlcInfo.m.rlcUm.pdcpSNSize;
+#ifdef NR_PDCP_DRB_SN_18_BIT
+                  pjRbCb->snLen  =   PJ_18_BIT_SN;
+#else
+                  pjRbCb->snLen  =   PJ_12_BIT_SN;
+#endif
+               }
+               else
+               {
+                  /* SN length can be 12/18 bit for AM mode */
+                  pjRbCb->snLen  =   cfgEnt->m.addCfg.rlcInfo.m.rlcAm.pdcpSNSize;
+#ifdef NR_PDCP_DRB_SN_18_BIT
+                  pjRbCb->snLen  =   PJ_18_BIT_SN;
+#else
+                  pjRbCb->snLen  =   PJ_12_BIT_SN;
+#endif
+                  if (isHo)
+                  {
+                     pjRbCb->state  =   PJ_STATE_HO;
+                  }
+               }
+               ueCb->numDrbs++;
+            }
+            pjRbCb->maxTxSn = (1 << pjRbCb->snLen);
+            /* Initialize all off board  timers */
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+            cmInitTimers(&pjRbCb->dlCb.obdTmr,PJ_RB_MAX_TIMERS); 
+#endif                  
+
+            RLOG_ARG2(L_DEBUG,DBG_UEID,ueCb->key.ueId, 
+                  "Received RB Req with -- Dir(%d), mode(%d)",
+                       pjRbCb->dir, pjRbCb->mode);
+
+           
+            if (PJ_DIR_DL &  pjRbCb->dir)
+            {
+               pjRbCb->dlCb.discTmrInt = cfgEnt->m.addCfg.discardTmr;
+               pjRbCb->dlCb.cfmReqd    = cfgEnt->m.addCfg.cfmReqd;
+               /* pjRbCb->dlCb.count      = 0xffffffff; */
+
+               /* Discard Timer is Enabled */
+               if(pjRbCb->dlCb.discTmrInt > 0 )
+               {
+                  cmInitTimers(&pjRbCb->dlCb.discTmr,PJ_RB_MAX_TIMERS); 
+                  /* 1. The discTmr value is absolute value in ms units 
+                     2. Store the DiscardTmr value in terms of Layer resolution
+                     ie discTmrVal = dicTrmVal/(SS_TICKS*Layer Resolution) 
+                     and round to next integer value.
+                   */
+                  tmrVal = (S16)(pjRbCb->dlCb.discTmrInt % (SS_TICKS_SEC
+                        * gCb->pjGenCfg.timeRes));  /*KW_FIX*/
+                  pjRbCb->dlCb.discTmrInt = (S16)(pjRbCb->dlCb.discTmrInt / 
+                                            (SS_TICKS_SEC * gCb->pjGenCfg.timeRes));
+                  if(tmrVal)
+                     pjRbCb->dlCb.discTmrInt +=1; /* Round to next integer value if
+                                                     required */          
+               }
+
+               /*Initialization for Tx Buf */
+               gCb->pjGenCfg.nmbDlBins = PJ_MAX_HASH_BINS;
+               pjDbmDlBufInit(gCb, &pjRbCb->dlCb.txBuf,gCb->pjGenCfg.nmbDlBins);
+               cmLListInit(&pjRbCb->dlCb.dlPktQ);
+            }
+
+            /* Update the Compressor Informatio in Rb Cb */
+            if(cfgEnt->rbType == CM_LTE_DRB)
+            {
+               pjCfgUpdDlCompInfo(gCb, pjRbCb, ueCb,&(cfgEnt->m.addCfg.hdrCompCfg));
+/* kw005.201 added support for L2 measurement */
+#ifdef LTE_L2_MEAS
+               pjRbCb->qci =  cfgEnt->m.addCfg.qci;
+               pjAddToDlL2Meas(gCb,pjRbCb,
+                               ueCb->key.cellId,ueCb->key.ueId); 
+#endif
+            }
+
+            break;
+         }
+
+         /* Cfg Type received as Modify RB */
+      case CPJ_CFG_MODIFY:
+         {
+            if(CPJ_RECFG_CFMREQ & cfgEnt->m.modCfg.bitFlag)
+               pjRbCb->dlCb.cfmReqd    = cfgEnt->m.modCfg.cfmReqd;
+
+            /* Header Compression profile has been modified */
+
+            if(TRUE == cfgEnt->m.modCfg.hdrCompCfg.hdrCompUsed)
+            {
+               /* Close All the channels */
+               pjUtlDlCmpReset(gCb, pjRbCb); 
+               pjCfgUpdDlCompInfo(gCb, pjRbCb, ueCb, &cfgEnt->m.modCfg.hdrCompCfg);
+            }
+
+            /* In case of Hand off scenario: At Target eNode-B, 
+               Handoff information will send in re-cfg req */
+
+            if(TRUE  & cfgEnt->m.modCfg.hoInfo.isHoPres)
+            {
+               /* Store the HO information  and call for Status Report
+                * Generation also */
+               if(CPJ_HO_DL & cfgEnt->m.modCfg.hoInfo.isHoPres)
+               {
+                  pjRbCb->dlCb.count = cfgEnt->m.modCfg.hoInfo.dlCount - 1;
+                  if (pjRbCb->snLen != cfgEnt->m.modCfg.hoInfo.snLen)
+                  {
+                     pjRbCb->snLen = cfgEnt->m.modCfg.hoInfo.snLen;
+                  }
+               }
+               pjDlmProcessDlPktQ(gCb, pjRbCb);
+               pjRbCb->state = PJ_STATE_NORMAL;
+            }
+
+            break;
+         }
+
+         /* Un Expected cfg type */
+      default:
+         {
+            RLOG_ARG1(L_ERROR,DBG_CELLID, ueCb->key.cellId, 
+                  "pjCfgFillRbCb Failed -- for the invalid cfgType(%d)",
+                     cfgEnt->cfgType);
+         }
+   }
+   RETVALUE(ROK);
+} /* pjCfgFillPjRbCb */
+
+
+\f
+/**
+* @brief 
+*
+*   Hanlder to process the re-configuration for existing PJRB from the upper
+*   layer.
+*
+* @b Description: 
+*     1. This function fetch the PJRB from pdcp data base. @n
+*     2. update the data base with the  new configuration informtion received.  @n
+*     3. Return Success or Failure to the caller with reason and status
+*     information. @n
+*
+* @param [in]    gCb      -  PDCP Instance Control block
+* @param [in]    ueId     -  UE Identifier
+* @param [in]    cellId   -  CELL Identifier
+* @param [in]    entCfg   -  Entity Configuration to be done.
+* @param [out]   entCfm   -  Entity Confirmation.
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgReCfgDlRb
+(
+PjCb              *gCb,
+PjDlUeCb          *ueCb,
+UdxCfgEnt         *entCfg,
+UdxCfmEnt         *entCfm
+)
+#else
+PUBLIC S16 pjCfgReCfgDlRb (gCb,ueCb, entCfg, entCfm)
+PjCb              *gCb;
+PjDlUeCb          *ueCb;
+UdxCfgEnt         *entCfg;
+UdxCfmEnt         *entCfm;
+#endif
+{
+   S16       ret;
+   PjDlRbCb     *rbCb;    /* Rb Cb */
+
+   TRC3(pjCfgReCfgDlRb);
+
+   /* Initialization */
+   ret  = ROK;
+
+   RLOG2(L_DEBUG, "pjCfgReCfgRb - Received for -- cellId(%d),ueId(%d)",
+                          ueCb->key.cellId, ueCb->key.ueId);
+
+   /* Fetch Rb Cb */
+   PJ_DBM_FETCH_DL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
+   /* Rb Cb is not present or Rb Cb is not configured for PDCP */
+   if( NULLP == rbCb)
+   { 
+      RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId [%u]:RbId[%d] already exists",
+            ueCb->key.cellId,entCfg->rbId);
+      /* Fill entCfm structure */
+      PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+            CPJ_CFG_REAS_PDCPID_UNKWN);
+
+      RLOG_ARG2(L_ERROR,DBG_UEID,ueCb->key.ueId, 
+            "RB Cb is not present -- cellId(%d), rbId(%d)",
+                          ueCb->key.cellId, entCfg->rbId);
+      RETVALUE(RFAILED);
+   }
+
+   /* Copy the received infromation in to Rb Cb */
+   ret = pjCfgFillPjDlRbCb(gCb, rbCb, ueCb,FALSE, entCfg , entCfm);
+
+   /* Fill the Cfm status and Reason */
+   PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
+         CPJ_CFG_REAS_NONE);
+
+
+   RETVALUE(ret);
+} /* pjCfgReCfgRb */
+
+\f
+/**
+* @brief
+*  This function deletes the existing RB(PDCP and RLC) from  Ue Cb.
+*
+* @b Description:
+*    1. Stop the timers and deallocate tx/rx Buffs for PJRB CB. @n
+*    2. Delete the existing RB Cb(PDCP and RLC)  from Ue Cb. @n
+*
+* @param [in]    ueId     -  UE Identifier
+* @param [in]    cellId   -  CELL Identifier
+* @param [in]    entCfg   -  Entity Configuration to be done.
+* @param [out]   entCfm   -  Entity Confirmation.
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgDelDlRb
+(
+PjCb              *gCb,
+PjDlUeCb          *ueCb,
+UdxCfgEnt         *entCfg,
+UdxCfmEnt         *entCfm
+)
+#else
+PUBLIC S16 pjCfgDelDlRb (gCb, ueCb, entCfg, entCfm)
+PjCb              *gCb;
+PjDlUeCb          *ueCb;
+UdxCfgEnt         *entCfg;
+UdxCfmEnt         *entCfm;
+#endif
+{
+   S16      ret;
+   PjDlRbCb     *rbCb;    /* Rb Cb */
+
+   TRC3(pjCfgDelDlRb);
+
+   /* Initialization */
+   ret = ROK;
+
+   RLOG2(L_DEBUG, "pjCfgDelRb- Received for -- cellId(%d),ueId(%d)",
+                          ueCb->key.cellId,ueCb->key.ueId);
+
+   /* Fetch RB Cb */
+   PJ_DBM_FETCH_DL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
+
+   /* RB Cb is not present   or not configured for PDCP */
+   if (NULLP == rbCb) 
+   { 
+      RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId [%u]:RbId[%d] already exists",
+            ueCb->key.cellId,entCfg->rbId);
+      /* Fill entCfm structure with invalid pdcp Id */
+      PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+            CPJ_CFG_REAS_INVALID_PDCPID);
+
+      RLOG_ARG2(L_ERROR,DBG_UEID,ueCb->key.ueId, 
+            "RB Cb is not found, Deletion Failed -- cellId(%d), rbId(%d)",
+                          ueCb->key.cellId, entCfg->rbId);
+      RETVALUE(RFAILED);
+   }
+   /* Delete PDCP Related infromation from RB CB */
+   ret= pjCfgDelPjDlRbCb(gCb, ueCb, rbCb); 
+
+   if(ROK != ret)
+   {
+      /* Fill entCfm structure with invalid pdcp Id */
+      PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+            CPJ_CFG_REAS_INVALID_PDCPID);
+
+      RLOG_ARG2(L_ERROR,DBG_UEID,ueCb->key.ueId, 
+            "RB Cb Deletion Failed -- cellId(%d), rbId(%d)",
+                          ueCb->key.cellId, entCfg->rbId);
+      RETVALUE(ret);
+   }
+   rbCb->pktAdmitCnt= 0;
+   /* Fill the Cfm status and Reason */
+   PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
+         CPJ_CFG_REAS_NONE);
+
+
+   RETVALUE(ret);
+} /* pjCfgDelRb */
+
+
+
+\f
+/**
+*  @brief
+*
+*   This primitive is used to re-establish downlink SRB2 and/or DRB'S during RRC connection
+*   re-configuration procedure.
+*  
+*  @b Description:
+*  1. This function will trigger re-establishment for SRB2 and/or DRB's
+*
+* @param [in]    gCb      -  PDCP Instance Control block
+* @param [in]    ueId     -  UE Identifier
+* @param [in]    cellId   -  CELL Identifier
+* @param [in]    entCfg   -  Entity Configuration to be done.
+* @param [out]   entCfm   -  Entity Configuration cfm.
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgReEstDlRb
+(
+PjCb              *gCb,
+PjDlUeCb          *ueCb,
+UdxCfgEnt         *entCfg,
+UdxCfmEnt         *entCfm
+)
+#else
+PUBLIC S16 pjCfgReEstDlRb (gCb,ueCb, entCfg, entCfm)
+PjCb              *gCb;
+PjDlUeCb          *ueCb;
+UdxCfgEnt         *entCfg;
+UdxCfmEnt         *entCfm;
+#endif
+{
+   S16    ret;
+   PjDlRbCb   *rbCb;   /* Rb Cb */
+
+   TRC3(pjCfgReEstDlRb); 
+
+   /* Initialization */
+   ret  = ROK;
+
+   RLOG2(L_DEBUG, "pjCfgReEstRb- Received for -- cellId(%d),ueId(%d)",
+                         ueCb->key.cellId, ueCb->key.ueId);
+
+   /* Fetch Rb Cb */
+   PJ_DBM_FETCH_DL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
+   /* Rb Cb is not present or Rb Cb is not configured for PDCP */
+   if( NULLP == rbCb )
+   { 
+      RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId [%u]:RbId[%d] already exists",
+            ueCb->key.cellId,entCfg->rbId);
+      /* Fill entCfm structure with invalid PDCP Id*/
+      PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+            CPJ_CFG_REAS_PDCPID_UNKWN);
+
+      RLOG_ARG1(L_ERROR,DBG_UEID,ueCb->key.ueId, 
+            "Re-Est Failed : DL RB CB is not present -- cellId(%d)",
+                          ueCb->key.cellId);
+
+      RETVALUE(RFAILED);
+   }
+
+   /* A Cfm with failure is sent if the re-establishment comes when RBs are not in
+      re-est state */
+   if (ueCb->libInfo.state != PJ_STATE_REEST )
+   {
+      /* Fill entCfm structure with invalid PDCP Id*/
+      PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+            CPJ_CFG_REAS_INVALID_STATE);
+
+      RLOG_ARG1(L_ERROR,DBG_UEID,ueCb->key.ueId, 
+            "Re-Est Failed : RB State is Not REEST -- cellId(%d)",
+                          ueCb->key.cellId);
+      RETVALUE(RFAILED);
+   }
+
+   /* 5. Call the respective reestablishment functions for SRB */
+   if(rbCb->rbType == PJ_SRB)
+   {
+      pjDlmReEstSrb(gCb,rbCb);
+   }
+   else /* PJ_DRBs */
+   {
+      /* During Re-Establishment DL RAB state is assumed to be in PJ_STATE_NORMAL
+       * and the Status Report is sent only if this is the state.
+       * But if the Reestablishment happens during HO(PJ_STATE_REEST_HO) 
+       * due to the state change during HO no Status Report is sent after successful
+       * Re-establishment
+       */
+      rbCb->state = PJ_STATE_NORMAL;
+      rbCb->pktAdmitCnt = 0;
+      if (rbCb->mode == PJ_DRB_UM)
+      {
+          pjDlmReEstDrbUm(gCb,rbCb);
+      }
+      else
+      {
+        pjDlmReEstDrbAm(gCb,rbCb);
+      }
+   }/* if(rbType == .... */
+
+   RETVALUE(ret);
+} /* pjCfgReEstRb */
+
+
+\f
+/**
+* @brief
+* This primitive Delete Ue Cb from PDCP/RLC data base.
+*
+* @b Description:
+*  1. This primitive Delete the Ue Cb from PDCP/RLC Data base.
+*
+* @param [in]    ueId     -  UE Identifier
+* @param [in]    cellId   -  CELL Identifier
+* @param [in]    entCfg   -  Entity Configuration to be done.
+* @param [out]   entCfm   -  Entity Confirmation.
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgDelDlUe
+(
+PjCb              *gCb,
+PjDlUeCb          *ueCb,
+UdxCfgEnt         *entCfg,
+UdxCfmEnt         *entCfm
+)
+#else
+PUBLIC S16 pjCfgDelDlUe (gCb, ueCb, entCfg, entCfm)
+PjCb              *gCb;
+PjDlUeCb          *ueCb;
+UdxCfgEnt         *entCfg;
+UdxCfmEnt         *entCfm;
+#endif
+{
+   TRC3(pjCfgDelDlUe);
+
+   RLOG_ARG1(L_DEBUG,DBG_UEID,ueCb->key.ueId, 
+         "pjCfgDelUe- Received for -- cellId(%d)",
+                          ueCb->key.cellId);
+
+   /* Delete Ue Cb */
+   pjDbmDelDlUeCb(gCb, ueCb, FALSE);
+
+   /* Fill the Cfm */
+   PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
+         CPJ_CFG_REAS_NONE);
+
+   RETVALUE(ROK);
+} /* pjCfgDelUe */
+
+\f
+/**
+* @brief
+* This primitive configure the security information of an Ue Cb.
+*
+* @b Description:
+*  1. This primitive  configure the security information of an Ue Cb.
+*  2. Initilize  the  Integrity/Ciphering Channels if required.
+*
+* @param [in]    secCfg   -  Entity Configuration to be done.
+* @param [out]   secCfm   -  Entity Configuration Cfm done.
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgPrcSecDlCfg
+(
+PjCb             *gCb,
+UdxSecCfgReqInfo *secCfg,
+UdxSecCfgCfmInfo *cfgCfm
+)
+#else
+PUBLIC S16 pjCfgPrcSecDlCfg (gCb, secCfg, cfgCfm)
+PjCb              *gCb;
+UdxSecCfgReqInfo  *secCfg;
+UdxSecCfgCfmInfo  *cfgCfm;
+#endif
+{
+   S16     ret;
+   PjDlUeCb *ueCb;
+
+   TRC3(pjCfgPrcSecDlCfg);
+
+   /* Initialization */
+   ret  = ROK;
+   ueCb = NULLP;
+
+   RLOG2(L_DEBUG, "pjCfgPrcSecCfg- Received for -- cellId(%d),ueId(%d)",
+                          secCfg->cellId, secCfg->ueId);
+
+   /* Fetch Ue Cb */
+   ret = pjDbmFetchDlUeCb(gCb, secCfg->ueId, secCfg->cellId, &ueCb);
+
+   /* Ue Cb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   { 
+      RLOG_ARG1(L_ERROR, DBG_CELLID, secCfg->cellId,"UeId[%u] not found",
+            secCfg->ueId);
+      /* Fill entCfm structure */
+      PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
+            CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN);
+      RETVALUE(ret);
+   }
+
+   ueCb->secInfo.selSecAct= secCfg->secCfg.selSecAct;
+
+   /* Store Integrity Information */
+   ueCb->secInfo.intInfo.algoType=secCfg->secCfg.integInfo.algoType;
+   cmMemcpy(&ueCb->secInfo.intInfo.intKey[0], &secCfg->secCfg.integInfo.intKey[0], CPJ_INTG_KEY_LEN);
+
+   /* Store Ciphering Informaiton */
+   ueCb->secInfo.cipherInfo.algoType=secCfg->secCfg.cipherInfo.algoType; 
+
+   cmMemcpy(ueCb->secInfo.cipherInfo.cpKey,
+         &secCfg->secCfg.cipherInfo.ctrlplnKey[0],CPJ_CIPHER_KEY_LEN);
+
+   cmMemcpy(ueCb->secInfo.cipherInfo.upKey,
+         &secCfg->secCfg.cipherInfo.usrplnKey[0],CPJ_CIPHER_KEY_LEN);
+
+   /* Security Activation Done */
+   ueCb->secInfo.secAct = TRUE;
+
+   if(TRUE == secCfg->secCfg.isHo)
+   {
+      ueCb->secInfo.firstMsg   =  FALSE;
+   }
+   else
+   {
+      ueCb->secInfo.firstMsg   =  TRUE;
+   }
+
+   ueCb->secInfo.secCxt.cellId = secCfg->cellId;
+   ueCb->secInfo.secCxt.ueId   = secCfg->ueId;
+   ueCb->secInfo.secCxt.dir    = PJ_SEC_DIR_DL;
+
+#ifndef ALIGN_64BIT
+   RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId, 
+         "Security Paramters stored in UE CB are -- cellId(%d)"  
+         "Integrity Algo(%ld), cipherAlgoType(%ld) ",
+         secCfg->cellId, ueCb->secInfo.intInfo.algoType,
+         ueCb->secInfo.cipherInfo.algoType);
+#else
+   RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId, 
+         "Security Paramters stored in UE CB are -- cellId(%d)"  
+         "Integrity Algo(%d), cipherAlgoType(%d) ",
+         secCfg->cellId, ueCb->secInfo.intInfo.algoType,
+         ueCb->secInfo.cipherInfo.algoType);
+#endif
+   /* Open the Security Channels */
+
+   if(ueCb->secInfo.secAct)
+   {
+
+#ifdef PJ_SEC_ASYNC
+      ueCb->secInfo.secCxt.cfgTxId = ueCb->libInfo.nxtAvlbTxId;
+#endif 
+
+      ret = pjUtlDlIntInit(gCb, ueCb);
+
+      /* Integrity Init failed */
+      if(ROK != ret)
+      {
+         PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
+               CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_INTINIT_FAILED);
+
+         RETVALUE(ret);
+
+      }
+      ret = pjUtlDlCpInit(gCb, ueCb);
+      /* Ciphering Control Plane Init failed */
+      if(ROK != ret)
+      {
+         PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
+               CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_CCIPHR_FAILED);
+
+         RETVALUE(ret);
+
+      }
+      ret = pjUtlDlUpInit(gCb, ueCb);
+
+      /* Ciphering User Plane Init failed */
+      if(ROK != ret)
+      {
+         PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
+               CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UCIPHR_FAILED);
+
+         RETVALUE(ret);
+      }
+   }
+
+   /* Fill Cfg Cfm with Status OK */
+   PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
+         CPJ_CFG_CFM_OK,CPJ_CFG_REAS_NONE);
+
+   RETVALUE(ROK);
+} /* pjCfgPrcSecCfg */
+
+\f
+/**
+* @brief
+* This primitive changes the ueId of existing Ue Cb.
+* 
+* @b Description:
+*
+*    1. This function delete the UeCb from hashList. @n
+*    2. Update the Ue Cb with the new Keys. @n
+*    3. Insert the UeCb in hash list with new Key.  @n
+*
+* @param [in]    ueInfo      -  Old UE Information
+* @param [in]    newUeInfo   -  New UE Information
+* @param [out]   status      -  Status
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgDlUeIdChng
+(
+PjCb      *gCb,
+UdxUeInfo *ueInfo,
+UdxUeInfo *newUeInfo,
+CmStatus  *status
+)
+#else
+PUBLIC S16 pjCfgDlUeIdChng (gCb, ueInfo, newUeInfo, status)
+PjCb      *gCb;
+UdxUeInfo *ueInfo;
+UdxUeInfo *newUeInfo;
+CmStatus  *status;
+#endif
+{
+   PjDlUeCb *ueCb;
+   S16    ret;
+
+   TRC3(pjCfgDlUeIdChng)
+
+   ueCb = NULLP;
+   ret= ROK;
+
+   RLOG2(L_DEBUG, "pjCfgUeIdChng- Recived for -- cellId(%d),ueId(%d)",
+                          ueInfo->cellId, ueInfo->ueId);
+
+   if ( (ueInfo->ueId == newUeInfo->ueId) && 
+        (ueInfo->cellId == newUeInfo->cellId))
+   {
+      status->reason = CPJ_CFG_REAS_SAME_UEID;
+      status->status = CPJ_CFG_CFM_NOK; 
+      RLOG_ARG2(L_ERROR,DBG_CELLID,ueInfo->cellId,"Old UeId[%d] same as new UeId[%d]",
+            ueInfo->ueId,newUeInfo->ueId);
+      RETVALUE(RFAILED);
+   } 
+   
+   ret = pjDbmFetchDlUeCb(gCb, newUeInfo->ueId, newUeInfo->cellId, &ueCb);
+   if (ret == ROK)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, newUeInfo->cellId, "NewUeId[%d]:ueCb already exists",
+            newUeInfo->ueId);
+      status->reason = CPJ_CFG_REAS_SAME_UEID;
+      status->status = CPJ_CFG_CFM_NOK;
+      RETVALUE(RFAILED);
+   }
+  
+   ret = pjDbmFetchDlUeCb(gCb, ueInfo->ueId, ueInfo->cellId, &ueCb);
+   if (ret != ROK)
+   {
+      RLOG_ARG1(L_ERROR,DBG_CELLID,ueInfo->cellId,"UeId [%d]: UeCb not found",
+            ueInfo->ueId);
+      status->reason = CPJ_CFG_REAS_UE_UNKWN;
+      status->status = CPJ_CFG_CFM_NOK;
+      RETVALUE(RFAILED);
+   }
+  
+   ret = cmHashListDelete(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb);
+   if (ret != ROK)
+   {
+      RLOG_ARG1(L_ERROR,DBG_CELLID,ueInfo->cellId,"UeId[%u] HashList Deletion Failed",
+            ueInfo->ueId);
+      status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL;
+      status->status = CPJ_CFG_CFM_NOK;
+      RETVALUE(RFAILED);
+   }
+   
+   /* update the hash key with new values */ 
+   ueCb->key.ueId = newUeInfo->ueId;
+   ueCb->key.cellId = newUeInfo->cellId;
+
+   ret = cmHashListInsert(&(gCb->u.dlCb->ueLstCp), (PTR)ueCb, 
+                            (U8 *)&(ueCb->key), (U16) sizeof(PjUeKey));
+
+   if (ret != ROK)
+   {
+      RLOG_ARG1(L_ERROR,DBG_CELLID,newUeInfo->cellId,"UeId[%u] HashList Insertion Failed",
+            newUeInfo->ueId);
+      status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL;
+      status->status = CPJ_CFG_CFM_NOK;
+   }  
+  
+   RETVALUE(ret);
+} /* pjCfgUeIdChng */
+
+\f
+/**
+* @brief
+* This primitive reports the Count informatin of all RBs of an Ue Cb.
+*
+* @b Description:
+* 1. This function reports the count information of all the RBs of an UE. 
+*
+* @param [in]    ueId     -  UE Identifier
+* @param [in]    cellId   -  CELL Identifier
+* @param [out]   countCfm -  Count Information
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgPrcDlCount
+(
+PjCb            *gCb,
+UdxCountReqInfo *countReq,
+UdxCountCfmInfo       *countCfm
+)
+#else
+PUBLIC S16 pjCfgPrcDlCount (gCb, countReq, countCfm)
+PjCb            *gCb;
+UdxCountReqInfo *countReq;
+UdxCountCfmInfo       *countCfm;
+#endif
+{
+   S16     ret;
+   PjDlUeCb  *ueCb;
+   PjDlRbCb    *rbCb;
+   U8      numRb;
+   U8      idx;
+
+   TRC3(pjCfgPrcDlCount); 
+
+   /* Initialization */
+   ueCb   = NULLP;
+   rbCb   = NULLP;
+   ret    = ROK;
+   numRb  = 0;
+   idx  = 0;
+
+   RLOG2(L_DEBUG, "pjCfgPrcCount - Count Request Received for - cellId(%d),ueId(%d)",
+                          countReq->cellId, countReq->ueId);
+
+   /* Fetch  ue Cb */
+   ret = pjDbmFetchDlUeCb(gCb, countReq->ueId, countReq->cellId, &ueCb);
+   countCfm->ueId = countReq->ueId;
+   countCfm->cellId = countReq->cellId;
+   countCfm->transId = countReq->transId;
+
+   /* Ue Cb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   { 
+      RLOG_ARG1(L_ERROR, DBG_CELLID, countCfm->cellId,"UeId[%u] not found",countCfm->ueId);
+      /* Fill entCfm structure */
+      countCfm->numRb  = numRb;
+      countCfm->status = CPJ_CFG_CFM_NOK;
+      countCfm->reason = CPJ_CFG_REAS_UE_UNKWN;
+      RETVALUE(ret);
+   }
+
+   /* Loop through all DRBs  */
+   for(numRb=0, idx=0; idx < PJ_MAX_DRB_PER_UE && numRb < UDX_MAX_DRB; idx++)  /* KW_FIX */
+   {
+      rbCb = ueCb->drbCb[idx];
+      /* RB is present and configured for PDCP Layer */
+      if(NULLP != rbCb)
+      {
+         countCfm->countInfo[numRb].rbId= rbCb->rbId; 
+         countCfm->countInfo[numRb].dir = rbCb->dir; 
+         countCfm->countInfo[numRb].dlCount= rbCb->dlCb.count; 
+         countCfm->countInfo[numRb].ulCount= 0; 
+         numRb++;
+      }
+   }
+
+   /* Fill CountCfm with status and reason */
+   countCfm->numRb  = numRb;
+   if(numRb)
+   {
+      countCfm->status =CPJ_CFG_CFM_OK;
+      countCfm->reason =CPJ_CFG_REAS_NONE;
+   }
+   else
+   {
+      countCfm->status =CPJ_CFG_CFM_NOK;
+      countCfm->reason =CPJ_CFG_REAS_NO_DRBS;
+
+   }
+
+   RETVALUE(ret);
+} /* pjCfgPrcCount */
+
+/**
+* @brief
+* This primitive reports SDU status information of all RBs of an Ue Cb.
+*
+* @b Description:
+*  1. This primitive Trigger the Handoff Request procedure 
+*
+* @param [in]    ueId      -  UE Identifier
+* @param [in]    cellId    -  CELL Identifier
+* @param [out]   sduStaCfm -  SDU Status Information
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgPrcDlSduSta
+(
+PjCb                 *gCb,
+UdxSduStaReqInfo     *staReq
+)
+#else
+PUBLIC S16 pjCfgPrcDlSduSta (gCb, staReq)
+PjCb                 *gCb;
+UdxSduStaReqInfo     *staReq;
+#endif
+{
+   S16      ret;
+   PjDlUeCb  *ueCb;
+   U8 rbCnt;
+   U8 numRb = 0;
+   UdxSduStaInfo  *staInfo;
+   PjDlHoCfmInfo *hoCfmInfo;
+   UdxSduStaCfmInfo *cfmInfo;
+   PjUdxDlSapCb      *udxSap; 
+
+   TRC3(pjCfgPrcDlSduSta);
+
+   /* Initialization */
+   ret  = ROK;
+   ueCb = NULLP;
+
+   RLOG2(L_DEBUG, "pjCfgPrcSduSta - Received for -- cellId(%d),ueId(%d)",
+                          staReq->cellId, staReq->ueId);
+
+   /* Memory leak fix ccpu00135359 */
+   udxSap = &(gCb->u.dlCb->udxDlSap[0]);
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfmInfo, 
+      sizeof (UdxSduStaCfmInfo), ret);
+   if(ret != ROK)
+   {  
+#if (ERRCLASS & ERRCLS_DEBUG)    /*KW_FIX*/
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      /*ccpu00136858 */      
+      PJ_PST_FREE(gCb->u.dlCb->udxDlSap[0].pst.region,
+                  gCb->u.dlCb->udxDlSap[0].pst.pool, 
+                   staReq, sizeof(UdxSduStaReqInfo));
+#endif
+         RETVALUE(RFAILED);
+   }
+   cfmInfo->ueId = staReq->ueId;
+   cfmInfo->cellId = staReq->cellId;
+   cfmInfo->transId = staReq->transId;
+   cfmInfo->status = CPJ_CFG_CFM_OK; 
+
+   /* Fetch Ue Cb */
+   ret = pjDbmFetchDlUeCb(gCb, staReq->ueId, staReq->cellId, &ueCb);
+
+   /* UeCb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   { 
+      RLOG_ARG1(L_ERROR, DBG_CELLID, staReq->cellId,"UeId[%u] not found",staReq->ueId);
+      cfmInfo->status = CPJ_CFG_CFM_NOK; 
+      cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN;
+      cfmInfo->numRb = numRb;
+
+      /* Caller should return cfm with failure */
+      RLOG_ARG1(L_ERROR,DBG_UEID,staReq->ueId,
+                  "UE Cb is not found -- cellId(%d)",
+                          staReq->cellId);
+
+      /* Send Failure SduStaCfm */
+      PjDlUdxSduStaCfm(&gCb->u.dlCb->udxDlSap[0].pst, 
+                        gCb->u.dlCb->udxDlSap[0].suId, cfmInfo);
+
+      RETVALUE(RFAILED);
+   }
+
+   /* Call Ho Start handler for this UE */
+   pjUtlDlReEstHO(gCb, ueCb);
+
+   for(rbCnt=0, numRb=0; rbCnt < PJ_MAX_DRB_PER_UE && numRb < CPJ_MAX_DRB; rbCnt++)
+   {
+      hoCfmInfo   =  &ueCb->hoInfo->hoCfmInfo[rbCnt];
+      staInfo     =  &cfmInfo->sduStaInfo[numRb];
+      if(hoCfmInfo->pres != TRUE)
+      {
+         continue;
+      }
+      
+      staInfo->rbId  = hoCfmInfo->rbId;
+      staInfo->dir   =  hoCfmInfo->dir;
+      staInfo->dlSduStaInfo.count     =  hoCfmInfo->count;
+      staInfo->dlSduStaInfo.hoPres    =  TRUE;
+      numRb++;
+   } 
+   cfmInfo->numRb = numRb;
+   cfmInfo->status = ROK;
+   cfmInfo->reason = CPJ_CFG_REAS_NONE; 
+   PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo,
+              (PJ_MAX_DRB_PER_UE * sizeof(PjDlHoCfmInfo)));
+   PJ_FREE(gCb,ueCb->hoInfo, sizeof(PjDlHoInfo));             
+
+   PjDlUdxSduStaCfm(&gCb->u.dlCb->udxDlSap[0].pst, 
+                     gCb->u.dlCb->udxDlSap[0].suId, cfmInfo);
+   RETVALUE(ROK);
+} /* pjCfgPrcSduSta */
+
+   
+\f
+/**
+ * @brief
+ * This primitive to update the ROHC Comp details in PJRB  Cb.
+ *
+ * @b Description:
+ *  1. This primitive to update  the ROHC comp detils in PJRB Cb.
+ *
+ * @param [in]    pjRbCb    -  RB Control Block  
+ * @param [in]    ueCb      -  Ue Control Block 
+ * @param [in]    hdrCompCfg-  Comp Cfg Information 
+ * 
+ * @return  ROK
+ *
+ */
+#ifdef ANSI
+PRIVATE S16 pjCfgUpdDlCompInfo 
+(
+PjCb                   *gCb,
+PjDlRbCb               *rbCb,
+PjDlUeCb               *ueCb,
+UdxHdrCompCfg        *rohcCfg
+)
+#else
+PRIVATE S16 pjCfgUpdDlCompInfo(gCb, rbCb, ueCb, rohcCfg)
+PjCb                   *gCb;
+PjDlRbCb               *rbCb;
+PjDlUeCb               *ueCb;
+UdxHdrCompCfg        *rohcCfg;
+#endif
+{
+   U16   profId;
+   U8    idx;
+   S16   ret;
+
+   TRC3(pjCfgUpdDlCompInfo);
+
+   /* Initialization */   
+   ret    = ROK;
+   profId = 0;
+   idx  = 0; 
+
+   RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Received for -- cellId(%d),RbId(%d)",
+                          rbCb->rbId, ueCb->key.ueId);
+
+   /* Header Compresion information present */
+   if(rohcCfg->hdrCompUsed)
+   {
+      /* Header Compression is enabled */ 
+      rbCb->rohc.hdrCmpUsed = TRUE;
+
+      /* User Can Configure multipel profiles. Maximum profile ID should be used */  
+      for(; idx<CPJ_MAX_ROHC_PROF_LIST; idx++)
+      {
+         if((rohcCfg->rohcInfo.profLst[idx] )&&
+               (profId < rohcProfId[idx]))
+            profId = rohcProfId[idx];
+      } 
+   }
+   else
+   {
+      /* Header Compression is disabled */
+      rbCb->rohc.hdrCmpUsed = FALSE;
+      profId = 0x0000;
+   }
+
+   /* Store the profile Id and MaxCid */
+
+   rbCb->rohc.profId = profId;
+   rbCb->rohc.maxCid = rohcCfg->rohcInfo.maxCid;
+
+   /* Store the ue Details in Compressor Context */
+   rbCb->cmpCxt.ueId   = ueCb->key.ueId;
+   rbCb->cmpCxt.cellId = ueCb->key.cellId;
+   rbCb->cmpCxt.rbId   = rbCb->rbId;
+   rbCb->cmpCxt.rbType = rbCb->rbType;
+
+   RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Selected   -- profId(%d),maxCid(%d)",
+                          rbCb->rohc.profId, rbCb->rohc.maxCid);
+
+
+   /* Compress Init */
+   if(rbCb->rohc.hdrCmpUsed)
+   {
+      ret=pjUtlDlCmpInit(gCb, rbCb); 
+   }
+
+   RETVALUE(ret);
+} /* pjCfgUpdCompInfo */
+
+\f
+/**
+ * @brief
+ * This primitive to delete RB from Ue Cb.
+ *
+ * @b Description:
+ * 1. To delete the PJRB Cb from  UeCb.
+ *
+ * @param [in]    ueCb      -  Ue Control Block 
+ * @param [in]    rbCb      -  Rb Control Block  
+ * 
+ * @return  ROK
+ *
+ */
+#ifdef ANSI
+PUBLIC S16  pjCfgDelPjDlRbCb 
+(
+PjCb                 *gCb,
+PjDlUeCb             *ueCb,
+PjDlRbCb             *rbCb
+)
+#else
+PUBLIC S16 pjCfgDelPjDlRbCb(gCb,ueCb,rbCb)
+PjCb                  *gCb;
+PjDlUeCb              *ueCb;
+PjDlRbCb              *rbCb;
+#endif
+{   
+   S16  ret;
+/* kw005.201 added support for L2 measurement */
+#ifdef LTE_L2_MEAS
+#endif
+   TRC3(pjCfgDelPjDlRbCb);
+
+   /* Initialization */
+   ret = ROK;
+
+   /* RbCb is present and Configured for PDCP */
+   if(NULLP != rbCb) 
+   {
+      RLOG_ARG1(L_DEBUG, DBG_UEID,ueCb->key.ueId, 
+            "Delete RB Req Received for -- rbId (%d)",rbCb->rbId);
+
+#ifdef LTE_L2_MEAS
+      PJ_UPD_L2_DECR_PER_QCI_RB_COUNT(gCb, rbCb); 
+#endif
+      rbCb->ueCb   = NULLP;
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+      /* Stop off board timers */
+      if(PJ_DIR_DL & rbCb->dir)
+         pjStopTmr(gCb, (PTR)rbCb, PJ_EVT_DL_OBD_TMR);  
+#endif
+      /* Deinit Tx Buffers */
+      pjDbmTxDeInit(gCb, &rbCb->dlCb.txBuf);
+      pjUtlEmptyDlPktList(gCb, rbCb);
+
+      if (rbCb->dlCb.staRep != NULL)
+      {
+        PJ_FREE_BUF(rbCb->dlCb.staRep);
+      }
+
+      if (PJ_SRB == rbCb->rbType)
+      {
+         ueCb->numSrbs--;
+      }
+      else if(PJ_DRB == rbCb->rbType) 
+      {
+         ueCb->numDrbs--;
+         if (rbCb->rohc.hdrCmpUsed)
+         {
+            pjUtlCmpClose(gCb,rbCb->cmpCxtId);
+         }
+      }
+
+      /* Free the rbCb */
+      pjDbmDelDlRbCb(gCb,rbCb->rbId, rbCb->rbType, &rbCb, PJ_CFG_PDCP,ueCb);
+   } 
+   RETVALUE(ret);
+} /* pjCfgDelPjRBCb */
+
+\f
+/**
+ * @brief
+ * Handler to process the downlink re-establishment Request for SRB1 during
+ * RRC Re-Establishment request.
+ *
+ * @b Description:
+ * 1. This primitive is used to re-establish SRB1 only during RRC Re-establishment 
+ * 2. New Security Algo will applied 
+ *
+ * @param [in]    gCb        -  PDCP Instance Control block.
+ * @param [in]    reEstReq   -  Entity Configuration to be done.
+ * @param [out]   reEstCfm   -  Entity Configuration cfm.
+ * 
+ * @return  ROK
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjCfgDlReEstReq
+(
+PjCb            *gCb,
+UdxReEstReqInfo *reEstReq,
+UdxReEstCfmInfo *reEstCfm
+)
+#else
+PUBLIC S16 pjCfgDlReEstReq (gCb, reEstReq, reEstCfm)
+PjCb            *gCb;
+UdxReEstReqInfo *reEstReq;
+UdxReEstCfmInfo *reEstCfm;
+#endif
+{
+   S16     ret;
+   PjDlRbCb    *rbCb;
+   CmLteRlcId  rlcId;
+
+   TRC3(pjCfgDlReEstReq);
+   /* Initialization */
+   rlcId.cellId  =  reEstReq->pdcpId.cellId;
+   rlcId.ueId  =  reEstReq->pdcpId.ueId;
+   rlcId.rbId  =  reEstReq->pdcpId.rbId;
+   rlcId.rbType  =  reEstReq->pdcpId.rbType;
+
+   RLOG2(L_DEBUG, "ReEst Req Received for -- cellId(%d),ueId(%d)",
+                 reEstReq->pdcpId.cellId, reEstReq->pdcpId.ueId);
+
+   ret = pjDbmFetchDlRbCb(gCb,rlcId,&rbCb);
+   
+   /* Ue Cb is not present */
+   if( ROK != ret || NULLP == rbCb)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:RbId[%d] not found",
+            rlcId.cellId, rlcId.rbId);
+      /* Fill entCfm structure */
+      PJ_CFG_FILL_REESTREQ_CFM(reEstCfm, reEstReq->pdcpId.ueId,reEstReq->pdcpId.cellId,
+            reEstReq->transId, CPJ_CFG_CFM_NOK);
+      RETVALUE(ret);
+   }
+
+   /* Copy Security Information */ 
+   cmMemcpy(&rbCb->ueCb->secInfo.intInfo.intKey[0], &reEstReq->intKey[0], PJ_INTG_KEY_LEN);
+   cmMemcpy(&rbCb->ueCb->secInfo.cipherInfo.cpKey[0], &reEstReq->ctrlplnKey[0], PJ_CIPHER_KEY_LEN);
+   cmMemcpy(&rbCb->ueCb->secInfo.cipherInfo.upKey[0], &reEstReq->usrplnKey[0], PJ_CIPHER_KEY_LEN);
+
+   /* Mark Security Action Done */
+   rbCb->ueCb->secInfo.secAct = TRUE;
+   
+   /* update the status as success. Chances of failure after this is minimal*/
+   PJ_CFG_FILL_REESTREQ_CFM(reEstCfm, reEstReq->pdcpId.ueId,reEstReq->pdcpId.cellId,
+            reEstReq->transId, CPJ_CFG_CFM_OK);
+
+#ifdef PJ_SEC_ASYNC
+   /* In case of Async need to save the cfm information */
+   pjUtlDlSaveCfmInfo(gCb, rbCb->ueCb, PJ_REEST_ASYNC_CFM, TRUE, ENTPJ, 
+                                          (PTR)reEstCfm, NULLP);
+   PJ_FREE(gCb,reEstCfm, sizeof(CpjReEstCfmInfo));
+#endif
+
+   /* Call ReEst for SRB1 */
+   pjUtlDlReEstSrb1(gCb, rbCb);
+
+   RETVALUE(ROK);
+} /* pjCfgReEstReq */
+
+#ifdef LTE_L2_MEAS
+
+PRIVATE S16 pjAddToDlL2Meas(PjCb *gCb, PjDlRbCb *pjRbCb,U8 cellId,U16 ueId)
+{
+   PjL2MeasEvtCb *measEvtCb = NULLP;
+   PjL2MeasCb    *measCb    = NULLP;
+   U16           cntr;
+
+
+   for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++)
+   {
+      measEvtCb = &gCb->u.dlCb->pjL2Cb.pjL2EvtCb[cntr];
+      measCb = &(measEvtCb->measCb);
+
+      if (measCb->measType & LPJ_L2MEAS_DL_DISC)
+      {
+         pjUtlPlcMeasDatInDlL2Sts(&measCb->measData[pjRbCb->qci],
+               &pjRbCb->rbL2Cb, measCb->measType);
+         measCb->qci[pjRbCb->qci] = pjRbCb->qci;
+
+         measCb->measData[pjRbCb->qci].totDrbsPerQci++;
+      }
+   }
+   RETVALUE(ROK);
+}/*pjAddToDlL2Meas*/ 
+#endif /*LTE_L2_MEAS*/
+
+/*@}*/
+\f
+/********************************************************************30**
+
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_cfg_ul.c b/src/5gnrpdcp/pj_cfg_ul.c
new file mode 100755 (executable)
index 0000000..1224cbf
--- /dev/null
@@ -0,0 +1,1585 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+
+        Name:    LTE PDCP - Configuration Manager file
+
+        Type:    C source file
+
+        Desc:    It contains the following configuraiton primtives
+                    -- pjCfgAddRb 
+                    -- pjCfgReCfgRb 
+                    -- pjCfgDelRb 
+                    -- pjCfgReEstRb 
+                    -- pjCfgDelUe 
+                    -- pjCfgPrcSecCfg 
+                    -- pjCfgUeIdChng 
+                    -- pjCfgPrcCount 
+                    -- pjCfgPrcSduSta 
+
+        File:     pj_cfg_ul.c
+
+*********************************************************************21*/
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=213;
+
+/** @file gp_pj_cfg.c
+@brief LTE PDCP Configuration Module
+**/
+
+\f
+/* header (.h) include files */
+#include "envopt.h"             /* environment options */
+#include "envdep.h"             /* environment dependent */
+#include "envind.h"             /* environment independent */
+
+#include "gen.h"                /* general */
+#include "ssi.h"                /* system services interface */
+#include "cm5.h"                /* Timer Functions */
+#include "cm_lte.h"             /* common LTE header file */
+#include "cm_hash.h"            /* common hash module  file */
+#include "cm_llist.h"           /* common list header file */
+#include "cpj.h"                /* RRC layer */
+#include "pju.h"                /* PDCP service user */
+#include "lpj.h"                /* RRC layer */
+#include "pj_env.h"             /* RLC environment options */
+#include "pj.h"                 /* RLC layer */
+#include  "pj_ul.h"
+#include "pj_err.h"
+
+
+
+/* header/extern include files (.x) */
+
+#include "gen.x"                /* general */
+#include "ssi.x"                /* system services interface */
+#include "cm_lib.x"             /* common library */
+#include "cm5.x"                /* Timer Functions */
+#include "cm_hash.x"            /* common hash module */
+#include "cm_lte.x"             /* common LTE file */
+#include "cm_llist.x"           /* common list header file */
+#include "cpj.x"                /* RRC layer */
+#include "pju.x"                /* PDCP service user */
+#include "lpj.x"                /* LM Interface */
+#include "pj.x"                 /* RLC layer */
+#include "pj_udx.h"
+#include "pj_udx.x"
+#include "pj_ul.x"
+
+/* Proto types declarations for local functions */
+PRIVATE S16 pjCfgFillPjUlRbCb ARGS ((
+PjCb            *gCb,
+PjUlRbCb        *rbCb,
+PjUlUeCb        *ueCb,
+U8              isHo,
+CpjCfgEnt       *cfgEnt,
+CpjCfmEnt       *cfmEnt
+));
+
+PRIVATE S16 pjCfgUpdUlCompInfo  ARGS ((
+PjCb                   *gCb,
+PjUlRbCb               *rbCb,
+PjUlUeCb               *ueCb,
+CpjHdrCompCfg        *rohcCfg
+));
+
+#ifdef LTE_L2_MEAS
+PRIVATE S16 pjAddToUlL2Meas ARGS ((
+PjCb *gCb, 
+PjUlRbCb *kwRbCb,
+U8 cellId,
+U16 ueId
+));
+#endif
+
+/* Store the Profile ID into array index */
+/* RRC is not sending the profile id directly. It will give
+   the for all the profiles with True/False. PDCP will derive the profile
+   based on this profile Id list */
+
+PRIVATE U16  rohcProfId[CPJ_MAX_ROHC_PROF_LIST]=    { 0x0001, 0x0002, 0x0003, 0x0004,
+                                              0x0006, 0x0101, 0x0102, 0x0103, 
+                                              0x0104};
+/** @addtogroup cfgdata */
+/*@{*/
+/** 
+* @brief
+* 
+*   Hanlder to process the configuration recieved from the upper layer and update the pdcp
+*   data base.
+*
+* @b Description: 
+*     1. This function create a new  PDCP RB Cb. @n
+*     2. Newly created PDCP RB Cb will be placed in Data base with the  configuration
+*     informtion received.  @n
+*     3. Return Success or Failure to the caller with reason and status
+*     information. @n
+ * @param [in]    ueId     -  UE Identifier
+ * @param [in]    cellId   -  CELL Identifier
+ * @param [in]    entCfg   -  Entity Configuration to be done.
+ * @param [out]   entCfm   -  Entity Confirmation.
+ * 
+ * @return  ROK
+ */
+#ifdef ANSI
+PUBLIC S16 pjCfgAddUlRb
+(
+PjCb              *gCb,
+CmLteRnti         ueId,
+CmLteCellId       cellId,
+U8                isHo,
+CpjCfgEnt         *entCfg,
+PjUlUeCb          **ueCb,
+CpjCfmEnt         *entCfm
+)
+#else
+PUBLIC S16 pjCfgAddUlRb (gCb, ueId, cellId,isHo, entCfg, entCfm)
+PjCb              *gCb;
+CmLteRnti         ueId;
+CmLteCellId       cellId;
+U8                isHo;
+CpjCfgEnt         *entCfg;
+PjUlUeCb          **ueCb;
+CpjCfmEnt         *entCfm;
+#endif
+{
+   S16              ret;
+   PjUlRbCb         *rbCb;  /* Rb Cb Pointer */
+
+   TRC3(pjCfgAddUlRb);  
+
+   /* Initialization */
+   ret  = ROK;
+   rbCb = NULLP;
+
+   RLOG2(L_DEBUG, "pjCfgAddRb- Received with -- cellId(%d),ueId(%d)",
+                     cellId, ueId);
+
+   if( NULLP == *ueCb)
+   { 
+      /* Ue Cb is not present, Create Ue Cb */   
+      if ( pjDbmCreateUlUeCb(gCb, ueId, cellId, ueCb) != ROK)
+      {
+         /* Ue Cb allocation failed  */   
+         PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+               CPJ_CFG_REAS_UE_CREAT_FAIL);
+
+         RLOG_ARG1(L_ERROR,DBG_UEID,ueId, "Creating UE Cb Failed -- cellId(%d)",
+                     cellId);
+         RETVALUE(ret);
+      } 
+   }
+
+   (*ueCb)->inst = gCb->init.inst;
+   /* Rb Id is allowed range or not */   
+   PJ_VALIDATE_RBID(ueId, entCfg->rbId, entCfg->rbType, ret);
+   if ( ROK != ret)
+   { 
+      PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+         CPJ_CFG_REAS_INVALID_RBID);
+
+      RLOG_ARG2(L_ERROR,DBG_UEID,ueId, "Invalid RB ID-- cellId(%d),RB Id(%d)",
+                     cellId, entCfg->rbId);
+      RETVALUE(ret);
+   }
+
+
+   /* Find Rb Cb already exist or not */   
+   PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, (*ueCb), rbCb);
+
+   if (NULLP != rbCb)
+   {
+      RLOG_ARG2(L_WARNING, DBG_UEID,ueId, "CellId [%u]:RbId[%d] already exists",
+            cellId,entCfg->rbId);
+      /* Rb Cb already exist for pdpcp */   
+      PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+            CPJ_CFG_REAS_SAME_RBID);
+      RETVALUE(RFAILED);
+   }
+   else if (NULLP == rbCb)
+   {
+      /* Create Rb Cb and place in Ue Cb */   
+      rbCb =   pjDbmCreateUlRbCb(gCb, entCfg->rbId, entCfg->rbType, *ueCb, PJ_CFG_PDCP); 
+      if(NULLP == rbCb)
+      {
+         RLOG_ARG2(L_ERROR, DBG_UEID, ueId,"CellId [%u]:Creation of rbCb with id [%d] failed", 
+               cellId, entCfg->rbId);
+         /* Create Rb Cb Failed*/   
+         PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+               CPJ_CFG_REAS_ENT_CREAT_FAIL);
+         RETVALUE(RFAILED);
+      } 
+   }
+
+   /* Copy the Recived information into RbCb */ 
+   ret = pjCfgFillPjUlRbCb(gCb, rbCb, *ueCb,isHo, entCfg , entCfm);
+
+   /* Fill the Cfm status and Reason */
+   PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
+         CPJ_CFG_REAS_NONE);
+
+   RETVALUE(ret);
+} /* pjCfgAddRb */
+
+/**
+* @brief 
+*
+*   Hanlder to update the PJRB with the received infromation during
+*   configuration or re configuration. 
+*
+* @b Description: 
+*     1. update the data base with the  new configuration informtion received.  @n
+*     2. update the data base with the  new re-configuration informtion received.  @n
+*     3. If required Initiliaze the tx/rx Buffers and Timers. @n
+*     4. Return Success or Failure to the caller with reason and status
+*     information. @n
+*
+ * @param [out]   rbCb     -  RB Control Block
+ * @param [out]   entCfm   -  PDCP Entiry Confirmation 
+ * @param [in]    ueCb     -  UE Control Block
+ * @param [in]    entCfg   -  PDCP Entity Configuration
+ *
+ * @return  ROK
+ */
+#ifdef ANSI
+PRIVATE S16 pjCfgFillPjUlRbCb
+(
+PjCb            *gCb,
+PjUlRbCb        *pjRbCb,
+PjUlUeCb        *ueCb,
+U8               isHo,
+CpjCfgEnt       *cfgEnt,
+CpjCfmEnt       *cfmEnt
+)
+#else
+PRIVATE S16 pjCfgFillPjUlRbCb(gCb, pjRbCb, ueCb, isHo, cfgEnt, cfmEnt)
+PjCb            *gCb;
+PjUlRbCb        *pjRbCb;
+PjUlUeCb        *ueCb;
+U8               isHo;
+CpjCfgEnt       *cfgEnt;
+CpjCfmEnt       *cfmEnt;
+#endif
+{
+   S16            ret;
+   U8             *bitMap;  /* Bitmap status report buffer      */
+   U16            bMapLen; /* Bit Map length */
+   /* kw005.201 added support for L2 measurement */
+   
+   TRC3(pjCfgFillPjUlRbCb);
+
+   /* Initialization */
+   ret     = ROK;
+   bMapLen = 0;
+
+   RLOG_ARG3(L_DEBUG,DBG_UEID,ueCb->key.ueId,"Received Fill RB Req For "
+                 "cellId(%d), rbId(%d), cfgType(%d)",
+                 ueCb->key.cellId, cfgEnt->rbId, cfgEnt->cfgType);
+
+   switch (cfgEnt->cfgType)
+   {
+      /* Cfg Type received as ADD RB */
+      case CPJ_CFG_ADD:
+         {
+            pjRbCb->state  =   PJ_STATE_NORMAL;
+            pjRbCb->rbId   =   cfgEnt->rbId;
+            pjRbCb->rbType =   cfgEnt->rbType;
+            pjRbCb->mode   =   cfgEnt->m.addCfg.rlcInfo.mode;
+            pjRbCb->dir    =   cfgEnt->m.addCfg.rlcInfo.dir;
+            pjRbCb->ueCb   =   ueCb;
+
+            if(PJ_SRB == pjRbCb->rbType)
+            {
+               /* SN length is fixed for SRB */
+               pjRbCb->snLen  = PJ_SRB_SN_LEN;
+               ueCb->numSrbs++;
+            }
+            else
+            {
+               if (CM_LTE_MODE_UM == pjRbCb->mode)
+               {   /* SN length can be 7 bit or 12 bit in UM mode */
+                  pjRbCb->snLen  =   cfgEnt->m.addCfg.rlcInfo.m.rlcUm.pdcpSNSize;
+#ifdef NR_PDCP_DRB_SN_18_BIT
+                  pjRbCb->snLen  =   PJ_18_BIT_SN;
+#else
+                  pjRbCb->snLen  =   PJ_12_BIT_SN;
+#endif
+               }
+               else
+               {
+                  /* SN length can be 12/15 bit for AM mode */
+                  pjRbCb->snLen  =   cfgEnt->m.addCfg.rlcInfo.m.rlcAm.pdcpSNSize;
+#ifdef NR_PDCP_DRB_SN_18_BIT
+                  pjRbCb->snLen  =   PJ_18_BIT_SN;
+#else
+                  pjRbCb->snLen  =   PJ_12_BIT_SN;
+#endif
+                  if (isHo)
+                  {
+                     pjRbCb->state = PJ_STATE_HO;
+                  }
+               }
+               ueCb->numDrbs++;
+            }
+            /* Initialize all off board  timers */
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+            cmInitTimers(&pjRbCb->ulCb.obdTmr,PJ_RB_MAX_TIMERS); 
+#endif                  
+
+            RLOG_ARG2(L_DEBUG,DBG_UEID,ueCb->key.ueId, 
+                  "RB Add Req Received with - Dir(%d),mode(%d)",
+                         pjRbCb->dir, pjRbCb->mode);
+
+            pjRbCb->ulCb.discReqd   = cfgEnt->m.addCfg.discReqd;
+            pjRbCb->ulCb.staRepReqd = cfgEnt->m.addCfg.rlcInfo.m.rlcAm.statusRepReqd;
+
+            /*Initialization for Rx Buf */
+            gCb->pjGenCfg.nmbUlBins = PJ_MAX_HASH_BINS;
+            pjDbmBufInit(gCb, &pjRbCb->ulCb.recBuf,gCb->pjGenCfg.nmbUlBins);
+            cmLListInit(&pjRbCb->ulCb.ulPktLst);
+            //pjRbCb->ulCb.lastSubCnt = 0xffffffff;
+            
+
+            /* Update the Compressor Informatio in Rb Cb */
+            if(cfgEnt->rbType == CM_LTE_DRB)
+            {
+               ret=pjCfgUpdUlCompInfo(gCb, pjRbCb, ueCb,&cfgEnt->m.addCfg.hdrCompCfg);
+/* kw005.201 added support for L2 measurement */
+#ifdef LTE_L2_MEAS
+               pjRbCb->qci =  cfgEnt->m.addCfg.qci;
+               pjAddToUlL2Meas(gCb,pjRbCb,
+                               ueCb->key.cellId,ueCb->key.ueId); 
+#endif
+            }
+            /* TODO: once APP and RRC changes are done, we can enable the below line */
+            //pjRbCb->reOrdrTmrVal = cfgEnt->m.addCfg.reOrdrTmrVal;
+            pjRbCb->reOrdrTmrVal = 8000; 
+            cmInitTimers(&(pjRbCb->ulCb.tReordTmr), 1); 
+            break;
+         }
+
+         /* Cfg Type received as Modify RB */
+      case CPJ_CFG_MODIFY:
+         {
+            /* Store the received Information */
+            if(CPJ_RECFG_DISRQD & cfgEnt->m.modCfg.bitFlag)
+               pjRbCb->ulCb.discReqd   = cfgEnt->m.modCfg.discReqd;
+            
+            if(CPJ_RECFG_REORDTMR & cfgEnt->m.modCfg.bitFlag)
+            {
+            
+               /* TODO: once APP and RRC changes are done, we can enable the below line */
+               //pjRbCb->reOrdrTmrVal = cfgEnt->m.modCfg.reOrdrTmrVal;
+               pjRbCb->reOrdrTmrVal = 8000;
+               Bool tmrRunning = pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR);
+               if(tmrRunning)
+               {
+                  /*  update RX_REORD to RX_NEXT; */
+                  pjRbCb->ulCb.rxReord = pjRbCb->ulCb.rxNext;
+
+                  /*  stop and restart t-Reordering. */
+                  pjStopTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR);
+                  pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR);
+               }
+            }
+            
+            /* Header Compression profile has been modified */
+            if(TRUE == cfgEnt->m.modCfg.hdrCompCfg.hdrCompUsed)
+            {
+               /* Close All the channels */
+               pjUtlUlCmpReset(gCb, pjRbCb); 
+               pjCfgUpdUlCompInfo(gCb, pjRbCb, ueCb, &cfgEnt->m.modCfg.hdrCompCfg);
+            }
+
+            /* In case of Hand off scenario: At Target eNode-B, 
+               Handoff information will send in re-cfg req */
+
+            if(TRUE  & cfgEnt->m.modCfg.hoInfo.isHoPres)
+            {
+               /* Store the HO information  and call for Status Report
+                * Generation also */
+              
+               /* Down Up Lin Information present */
+               if(CPJ_HO_UL & cfgEnt->m.modCfg.hoInfo.isHoPres)
+               {
+                  RLOG_ARG2(L_DEBUG,DBG_UEID,ueCb->key.ueId, 
+                        "Received PDCP Update from Application for dir(%d), mode(%d)",
+                               pjRbCb->dir, pjRbCb->mode);
+
+                  pjRbCb->ulCb.rxDeliv = cfgEnt->m.modCfg.hoInfo.ulCount;
+                  pjRbCb->ulCb.rxNext = cfgEnt->m.modCfg.hoInfo.ulCount;
+                  if (pjRbCb->snLen != cfgEnt->m.modCfg.hoInfo.snLen)
+                  {
+                     pjRbCb->snLen = cfgEnt->m.modCfg.hoInfo.snLen;
+                  }
+                  /* Store the Count in ulCb, this is needed while sending PDCP Status Report */
+                  bMapLen = cfgEnt->m.modCfg.hoInfo.numBits;
+                  bitMap = cfgEnt->m.modCfg.hoInfo.ulBitMap;
+
+                  /* Build and send the Status Report to RLC */
+                  /* Send the FMS & bitmap retrieved now from App */
+                  RLOG_ARG0(L_DEBUG,DBG_UEID,ueCb->key.ueId,
+                          "Sending PDCP Status Report to UE ");
+
+                  pjUlmBldStaRep(gCb, pjRbCb, pjRbCb->ulCb.rxDeliv, bitMap, bMapLen);
+
+                  pjUlmProcessUlPktQ(gCb, pjRbCb);
+
+                  pjRbCb->state = PJ_STATE_NORMAL;
+
+                  if(bMapLen != 0)
+                  {
+                     PJ_FREE(gCb, bitMap, (bMapLen / 8) * sizeof(U8));
+                  }
+               } 
+            }
+
+            break;
+         }
+
+         /* Un Expected cfg type */
+      default:
+         {
+            RLOG1(L_ERROR, "Invalid cfgType [%d]", cfgEnt->cfgType);
+         }
+   }
+   RETVALUE(ret);
+} /* pjCfgFillPjRbCb */
+
+
+\f
+/**
+* @brief 
+*
+*   Hanlder to process the re-configuration for existing PJRB from the upper
+*   layer.
+*
+* @b Description: 
+*     1. This function fetch the PJRB from pdcp data base. @n
+*     2. update the data base with the  new configuration informtion received.  @n
+*     3. Return Success or Failure to the caller with reason and status
+*     information. @n
+*
+* @param [in]    ueId     -  UE Identifier
+* @param [in]    cellId   -  CELL Identifier
+* @param [in]    entCfg   -  Entity Configuration to be done.
+* @param [out]   entCfm   -  Entity Confirmation.
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgReCfgUlRb
+(
+PjCb              *gCb,
+PjUlUeCb          *ueCb,
+CpjCfgEnt         *entCfg,
+CpjCfmEnt         *entCfm
+)
+#else
+PUBLIC S16 pjCfgReCfgUlRb (gCb, ueCb, entCfg, entCfm)
+PjCb              *gCb;
+PjUlUeCb          *ueCb;
+CpjCfgEnt         *entCfg;
+CpjCfmEnt         *entCfm;
+#endif
+{
+   S16       ret;
+   PjUlRbCb     *rbCb;    /* Rb Cb */
+
+   TRC3(pjCfgReCfgUlRb);
+
+   /* Initialization */
+   ret  = ROK;
+   rbCb = NULLP;
+
+   RLOG2(L_DEBUG, "Re-Cfg UL RB Req Received for -- cellId(%d),ueId(%d)",
+                     ueCb->key.cellId,ueCb->key.ueId);
+
+   /* Fetch Rb Cb */
+   PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
+
+   /* Rb Cb is not present or Rb Cb is not configured for PDCP */
+   if( NULLP == rbCb)
+   { 
+      RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId[%u]:RbId[%d] not found",
+            ueCb->key.cellId, entCfg->rbId);
+      /* Fill entCfm structure */
+      PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+            CPJ_CFG_REAS_PDCPID_UNKWN);
+
+      RETVALUE(RFAILED);
+   }
+
+   /* Copy the received infromation in to Rb Cb */
+   ret = pjCfgFillPjUlRbCb(gCb, rbCb, ueCb,FALSE, entCfg , entCfm);
+
+   /* Fill the Cfm status and Reason */
+   PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
+         CPJ_CFG_REAS_NONE);
+
+
+   RETVALUE(ret);
+} /* pjCfgReCfgRb */
+
+\f
+/**
+* @brief
+*  This function deletes the existing RB(PDCP and RLC) from  Ue Cb.
+*
+* @b Description:
+*    1. Stop the timers and deallocate tx/rx Buffs for PJRB CB. @n
+*    2. Delete the existing RB Cb(PDCP and RLC)  from Ue Cb. @n
+*
+* @param [in]    ueId     -  UE Identifier
+* @param [in]    cellId   -  CELL Identifier
+* @param [in]    entCfg   -  Entity Configuration to be done.
+* @param [out]   entCfm   -  Entity Confirmation.
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgDelUlRb
+(
+PjCb              *gCb,
+PjUlUeCb          *ueCb,
+CpjCfgEnt         *entCfg,
+CpjCfmEnt         *entCfm
+)
+#else
+PUBLIC S16 pjCfgDelUlRb (gCb, ueId, cellId, entCfg, entCfm)
+PjCb              *gCb;
+PjUlUeCb          *ueCb;
+CpjCfgEnt         *entCfg;
+CpjCfmEnt         *entCfm;
+#endif
+{
+   S16      ret;
+   PjUlRbCb *rbCb = NULLP; 
+
+   TRC3(pjCfgDelUlRb);
+
+   /* Initialization */
+   ret = ROK;
+
+   RLOG2(L_DEBUG, "Del UL RB Req Received for -- cellId(%d),ueId(%d)",
+                     ueCb->key.cellId, ueCb->key.ueId);
+
+   /* Fetch RB Cb */
+   PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
+
+   /* RB Cb is not present   or not configured for PDCP */
+   if (NULLP == rbCb) 
+   { 
+      RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId[%u]:RbId[%d] not found",
+            ueCb->key.cellId, entCfg->rbId);
+      /* Fill entCfm structure with invalid pdcp Id */
+      PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+            CPJ_CFG_REAS_INVALID_PDCPID);
+
+      RETVALUE(RFAILED);
+   }
+   /* Delete PDCP Related infromation from RB CB */
+   ret= pjCfgDelPjUlRbCb(gCb, ueCb, rbCb); 
+
+   if(ROK != ret)
+   {
+      /* Fill entCfm structure with invalid pdcp Id */
+      PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+            CPJ_CFG_REAS_INVALID_PDCPID);
+
+      RLOG_ARG2(L_ERROR, DBG_UEID, ueCb->key.ueId, "CellId[%u]:RbId[%d] not deleted",
+            ueCb->key.cellId, entCfg->rbId);
+      RETVALUE(ret);
+   }
+   /* Fill the Cfm status and Reason */
+   PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
+         CPJ_CFG_REAS_NONE);
+
+
+   RETVALUE(ret);
+} /* pjCfgDelRb */
+
+
+
+\f
+/**
+*  @brief
+*
+*   This primitive is used to re-establish Uplink SRB2 and/or DRB'S during RRC connection
+*   re-configuration procedure.
+*  
+*  @b Description:
+*  1. This function will trigger re-establishment for SRB2 and/or DRB's
+*
+* @param [in]    gCB      -  Pdcp Instance Control block
+* @param [in]    ueId     -  UE Identifier
+* @param [in]    cellId   -  CELL Identifier
+* @param [in]    entCfg   -  Entity Configuration to be done.
+* @param [out]   entCfm   -  Entity Configuration cfm.
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgReEstUlRb
+(
+PjCb              *gCb,
+PjUlUeCb          *ueCb, 
+CpjCfgEnt         *entCfg,
+CpjCfmEnt         *entCfm,
+UdxCfmEnt         *entDlCfgCfm 
+)
+#else
+PUBLIC S16 pjCfgReEstUlRb (gCb, *ueCb, entCfg, entCfm, entDlCfgCfm)
+PjCb          *gCb;
+PjUlUeCb      *ueCb;
+CpjCfgEnt     *entCfg;
+CpjCfmEnt     *entCfm;
+UdxCfmEnt     *entDlCfgCfm; 
+#endif
+{
+   PjUlRbCb *rbCb = NULLP;
+
+   TRC3(pjCfgReEstUlRb); 
+
+   RLOG2(L_DEBUG, "Config ReEst Req Received for UL RB -- cellId(%d),ueId(%d)",
+                     ueCb->key.cellId, ueCb->key.ueId);
+
+   /* Fetch Rb Cb */
+   PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
+
+   /* Rb Cb is not present or Rb Cb is not configured for PDCP */
+   if( NULLP == rbCb )
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID, ueCb->key.ueId, "CellId[%u]:RbId[%d] not found",
+            ueCb->key.cellId, entCfg->rbId);
+      /*This RB might be configured at PDCP-DL not at PDCP-UL (Rlc-UM RB with DL direction)*/
+      PJ_MEM_CPY(entCfm, entDlCfgCfm, sizeof(CpjCfmEnt)); /* KW_FIX */
+
+      RETVALUE(RFAILED);
+   }
+   /* A Cfm with failure is sent if the re-establishment comes when RBs are not in
+      re-est state */
+   if (ueCb->libInfo.state != PJ_STATE_REEST )
+   {
+      /* Fill entCfm structure with invalid PDCP Id*/
+      PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+            CPJ_CFG_REAS_INVALID_STATE);
+      RLOG_ARG2(L_ERROR, DBG_UEID, ueCb->key.ueId, "CellId[%u]:W/o REEST ,RbId[%d] not reestblshd",
+            ueCb->key.cellId, entCfg->rbId);
+      RETVALUE(RFAILED);
+   }
+
+   if(rbCb->rbType == PJ_SRB)
+   {
+      pjUlmReEstSrb(gCb,rbCb);
+   }
+   else
+   {
+      ueCb->libInfo.numReEstDrb++;
+      rbCb->state = PJ_STATE_REEST;
+     
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+       rbCb->ulCb.obdCnt   = 0;
+       rbCb->ulCb.transCmp = FALSE;
+       if(rbCb->mode == PJ_DRB_AM)
+       {
+          rbCb->ulCb.firstReEstCnt   =   rbCb->ulCb.rxDeliv;
+       }
+#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */    
+   }/* if(rbType == .... */
+   if (entDlCfgCfm->status != CPJ_CFG_CFM_OK)
+   {
+      PJ_MEM_CPY(entCfm, entDlCfgCfm, 
+                       sizeof(CpjCfmEnt)); /* KW_FIX */
+   }
+
+   RETVALUE(ROK);
+} /* pjCfgReEstRb */
+
+
+\f
+/**
+* @brief
+* This primitive Delete Ue Cb from PDCP/RLC data base.
+*
+* @b Description:
+*  1. This primitive Delete the Ue Cb from PDCP/RLC Data base.
+*
+* @param [in]    ueId     -  UE Identifier
+* @param [in]    cellId   -  CELL Identifier
+* @param [in]    entCfg   -  Entity Configuration to be done.
+* @param [out]   entCfm   -  Entity Confirmation.
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgDelUlUe
+(
+PjCb              *gCb,
+PjUlUeCb          *ueCb,
+CpjCfgEnt         *entCfg,
+CpjCfmEnt         *entCfm
+)
+#else
+PUBLIC S16 pjCfgDelUlUe (gCb, ueId, cellId, entCfg, entCfm)
+PjCb              *gCb;
+PjUlUeCb          *ueCb,
+CpjCfgEnt         *entCfg;
+CpjCfmEnt         *entCfm;
+#endif
+{
+   S16     ret;
+
+   TRC3(pjCfgDelUlUe);
+
+   /* Initialization */
+   ret    = ROK;
+
+   RLOG2(L_DEBUG, "pjCfgDelUe- Received for -- cellId(%d),ueId(%d)",
+                     ueCb->key.cellId, ueCb->key.ueId);
+
+
+   /* Delete Ue Cb */
+   ret=pjDbmDelUlUeCb(gCb, ueCb, FALSE);
+
+   /* Fill the Cfm */
+   PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
+         CPJ_CFG_REAS_NONE);
+
+
+   RETVALUE(ret);
+} /* pjCfgDelUe */
+
+\f
+/**
+* @brief
+* This primitive configure the security information of an Ue Cb.
+*
+* @b Description:
+*  1. This primitive  configure the security information of an Ue Cb.
+*  2. Initilize  the  Integrity/Ciphering Channels if required.
+*
+* @param [in]    secCfg   -  Entity Configuration to be done.
+* @param [out]   secCfm   -  Entity Configuration Cfm done.
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgPrcSecUlCfg
+(
+PjCb             *gCb,
+CpjSecCfgReqInfo *secCfg,
+CpjSecCfgCfmInfo *cfgCfm
+)
+#else
+PUBLIC S16 pjCfgPrcSecUlCfg (gCb,secCfg, cfgCfm)
+PjCb              *gCb;
+CpjSecCfgReqInfo  *secCfg;
+CpjSecCfgCfmInfo  *cfgCfm;
+#endif
+{
+   S16     ret;
+   PjUlUeCb *ueCb;
+
+   TRC3(pjCfgPrcSecUlCfg);
+
+   /* Initialization */
+   ret  = ROK;
+   ueCb = NULLP;
+
+   RLOG2(L_DEBUG, "pjCfgPrcSecCfg- Received for -- cellId(%d),ueId(%d)",
+                     secCfg->cellId, secCfg->ueId);
+
+   /* Fetch Ue Cb */
+   ret = pjDbmFetchUlUeCb(gCb, secCfg->ueId, secCfg->cellId, &ueCb);
+
+   /* Ue Cb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   { 
+      RLOG_ARG1(L_ERROR, DBG_CELLID, secCfg->cellId,"UeId[%u] not found",
+            secCfg->ueId);
+      /* Fill entCfm structure */
+      PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
+            CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN);
+      RETVALUE(ret);
+   }
+
+   ueCb->secInfo.selSecAct= secCfg->secCfg.selSecAct;
+
+   /* Store Integrity Information */
+   ueCb->secInfo.intInfo.algoType=secCfg->secCfg.integInfo.algoType;
+   cmMemcpy(&ueCb->secInfo.intInfo.intKey[0], &secCfg->secCfg.integInfo.intKey[0], CPJ_INTG_KEY_LEN);
+
+   /* Store Ciphering Informaiton */
+   ueCb->secInfo.cipherInfo.algoType=secCfg->secCfg.cipherInfo.algoType; 
+
+   cmMemcpy(ueCb->secInfo.cipherInfo.cpKey,
+         &secCfg->secCfg.cipherInfo.ctrlplnKey[0],CPJ_CIPHER_KEY_LEN);
+
+   cmMemcpy(ueCb->secInfo.cipherInfo.upKey,
+         &secCfg->secCfg.cipherInfo.usrplnKey[0],CPJ_CIPHER_KEY_LEN);
+
+   /* Security Activation Done */
+   ueCb->secInfo.secAct = TRUE;
+
+   if(TRUE == secCfg->secCfg.isHo)
+   {
+      ueCb->secInfo.firstMsg   =  FALSE;
+   }
+   else
+   {
+      ueCb->secInfo.firstMsg   =  TRUE;
+   }
+
+   ueCb->secInfo.secCxt.cellId = secCfg->cellId;
+   ueCb->secInfo.secCxt.ueId   = secCfg->ueId;
+   ueCb->secInfo.secCxt.dir    = PJ_SEC_DIR_UL;
+
+#ifndef ALIGN_64BIT
+   RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId, 
+         "Security Paramters stored in UE CB are -- cellId(%d),"
+          " Integrity Algo(%ld), cipherAlgoType(%ld) ",
+           secCfg->cellId, ueCb->secInfo.intInfo.algoType,
+           ueCb->secInfo.cipherInfo.algoType);
+#else
+   RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId, 
+         "Security Paramters stored in UE CB are -- cellId(%d),"
+          " Integrity Algo(%d), cipherAlgoType(%d) ",
+           secCfg->cellId, ueCb->secInfo.intInfo.algoType,
+           ueCb->secInfo.cipherInfo.algoType);
+#endif
+   /* Open the Security Channels */
+
+   if(ueCb->secInfo.secAct)
+   {
+
+#ifdef PJ_SEC_ASYNC
+      ueCb->secInfo.secCxt.cfgTxId = ueCb->libInfo.nxtAvlbTxId;
+#endif 
+
+      ret = pjUtlUlIntInit(gCb,ueCb);
+
+      /* Integrity Init failed */
+      if(ROK != ret)
+      {
+         PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
+               CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_INTINIT_FAILED);
+
+         RETVALUE(ret);
+
+      }
+      ret = pjUtlUlCpInit(gCb,ueCb);
+      /* Ciphering Control Plane Init failed */
+      if(ROK != ret)
+      {
+         PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
+               CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_CCIPHR_FAILED);
+
+         RETVALUE(ret);
+
+      }
+      ret = pjUtlUlUpInit(gCb,ueCb);
+
+      /* Ciphering User Plane Init failed */
+      if(ROK != ret)
+      {
+         PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
+               CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UCIPHR_FAILED);
+
+         RETVALUE(ret);
+      }
+   }
+
+   /* Fill Cfg Cfm with Status OK */
+   PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
+         CPJ_CFG_CFM_OK,CPJ_CFG_REAS_NONE);
+
+   RETVALUE(ROK);
+} /* pjCfgPrcSecCfg */
+
+\f
+/**
+* @brief
+* This primitive changes the ueId of existing Ue Cb.
+* 
+* @b Description:
+*
+*    1. This function delete the UeCb from hashList. @n
+*    2. Update the Ue Cb with the new Keys. @n
+*    3. Insert the UeCb in hash list with new Key.  @n
+*
+* @param [in]    ueInfo      -  Old UE Information
+* @param [in]    newUeInfo   -  New UE Information
+* @param [out]   status      -  Status
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgUlUeIdChng
+(
+PjCb      *gCb,
+CpjUeInfo *ueInfo,
+CpjUeInfo *newUeInfo,
+CmStatus  *status
+)
+#else
+PUBLIC S16 pjCfgUlUeIdChng (gCb, ueInfo, newUeInfo, status)
+PjCb      *gCb;
+CpjUeInfo *ueInfo;
+CpjUeInfo *newUeInfo;
+CmStatus  *status;
+#endif
+{
+   PjUlUeCb *ueCb;
+   S16    ret;
+
+   TRC3(pjCfgUlUeIdChng)
+
+   ueCb = NULLP;
+   ret= ROK;
+
+   RLOG2(L_DEBUG, "pjCfgUeIdChng- Recived for -- cellId(%d),ueId(%d)",
+                     ueInfo->cellId, ueInfo->ueId);
+
+   if ( (ueInfo->ueId == newUeInfo->ueId) && 
+        (ueInfo->cellId == newUeInfo->cellId))
+   {
+      status->reason = CPJ_CFG_REAS_SAME_UEID;
+      status->status = CPJ_CFG_CFM_NOK; 
+
+#ifdef DEBUGP
+      RLOG_ARG3(L_ERROR,DBG_UEID,ueInfo->ueId, "Changing UE Id -- Failed :"
+           "old and New UeId are Same - cellId(%d),newCellId(%d), newUeId(%d)",
+                ueInfo->cellId, newUeInfo->cellId, newUeInfo->ueId);
+#endif
+      RETVALUE(RFAILED);
+   } 
+   
+   ret = pjDbmFetchUlUeCb(gCb, newUeInfo->ueId, newUeInfo->cellId, &ueCb);
+   if (ret == ROK)
+   {
+
+#ifdef DEBUGP
+      RLOG_ARG1(L_ERROR,DBG_UEID,ueInfo->ueId,
+            "Changing Ue ID Failed :New UeId already Exists -- cellId(%d)",
+                     newUeInfo->cellId );
+#endif
+      status->reason = CPJ_CFG_REAS_SAME_UEID;
+      status->status = CPJ_CFG_CFM_NOK;
+      RETVALUE(RFAILED);
+   }
+  
+   ret = pjDbmFetchUlUeCb(gCb, ueInfo->ueId, ueInfo->cellId, &ueCb);
+   if (ret != ROK)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, ueInfo->cellId,"UeId[%u] not found",ueInfo->ueId);
+      status->reason = CPJ_CFG_REAS_UE_UNKWN;
+      status->status = CPJ_CFG_CFM_NOK;
+      RETVALUE(RFAILED);
+   }
+  
+   ret = cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb);
+   if (ret != ROK)
+   {
+
+#ifdef DEBUGP
+      RLOG_ARG1(L_ERROR,DBG_UEID,ueInfo->ueId, "cmHashListDelete Failed -- cellId(%d)",
+                     ueInfo->cellId);
+#endif
+      status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL;
+      status->status = CPJ_CFG_CFM_NOK;
+      RETVALUE(RFAILED);
+   }
+   
+   /* update the hash key with new values */ 
+   ueCb->key.ueId = newUeInfo->ueId;
+   ueCb->key.cellId = newUeInfo->cellId;
+
+    ret = cmHashListInsert(&(gCb->u.ulCb->ueLstCp), (PTR)ueCb, 
+          (U8 *)&(ueCb->key), (U16) sizeof(PjUeKey));
+
+  if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG_ARG2(L_ERROR,DBG_UEID,ueInfo->ueId, 
+            "cmHashListInsert Failed -- cellId(%d),New ueId(%d)",
+                     newUeInfo->cellId, newUeInfo->ueId);
+#endif
+      status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL;
+      status->status = CPJ_CFG_CFM_NOK;
+   }  
+  
+   RETVALUE(ret);
+} /* pjCfgUeIdChng */
+
+\f
+/**
+* @brief
+* This primitive reports the Count informatin of all RBs of an Ue Cb.
+*
+* @b Description:
+* 1. This function reports the count information of all the RBs of an UE. 
+*
+* @param [in]    ueId     -  UE Identifier
+* @param [in]    cellId   -  CELL Identifier
+* @param [out]   countCfm -  Count Information
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgPrcUlCount
+(
+PjCb            *gCb,
+CpjCountReqInfo *countReq,
+CpjCountCfmInfo       *countCfm,
+UdxCountCfmInfo *cntCfm
+)
+#else
+PUBLIC S16 pjCfgPrcUlCount (gCb, countReq, countCfm)
+PjCb            *gCb;
+CpjCountReqInfo *countReq;
+CpjCountCfmInfo       *countCfm;
+UdxCountCfmInfo *cntCfm;
+#endif
+{
+   S16     ret;
+   PjUlUeCb  *ueCb;
+   PjUlRbCb    *rbCb;
+   U8      numdlRb;
+   U8      idx;
+   U8      idx1;
+
+   TRC3(pjCfgPrcUlCount); 
+
+   /* Initialization */
+   ueCb   = NULLP;
+   rbCb   = NULLP;
+   ret    = ROK;
+   idx  = 0;
+   idx1  = 0;
+   numdlRb = cntCfm->numRb;
+
+   RLOG2(L_DEBUG, "pjCfgPrcCount - Count Request Received for - cellId(%d),ueId(%d)",
+                     countReq->cellId, countReq->ueId);
+
+   /* Fetch  ue Cb */
+   ret = pjDbmFetchUlUeCb(gCb, countReq->ueId, countReq->cellId, &ueCb);
+   countCfm->ueId = countReq->ueId;
+   countCfm->cellId = countReq->cellId;
+   countCfm->transId = countReq->transId;
+
+   /* Ue Cb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   { 
+      RLOG_ARG1(L_ERROR, DBG_CELLID, countReq->cellId,"UeId[%u] not found",countReq->ueId);
+      /* Fill entCfm structure */
+      countCfm->numRb  = cntCfm->numRb;
+      countCfm->status = CPJ_CFG_CFM_NOK;
+      countCfm->reason = CPJ_CFG_REAS_UE_UNKWN;
+      RETVALUE(ret);
+   }
+
+   /* Loop through all DRBs  */
+   for(idx=0; idx < PJ_MAX_DRB_PER_UE; idx++)     /* KW_FIX */
+   {
+      rbCb = ueCb->drbCb[idx];
+      /* RB is present and configured for PDCP Layer */
+      if(NULLP != rbCb)
+      {
+         for(idx1=0; idx1 < numdlRb; idx1++)
+         {
+            if(rbCb->rbId == countCfm->countInfo[idx1].rbId)
+            {
+               countCfm->countInfo[idx1].ulCount=  rbCb->ulCb.rxNext; 
+               break;
+            }   
+            else
+            {    
+               countCfm->countInfo[countCfm->numRb].rbId= rbCb->rbId; 
+               countCfm->countInfo[countCfm->numRb].dir = rbCb->dir; 
+               countCfm->countInfo[countCfm->numRb].ulCount= rbCb->ulCb.rxNext; 
+               countCfm->countInfo[countCfm->numRb].dlCount= 0; 
+               countCfm->numRb++;  
+            }
+         } 
+         if(numdlRb == 0)
+         {  
+            countCfm->countInfo[countCfm->numRb].rbId= rbCb->rbId; 
+            countCfm->countInfo[countCfm->numRb].dir = rbCb->dir; 
+            countCfm->countInfo[countCfm->numRb].ulCount= rbCb->ulCb.rxNext; 
+            countCfm->countInfo[countCfm->numRb].dlCount= 0; 
+            countCfm->numRb++;  
+
+         }
+
+      }
+
+   }
+
+   /* Fill CountCfm with status and reason */
+   if(countCfm->numRb)
+   {
+      countCfm->status =CPJ_CFG_CFM_OK;
+      countCfm->reason =CPJ_CFG_REAS_NONE;
+   }
+   else
+   {
+      countCfm->status =CPJ_CFG_CFM_NOK;
+      countCfm->reason =CPJ_CFG_REAS_NO_DRBS;
+
+   }
+
+   RETVALUE(ret);
+} /* pjCfgPrcCount */
+
+/**
+* @brief
+* This primitive reports SDU status information of all RBs of an Ue Cb.
+*
+* @b Description:
+*  1. This primitive Trigger the Handoff Request procedure 
+*
+* @param [in]    ueId      -  UE Identifier
+* @param [in]    cellId    -  CELL Identifier
+* @param [out]   sduStaCfm -  SDU Status Information
+* 
+* @return  ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjCfgPrcUlSduSta
+(
+PjCb                 *gCb,
+CpjSduStaReqInfo     *staReq,
+UdxSduStaCfmInfo     *staCfm
+)
+#else
+PUBLIC S16 pjCfgPrcUlSduSta (gCb, staReq, staCfm)
+PjCb                 *gCb;
+CpjSduStaReqInfo     *staReq;
+UdxSduStaCfmInfo     *staCfm;
+#endif
+{
+   S16                ret;
+   PjUlUeCb          *ueCb;
+   CpjSduStaCfmInfo  *cfmInfo;
+
+   TRC3(pjCfgPrcUlSduSta);
+
+   /* Initialization */
+   ret  = ROK;
+   ueCb = NULLP;
+
+   RLOG2(L_DEBUG, "pjCfgPrcSduSta - Received for -- cellId(%d),ueId(%d)",
+                     staReq->cellId, staReq->ueId);
+
+
+   /* Fetch Ue Cb */
+   ret = pjDbmFetchUlUeCb(gCb, staReq->ueId, staReq->cellId, &ueCb);
+
+   /* UeCb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   { 
+      RLOG_ARG1(L_ERROR, DBG_CELLID, staReq->cellId,"UeId[%u] not found",staReq->ueId);
+      /* Memory leak fix ccpu00135359 */
+      PjCpjSapCb        *cpjSap;
+      cpjSap = &gCb->u.ulCb->cpjSap;
+      if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfmInfo, 
+         sizeof (CpjSduStaCfmInfo)) != ROK)
+      {
+         RLOG0(L_FATAL,"Memory allocation failed");
+         RETVALUE(RFAILED);
+      }
+
+      cfmInfo->ueId = staReq->ueId;
+      cfmInfo->cellId = staReq->cellId;
+      cfmInfo->transId = staReq->transId;
+      cfmInfo->status = CPJ_CFG_CFM_NOK; 
+      cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN;
+
+      /* Caller should return cfm with failure */
+      RLOG_ARG1(L_DEBUG,DBG_UEID,staReq->ueId, "UE Cb is not found -- cellId(%d)",
+                     staReq->cellId);
+
+      /* Send Failure SduStaCfm */
+      PjUiCpjSduStaCfm(&gCb->u.ulCb->cpjSap.pst, 
+                        gCb->u.ulCb->cpjSap.suId, cfmInfo);
+
+      
+      RETVALUE(RFAILED);
+   }
+
+   /* Call Ho Start handler for this UE */
+   pjUtlUlReEstHO(gCb, ueCb);
+
+   ueCb->hoInfo->transId = staReq->transId;
+   ueCb->hoInfo->staCfm = staCfm;
+
+   if (ueCb->libInfo.numReEstCmp > 0)
+   {
+      if (ueCb->libInfo.numReEstCmp > ueCb->libInfo.numReEstDrb)
+      {
+         /* Error Case */
+         ueCb->libInfo.numReEstDrb = 0;
+         ueCb->libInfo.numReEstCmp = 0;
+      } 
+      else
+      {
+         ueCb->libInfo.numReEstDrb -= ueCb->libInfo.numReEstCmp;
+         ueCb->libInfo.numReEstCmp = 0;
+      }
+   }
+
+   if (ueCb->libInfo.numReEstDrb == 0)
+   {
+      pjUtlUlSndSduStaCfm(gCb,ueCb);
+   }
+
+   RETVALUE(ROK);
+} /* pjCfgPrcSduSta */
+
+   
+\f
+/**
+ * @brief
+ * This primitive to update the ROHC Comp details in PJRB  Cb.
+ *
+ * @b Description:
+ *  1. This primitive to update  the ROHC comp detils in PJRB Cb.
+ *
+ * @param [in]    pjRbCb    -  RB Control Block  
+ * @param [in]    ueCb      -  Ue Control Block 
+ * @param [in]    hdrCompCfg-  Comp Cfg Information 
+ * 
+ * @return  ROK
+ *
+ */
+#ifdef ANSI
+PRIVATE S16 pjCfgUpdUlCompInfo 
+(
+PjCb                   *gCb,
+PjUlRbCb               *rbCb,
+PjUlUeCb               *ueCb,
+CpjHdrCompCfg        *rohcCfg
+)
+#else
+PRIVATE S16 pjCfgUpdUlCompInfo(gCb, rbCb, ueCb, rohcCfg)
+PjCb                   *gCb; 
+PjUlRbCb               *rbCb;
+PjUlUeCb               *ueCb;
+CpjHdrCompCfg        *rohcCfg;
+#endif
+{
+   U16   profId;
+   U8    idx;
+   S16   ret;
+
+   TRC3(pjCfgUpdUlCompInfo);
+
+   /* Initialization */   
+   ret    = ROK;
+   profId = 0;
+   idx  = 0; 
+
+   RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Received for -- cellId(%d),RbId(%d)",
+                     rbCb->rbId, ueCb->key.ueId);
+
+   /* Header Compresion information present */
+   if(rohcCfg->hdrCompUsed)
+   {
+      /* Header Compression is enabled */ 
+      rbCb->rohc.hdrCmpUsed = TRUE;
+
+      /* User Can Configure multipel profiles. Maximum profile ID should be used */  
+      for(; idx<CPJ_MAX_ROHC_PROF_LIST; idx++)
+      {
+         if((rohcCfg->rohcInfo.profLst[idx] )&&
+               (profId < rohcProfId[idx]))
+            profId = rohcProfId[idx];
+      } 
+   }
+   else
+   {
+      /* Header Compression is disabled */
+      rbCb->rohc.hdrCmpUsed = FALSE;
+      profId = 0x0000;
+   }
+
+   /* Store the profile Id and MaxCid */
+
+   rbCb->rohc.profId = profId;
+   rbCb->rohc.maxCid = rohcCfg->rohcInfo.maxCid;
+
+   /* Store the ue Details in Compressor Context */
+   rbCb->cmpCxt.ueId   = ueCb->key.ueId;
+   rbCb->cmpCxt.cellId = ueCb->key.cellId;
+   rbCb->cmpCxt.rbId   = rbCb->rbId;
+   rbCb->cmpCxt.rbType = rbCb->rbType;
+
+   RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Selected   -- profId(%d),maxCid(%d)",
+                     rbCb->rohc.profId, rbCb->rohc.maxCid);
+
+
+   /* Compress Init */
+   if(rbCb->rohc.hdrCmpUsed)
+   {
+      ret=pjUtlUlCmpInit(gCb, rbCb); 
+   }
+
+   RETVALUE(ret);
+} /* pjCfgUpdCompInfo */
+
+\f
+/**
+ * @brief
+ * This primitive to delete RB from Ue Cb.
+ *
+ * @b Description:
+ * 1. To delete the PJRB Cb from  UeCb.
+ *
+ * @param [in]    ueCb      -  Ue Control Block 
+ * @param [in]    rbCb      -  Rb Control Block  
+ * 
+ * @return  ROK
+ *
+ */
+#ifdef ANSI
+PUBLIC S16  pjCfgDelPjUlRbCb 
+(
+PjCb                 *gCb,
+PjUlUeCb             *ueCb,
+PjUlRbCb             *rbCb
+)
+#else
+PUBLIC S16 pjCfgDelPjUlRbCb(gCb,ueCb,rbCb)
+PjCb                  *gCb;
+PjUlUeCb              *ueCb;
+PjUlRbCb              *rbCb;
+#endif
+{   
+   S16  ret;
+/* kw005.201 added support for L2 measurement */
+#ifdef LTE_L2_MEAS_COMMENT
+   U8   evtIdx;
+   U8   qciIdx;
+#endif
+   TRC3(pjCfgDelPjUlRbCb);
+
+   /* Initialization */
+   ret = ROK;
+
+   RLOG0(L_DEBUG,"pjCfgDelPjRBCb- Recieved -- rbId() CfgState() ");
+
+   /* RbCb is present and Configured for PDCP */
+   if(NULLP != rbCb) 
+   {
+      RLOG1(L_DEBUG, "pjCfgDelPjRBCb- Received for -- rbId (%d)",
+               rbCb->rbId);
+
+#ifdef LTE_L2_MEAS
+      /* This should be done for every counter added for UL */
+      if((rbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS] != NULLP) &&
+          (rbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->totDrbsPerQci > 0))
+      {
+         rbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->totDrbsPerQci--;
+      }
+#endif
+      Bool tmrRunning = pjChkTmr(gCb,(PTR)rbCb,PJ_EVT_UL_REORD_TMR);
+      if(tmrRunning)
+      {
+          pjStopTmr(gCb,(PTR)rbCb, PJ_EVT_UL_REORD_TMR);
+      }
+
+
+      rbCb->ueCb   = NULLP;
+
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+      /* Stop off board timers */  
+
+      if(PJ_DIR_UL & rbCb->dir)
+          if(rbCb->ulCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR)
+          {
+                pjStopTmr(gCb, (PTR)&rbCb, PJ_EVT_UL_OBD_TMR); 
+          }
+#endif
+     
+      /* Deinit Rx Buffers */
+      pjDbmRxDeInit(gCb,&rbCb->ulCb.recBuf);
+      pjUtlEmptyUlPktList(gCb, rbCb);
+
+      /* Close the Comp channels */  
+      if (PJ_SRB == rbCb->rbType)
+      {
+         ueCb->numSrbs--;
+      }
+      else if (PJ_DRB == rbCb->rbType)
+      {
+         ueCb->numDrbs--;
+         if (rbCb->rohc.hdrCmpUsed)
+         {
+            pjUtlCmpClose(gCb,rbCb->cmpCxtId);
+         }
+      }
+            /* Free the rbCb */
+      pjDbmDelUlRbCb(gCb,rbCb->rbId, rbCb->rbType, &rbCb, PJ_CFG_PDCP, ueCb);
+
+   } 
+   RETVALUE(ret);
+} /* pjCfgDelPjRBCb */
+
+\f
+/**
+ * @brief
+ * Handler to process the re-establishment Request for SRB1 during
+ * RRC Re-Establishment request.
+ *
+ * @b Description:
+ * 1. This primitive is used to re-establish SRB1 only during RRC Re-establishment 
+ * 2. New Security Algo will applied 
+ *
+ * @param [in]    reEstReq   -  Entity Configuration to be done.
+ * @param [out]   reEstCfm   -  Entity Configuration cfm.
+ * 
+ * @return  ROK
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjCfgUlReEstReq
+(
+PjCb              *gCb,
+CpjReEstReqInfo   *reEstReq,
+CpjReEstCfmInfo   *reEstCfm
+)
+#else
+PUBLIC S16 pjCfgUlReEstReq (gCb, reEstReq, reEstCfm)
+PjCb              *gCb;
+CpjReEstReqInfo   *reEstReq;
+CpjReEstCfmInfo   *reEstCfm;
+#endif
+{
+   S16     ret;
+   PjUlUeCb  *ueCb;
+   PjUlRbCb    *rbCb;
+   CmLteRlcId rlcId;
+
+   TRC3(pjCfgUlReEstReq);
+   /* Initialization */
+   ret = ROK;
+   rlcId.ueId   =  reEstReq->pdcpId.ueId;
+   rlcId.cellId   =  reEstReq->pdcpId.cellId;
+   rlcId.rbId   =  reEstReq->pdcpId.rbId;
+   rlcId.rbType   =  reEstReq->pdcpId.rbType;
+
+   RLOG2(L_DEBUG, "pjCfgReEstReq- Received for -- cellId(%d),ueId(%d)",
+                     rlcId.cellId, rlcId.ueId);
+
+   ret = pjDbmFetchUlRbCb(gCb, rlcId,&rbCb);
+   
+   
+   /* Ue Cb is not present */
+   if( ROK != ret || NULLP == rbCb)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:RbId[%d] not found",
+            rlcId.cellId, rlcId.rbId);
+      /* Fill entCfm structure */
+      PJ_CFG_FILL_REESTREQ_CFM(reEstCfm, rlcId.ueId,rlcId.cellId,
+            reEstReq->transId, LCM_PRIM_NOK);
+      RETVALUE(ret);
+   }
+  
+   ueCb = rbCb->ueCb;
+
+   /* Copy Security Information */ 
+   cmMemcpy(&ueCb->secInfo.intInfo.intKey[0], &reEstReq->intKey[0], PJ_INTG_KEY_LEN);
+   cmMemcpy(&ueCb->secInfo.cipherInfo.cpKey[0], &reEstReq->ctrlplnKey[0], PJ_CIPHER_KEY_LEN);
+   cmMemcpy(&ueCb->secInfo.cipherInfo.upKey[0], &reEstReq->usrplnKey[0], PJ_CIPHER_KEY_LEN);
+
+   /* Mark Security Action Done */
+   ueCb->secInfo.secAct = TRUE;
+
+   reEstCfm->transId = reEstReq->transId;
+   reEstCfm->ueId    = reEstReq->pdcpId.ueId;
+   reEstCfm->cellId  = reEstReq->pdcpId.cellId;
+
+   /* Save the information */
+#ifdef PJ_SEC_ASYNC
+   pjUtlUlSaveCfmInfo(gCb,rbCb->ueCb, PJ_REEST_ASYNC_CFM, FALSE, ENTPJ, 
+                                          (PTR)reEstCfm, NULLP);
+   PJ_FREE(gCb,reEstCfm, sizeof(CpjReEstCfmInfo));
+#endif /* PJ_SEC_ASYNC */
+
+   /* Call ReEst for SRB1 */
+   pjUtlUlReEstSrb1(gCb,rbCb);
+
+   RETVALUE(ROK);
+} /* pjCfgReEstReq */
+
+#ifdef LTE_L2_MEAS
+/**
+ * @brief
+ * Handler to add measCb to rbCb.
+ *
+ * @b Description:
+ * Handler to add measCb to rbCb.
+ *
+ * 
+ * @return  ROK
+ *
+ */
+PRIVATE S16 pjAddToUlL2Meas(PjCb *tPjCb, PjUlRbCb *pjRbCb,U8 cellId, U16 ueId)
+{
+   U32 cntr;
+
+   RLOG1(L_DEBUG, "L2_MEAS_ADD Adding UE ueid %d ", ueId);
+
+   for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++)
+   {
+      PjL2MeasCb *measCb = &tPjCb->u.ulCb->pjL2Cb.pjL2EvtCb[cntr].measCb;
+
+      if (measCb->measType & LPJ_L2MEAS_UL_LOSS)
+      {
+         pjUtlPlcMeasDatInUlL2Sts(&measCb->measData[pjRbCb->qci],
+               &pjRbCb->rbL2Cb, measCb->measType);
+         measCb->qci[pjRbCb->qci] = pjRbCb->qci;
+         measCb->measData[pjRbCb->qci].totDrbsPerQci++;
+         measCb->numQci++;
+      }
+   }
+   RETVALUE(ROK);
+}/*pjAddToDlL2Meas*/ 
+#endif
+
+/*@}*/
+\f
+/********************************************************************30**
+
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_dbm.c b/src/5gnrpdcp/pj_dbm.c
new file mode 100755 (executable)
index 0000000..8f7a25f
--- /dev/null
@@ -0,0 +1,163 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    PDCP - Database module file
+    
+        Type:    C source file
+  
+        Desc:    Source code for Database Module functions such as, 
+
+                  -  pjDbmBufInit
+                  -  pjDbmInsTxEnt
+                  -  pjDbmGetTxEnt
+                  -  pjDbmGetTxEntSn
+                  -  pjDbmDelTxEnt
+                  -  pjDbmTxDeInit
+                  -  pjDbmInsRxEnt
+                  -  pjDbmGetRxEnt
+                  -  pjDbmDelRxEnt
+                  -  pjDbmRxDeInit
+
+        File:    pj_dbm.c
+  
+*********************************************************************21*/
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=214;
+
+\f
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"                /* general */
+#include "ssi.h"                /* system services interface */
+#include "cm5.h"                /* Timer Functions */
+#include "cm_lte.h"             /* common LTE header file */
+#include "cm_hash.h"            /* common hash module  file */
+#include "cm_llist.h"           /* common list header file */
+#include "cpj.h"                /* RRC layer */
+#include "pju.h"                /* PDCP service user */
+#include "lpj.h"                /* RRC layer */
+#include "pj_env.h"             /* RLC environment options */
+#include "pj.h"                 /* RLC layer */
+#include "pj_err.h"
+
+/* extern (.x) include files */
+#include "gen.x"                /* general */
+#include "ssi.x"                /* system services interface */
+#include "cm_lib.x"             /* common library */
+#include "cm5.x"                /* Timer Functions */
+#include "cm_hash.x"            /* common hash module */
+#include "cm_lte.x"             /* common LTE file */
+#include "cm_llist.x"           /* common list header file */
+#include "cpj.x"                /* RRC layer */
+#include "pju.x"                /* PDCP service user */
+#include "lpj.x"                /* LM Interface */
+#include "pj.x"                 /* RLC layer */
+
+
+\f
+/* local defines */
+
+/* local externs */
+
+/* forward references */
+
+/* public variable declarations */
+
+/* This structure holds all the global structs we need. */
+
+/* private variable declarations */
+
+/* private function declarations */
+
+/** @file gp_pj_dbm.c
+@brief PDCP DBM Module
+**/
+
+/*****************************************************************************
+ *                  HANDLER FOR THE TRANSMISSION BUFFER
+ ****************************************************************************/
+\f
+/**
+ *
+ * @brief Handler to initialize  Buffer
+ *
+ * @b Description
+ *        This function is invoked by config to initialize the Buffer
+ *        hash List
+ *
+ *  @param[in]    buf       Rx/Tx Buffer Control Point
+ *  @param[in]    numBins   number of Bins
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmBufInit
+(
+PjCb        *gCb,
+PjBuf       *buf,            /* !< Rx/Tx Buffer */
+U8          numBins          /* !< number of Bins */
+)
+#else
+PUBLIC S16 pjDbmBufInit(gCb,buf, numBins)
+PjCb        *gCb;
+PjBuf       *buf;            /* !< Rx/Tx Buffer */ 
+U8          numBins;         /* !< number of Bins */             
+#endif
+{
+   U8       hashIndex;        /* HashIndex of array */
+
+   TRC3(pjDbmBufInit)
+
+   RLOG1(L_DEBUG, "pjDbmBufInit(buf, numBins(%d)", numBins);
+
+   /* Initialize CmLListCps*/
+   PJ_ALLOC(gCb,buf->datQ, (sizeof(CmLListCp) * numBins));
+#if (ERRCLASS & ERRCLS_DEBUG)
+   if (buf->datQ == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+
+   for(hashIndex = 0; hashIndex < numBins; hashIndex++)
+   {
+      cmLListInit(&buf->datQ[hashIndex]);
+   }
+
+   /* Initialistations of buf */
+   buf->numEntries = 0;
+   buf->numBins    = numBins;
+
+   RETVALUE(ROK);
+} /* pjDbmBufInit */
+
+
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_dbm_dl.c b/src/5gnrpdcp/pj_dbm_dl.c
new file mode 100755 (executable)
index 0000000..29e3db8
--- /dev/null
@@ -0,0 +1,1332 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    PDCP - Database module file
+    
+        Type:    C source file
+  
+        Desc:    Source code for Database Module functions such as, 
+
+                  -  pjDbmBufInit
+                  -  pjDbmInsTxEnt
+                  -  pjDbmGetTxEnt
+                  -  pjDbmGetTxEntSn
+                  -  pjDbmDelTxEnt
+                  -  pjDbmTxDeInit
+                  -  pjDbmInsRxEnt
+                  -  pjDbmGetRxEnt
+                  -  pjDbmDelRxEnt
+                  -  pjDbmRxDeInit
+
+        File:    pj_dbm_dl.c
+  
+*********************************************************************21*/
+  
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=215;
+\f
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"                /* general */
+#include "ssi.h"                /* system services interface */
+#include "cm5.h"                /* Timer Functions */
+#include "cm_lte.h"             /* common LTE header file */
+#include "cm_hash.h"            /* common hash module  file */
+#include "cm_llist.h"           /* common list header file */
+#include "cpj.h"                /* RRC layer */
+#include "pju.h"                /* PDCP service user */
+#include "lpj.h"                /* RRC layer */
+#include "pj_env.h"             /* RLC environment options */
+#include "pj.h"                 /* RLC layer */
+#include "pj_dl.h"
+#include "pj_err.h"
+#include "pj_ptsec.h"
+/* extern (.x) include files */
+#include "gen.x"                /* general */
+#include "ssi.x"                /* system services interface */
+#include "cm_lib.x"             /* common library */
+#include "cm5.x"                /* Timer Functions */
+#include "cm_hash.x"            /* common hash module */
+#include "cm_lte.x"             /* common LTE file */
+#include "cm_llist.x"           /* common list header file */
+#include "cpj.x"                /* RRC layer */
+#include "pju.x"                /* PDCP service user */
+#include "lpj.x"                /* LM Interface */
+#include "pj.x"                 /* RLC layer */
+#include "pj_udx.h"
+#include "pj_udx.x"
+#include "pj_dl.x"
+#include "pj_ul.x"
+U32 pjTotDlPckCntPerCell;
+\f
+/* local defines */
+
+/* local externs */
+
+/* forward references */
+
+/* public variable declarations */
+PUBLIC S16 pjCiphStateChek ARGS ((PjCb *gCb, PjTxEnt *txEnt));
+/* This structure holds all the global structs we need. */
+
+/* private variable declarations */
+
+/* private function declarations */
+
+/** @file gp_pj_dbm.c
+@brief PDCP DBM Module
+**/
+/*****************************************************************************
+ *                  HANDLER FOR THE TRANSMISSION BUFFER
+ ****************************************************************************/
+\f
+/**
+ *
+ * @brief Handler to initialize  Buffer
+ *
+ * @b Description
+ *        This function is invoked by config to initialize the Buffer
+ *        hash List
+ *
+ *  @param[in]    buf       Rx/Tx Buffer Control Point
+ *  @param[in]    numBins   number of Bins
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmDlBufInit
+(
+PjCb        *gCb,
+PjBuf       *buf,            /* !< Rx/Tx Buffer */
+U8          numBins          /* !< number of Bins */
+)
+#else
+PUBLIC S16 pjDbmDlBufInit(gCb, buf, numBins)
+PjCb        *gCb;
+PjBuf       *buf;            /* !< Rx/Tx Buffer */ 
+U8          numBins;         /* !< number of Bins */             
+#endif
+{
+   U8       hashIndex;        /* HashIndex of array */
+
+   TRC3(pjDbmDlBufInit)
+
+   RLOG1(L_DEBUG, "pjDbmBufInit(buf, numBins(%d)", numBins);
+
+   /* Initialize CmLListCps*/
+   PJ_ALLOC(gCb, buf->datQ, (sizeof(CmLListCp) * numBins));
+#if (ERRCLASS & ERRCLS_DEBUG)
+   if (buf->datQ == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+
+   for(hashIndex = 0; hashIndex < numBins; hashIndex++)
+   {
+      cmLListInit(&buf->datQ[hashIndex]);
+   }
+
+   /* Initialistations of buf */
+   buf->numEntries = 0;
+   buf->numBins    = numBins;
+   
+   cmLListInit(&buf->datCfmQ);
+   cmLListInit(&buf->sduSubmitQ);
+   cmLListInit(&buf->reEstPktQ);
+
+   RETVALUE(ROK);
+} /* pjDbmBufInit */
+
+\f
+/**
+ *
+ * @brief Handler to insert into a TX Buffer
+ *
+ * @b Description
+ *        This function is invoked to insert into
+ *        the transmission buffer hash List
+ *
+ *  @param[in]    buf         Tx Buffer 
+ *  @param[in]    txEnt       Transmission Entry
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmInsTxEnt
+(
+PjCb        *gCb,
+PjBuf       *buf,             /* !< Tx Buffer */  
+PjTxEnt     *txEnt            /* !< Tx Entry */              
+)
+#else
+PUBLIC S16 pjDbmInsTxEnt(gCb, buf, txEnt)
+PjCb        *gCb;
+PjBuf       *buf;             /* !< Tx Buffer */              
+PjTxEnt     *txEnt;           /* !< Tx Entry */               
+#endif
+{
+   U8       hashKey;          /* Computed HashKey */
+
+   TRC3(pjDbmInsTxEnt)
+
+//   pjTotDlPckCntPerCell++; 
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
+            "pjDbmInsTxEnt(buf, txEnt(%ld)\n", txEnt->count));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
+            "pjDbmInsTxEnt(buf, txEnt(%d)\n", txEnt->count));
+#endif
+   /* Get the hash index */
+   hashKey = (U8)PJ_HASH_FN(buf, txEnt->count); /*KW_FIX*/
+
+   txEnt->lstEnt.node = (PTR)txEnt;
+   cmLListAdd2Tail(&buf->datQ[hashKey], &txEnt->lstEnt);
+   buf->numEntries ++;
+   txEnt->sduSubmitEnt.node = (PTR)txEnt;
+   cmLListAdd2Tail(&buf->sduSubmitQ, &txEnt->sduSubmitEnt);
+
+   RETVALUE(ROK);
+} /* pjDbmTxBufIns */
+
+\f
+/**
+ *
+ * @brief Handler to fetch from a TX Buffer
+ *
+ * @b Description
+ *        This function is invoked to fetch from
+ *         the transmission buffer hash List
+ *
+ *  @param[in]    buf         Tx Buffer 
+ *  @param[in]    count       Count of the PjTxEnt to retrieve
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC PjTxEnt* pjDbmGetTxEnt
+(
+PjCb        *gCb,
+PjBuf       *buf,        /* !< Tx Buffer  */                    
+U32          count       /* !< Count of the PjTxEnt to retrieve */
+)
+#else
+PUBLIC PjTxEnt* pjDbmGetTxEnt(gCb, buf, count)
+PjCb        *gCb;
+PjBuf       *buf;        /* !<Tx Buffer  */                     
+U32         count;       /* !<Count of the PjTxEnt to retrieve */ 
+#endif
+{
+   U8          hashKey;     /* Computed Hash Key */
+   CmLListCp   *datQ;       /* Pointer to the ListCp */
+   PjTxEnt     *tmpEnt;     /* Loop Var - Pointer to PjTxEnt */
+
+   TRC3(pjDbmGetTxEnt) 
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
+            "pjDbmGetTxEnt(buf, txEnt(%ld)\n", count));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
+            "pjDbmGetTxEnt(buf, txEnt(%d)\n", count));
+#endif 
+   /* Call the hash function */
+   hashKey = (U8)PJ_HASH_FN(buf, count); /*KW_FIX*/
+
+   datQ = &buf->datQ[hashKey];
+
+   cmLListFirst(datQ);
+   while(cmLListCrnt(datQ))
+   {
+      tmpEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(datQ));
+      if(tmpEnt->count  == count)
+      {
+         RETVALUE(tmpEnt);
+      }
+      cmLListNext(datQ);
+   }
+   RETVALUE(NULLP);
+} /* pjDbmGetTxEnt */
+
+\f
+/**
+ *
+ * @brief Handler to fetch from a TX Buffer
+ *
+ * @b Description
+ *        This function is fetch the node based on the SN.
+ *        This function will be called only for the case of a 
+ *        PDCP STATUS REPORT being received by the DRB AM. 
+ *
+ *  @param[in]    buf         Tx Buffer 
+ *  @param[in]    sn          SN to get the Ent
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC PjTxEnt* pjDbmGetTxEntSn
+(
+PjCb        *gCb,
+PjBuf       *buf,        /* !< Tx Buffer  */                     
+U16          sn          /* !< SN of the PjTxEnt to retrieve */ 
+)
+#else
+PUBLIC PjTxEnt* pjDbmGetTxEntSn(gCb, buf, sn)
+PjCb        *gCb;
+PjBuf       *buf;        /* !< Tx Buffer  */                      
+U16         sn;          /* !< SN of the PjTxEnt to retrieve */     
+#endif
+{
+   U8          hashKey;  /* Computed hash index */
+   CmLListCp   *datQ;    /* Pointer to the ListCP */
+   PjTxEnt     *tmpEnt;  /* Loop Var - pointer to PjTxEnt */
+
+   TRC3(pjDbmGetTxEntSn) 
+
+   RLOG1(L_DEBUG, "pjDbmGetTxEnt(buf, sn(%d)", sn);
+
+   /* Call the hash function */
+   hashKey = (U8)PJ_HASH_FN(buf, sn); /*KW_FIX*/
+
+   datQ = &buf->datQ[hashKey];
+
+   /* Loop through to find the entry that matches */
+   cmLListFirst(datQ);
+   while(cmLListCrnt(datQ))
+   {
+      tmpEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(datQ));
+      if(tmpEnt->sn == sn)
+      {
+         RETVALUE(tmpEnt);
+      }
+      cmLListNext(datQ);
+   }
+   RETVALUE(NULLP);
+
+} /* pjDbmGetTxEntSn */
+  
+/* ccpu00136902 */
+#if (defined (LTE_PAL_ENB) || defined (TENB_ACC))
+/**
+ *  @brief This fn is called to chek the state of the PDCP pkts in DL before Ciphering operation
+ *         and appropriate action is taken accordingly
+ *
+ *  @details
+ *      Function : pjCiphStateChek
+ *
+ *  Processing Steps:
+ *
+ *
+ * @return  S16
+ *        -# Success : ROK
+ *        -# Failure : RFAILED
+*/
+#ifdef ANSI
+PUBLIC S16 pjCiphStateChek
+(
+PjCb        *gCb,
+PjTxEnt     *txEnt
+)
+#else
+PUBLIC S16 pjCiphStateChek(gCb, txEnt)
+PjCb        *gCb;
+PjTxEnt     *txEnt;
+#endif
+{
+  TRC3(pjCiphStateChek);
+  PJ_FREE_BUF(txEnt->sdu);
+  PJ_FREE_BUF(txEnt->pdu);
+#ifdef FLAT_BUFFER_OPT
+   if(txEnt->fb.startAddr)
+   {
+       PJ_FREE_FLAT_BUF(gCb, (&(txEnt->fb)));
+   }
+#endif
+
+  PJ_FREE(gCb, txEnt, sizeof(PjTxEnt));
+  RETVALUE(ROK);
+}
+#endif
+
+\f
+/**
+ *
+ * @brief Handler to delete from a TX Buffer
+ *
+ * @b Description
+ *        This function is invoked by to insert into
+ *         the transaction buffer hash List
+ *
+ *  @param[in]    buf         Tx Buffer 
+ *  @param[in]    count       count to get the Ent
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmDelTxEnt
+(
+PjCb        *gCb,
+PjBuf       *buf,     /* !< Tx Buffer  */                     
+U32         count     /* !< Count of the PjTxEnt to delete */ 
+)
+#else
+PUBLIC S16 pjDbmDelTxEnt(gCb, buf, count)
+PjCb        *gCb;
+PjBuf       *buf;     /* !< Tx Buffer  */                      
+U32         count;    /* !< Count of the PjTxEnt to delete */    
+#endif
+{
+   U8          hashKey;      /* Computed Hash Key */
+   CmLListCp   *datQ;        /* Pointer to the ListCP */
+   PjTxEnt     *delEnt;      /* Loop Var - pointer to PjTxEnt */
+
+   TRC3(pjDbmDelTxEnt)
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
+            "pjDbmDelTxEnt(buf,  count(%ld)\n", count));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
+            "pjDbmDelTxEnt(buf,  count(%d)\n", count));
+#endif
+
+   /* search for the entry */
+   delEnt   =  pjDbmGetTxEnt(gCb, buf, count);
+   if(delEnt == NULLP)
+   {
+      RETVALUE(RFAILED);
+   }
+
+   /* Compute the hash index */
+   hashKey = (U8)PJ_HASH_FN(buf, delEnt->count); /*KW_FIX*/
+   datQ  =  &buf->datQ[hashKey];
+
+   /* delete the entry */
+   cmLListDelFrm(datQ, &delEnt->lstEnt);
+
+   if (delEnt->sduSubmitEnt.node != NULLP)
+   {
+      delEnt->sduSubmitEnt.node = NULLP;
+      cmLListDelFrm(&buf->sduSubmitQ,&delEnt->sduSubmitEnt);
+   }
+   if(delEnt->datCfmEnt.node != NULLP)
+   {
+      delEnt->datCfmEnt.node = NULLP;
+      cmLListDelFrm(&buf->datCfmQ, &delEnt->datCfmEnt);
+      pjTotDlPckCntPerCell--;
+   }
+
+   if(delEnt->reEstPktEnt.node != NULLP)
+   {
+      delEnt->reEstPktEnt.node = NULLP;
+      cmLListDelFrm(&buf->reEstPktQ, &delEnt->reEstPktEnt);
+   }
+   /* NULLing off to prevent double dealloc */
+   if(delEnt->pdu == delEnt->sdu)
+   {
+      delEnt->pdu =  NULLP;
+   }
+/* ccpu00136902 */
+   pjCiphStateChek(gCb, delEnt);
+   buf->numEntries --;
+
+   RETVALUE(ROK);
+} /* pjDbmDelTxEnt */
+
+\f
+/**
+ *
+ * @brief Handler to Delete all the elements in the hashlist
+ *       
+ *
+ * @b Description
+ *        This function is invoked to Delete all the elements in the
+ *        hash List
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmTxDelAll
+(
+PjCb  *gCb,
+PjBuf *buf        /* !< Tx Buffer  */                     
+)
+#else
+PUBLIC S16 pjDbmTxDelAll(gCb,buf)
+PjCb  *gCb;
+PjBuf *buf;       /* !< Tx Buffer  */                     
+#endif
+{
+   U8         i;         /* index counter */
+   CmLListCp *datQ;      /* CmLListcp Ptr */
+   CmLList   *lstEnt;   /* CmLList Ptr - Loop var */
+   PjTxEnt   *txEnt;     /* Tx Entry Ptr - Loop var */
+
+   TRC3(pjDbmTxDelAll);
+
+   RLOG0(L_DEBUG, "pjDbmTxDelAll(buf)");
+
+   /* cleanup the entries */
+   for(i = 0; i< buf->numBins; i++)
+   {
+      datQ = &buf->datQ[i];
+      while(cmLListFirst(datQ))
+      {
+         lstEnt = cmLListDelFrm(datQ, cmLListCrnt(datQ));
+         if(lstEnt != NULLP)
+         {
+            txEnt =  (PjTxEnt *)cmLListNode(lstEnt);
+            if(txEnt->datCfmEnt.node != NULLP)
+            {
+               txEnt->datCfmEnt.node = NULLP;
+               cmLListDelFrm(&buf->datCfmQ, &txEnt->datCfmEnt);
+               pjTotDlPckCntPerCell--;
+            }
+
+            if (txEnt->sduSubmitEnt.node != NULLP)
+            {
+               txEnt->sduSubmitEnt.node = NULLP;
+               cmLListDelFrm(&buf->sduSubmitQ,&txEnt->sduSubmitEnt);
+            }
+
+            if(txEnt->reEstPktEnt.node != NULLP)
+            {
+               txEnt->reEstPktEnt.node = NULLP;
+               cmLListDelFrm(&buf->reEstPktQ, &txEnt->reEstPktEnt);
+            }
+
+            if ( txEnt->sdu == txEnt->pdu )
+            {
+               txEnt->sdu = NULLP;
+            }
+            /* ccpu00136902 */
+            pjCiphStateChek(gCb, txEnt);
+         }
+      }
+      cmLListInit(datQ);
+   }
+
+   RETVALUE(ROK);
+} /* pjDbmTxDelAll */
+\f
+/**
+ *
+ * @brief Handler to De initialize hash list
+ *       
+ *
+ * @b Description
+ *        This function is invoked by LMM to De initialize the 
+ *        hash List
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmTxDeInit
+(
+PjCb  *gCb,
+PjBuf *buf        /* !< Tx Buffer  */                     
+)
+#else
+PUBLIC S16 pjDbmTxDeInit(gCb,buf)
+PjCb  *gCb;
+PjBuf *buf;       /* !< Tx Buffer  */                     
+#endif
+{
+
+   TRC3(pjDbmTxDeInit);
+
+   RLOG0(L_DEBUG, "pjDbmTxDeInit(buf)");
+
+   /* cleanup the entries */
+   pjDbmTxDelAll(gCb,buf);
+   
+   /* Cleanup the listCps */
+   PJ_FREE(gCb, buf->datQ, (sizeof(CmLListCp) * buf->numBins));
+   buf->numBins   =  NULLP;
+
+   RETVALUE(ROK);
+} /* pjDbmDeInit */
+
+
+\f
+/**
+ *
+ * @brief Handler to initialize hash list
+ *       
+ *
+ * @b Description
+ *        This function is invoked by LMM to initialize the UeCb and CellCb
+ *        hash List
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmDlInit  
+(
+PjCb *gCb
+)
+#else
+PUBLIC S16 pjDbmDlInit(gCb)
+PjCb *gCb;
+#endif
+{
+   S16      ret;              /* Return Value */
+
+   TRC3(pjDbmDlInit)
+
+#ifdef DEBUGP
+   RLOG0(L_DEBUG, "pjDbmInit()");
+#endif
+
+   /* Initialize ueCb Hash List */
+   ret = cmHashListInit(&(gCb->u.dlCb->ueLstCp), (U16) PJ_UE_LIST_BUCKET_SIZE,
+         (U16) 0, (Bool) FALSE, (U16) CM_HASH_KEYTYPE_DEF,
+         gCb->init.region, gCb->init.pool);
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG0(L_DEBUG, "pjDbmInit: cmHashListInit Failed for gCb.ueLstCp.");
+#endif
+      RETVALUE(ret);
+   }
+
+   RETVALUE(ROK);
+} /* pjDbmInit */
+
+\f
+/**
+ *
+ * @brief Handler to De initialize hash list
+ *       
+ *
+ * @b Description
+ *        This function is invoked by LMM to De initialize the UeCb and CellCb
+ *        hash List
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmDlDeInit
+(
+PjCb *gCb
+)
+#else
+PUBLIC S16 pjDbmDlDeInit(gCb)
+PjCb *gCb;
+#endif
+{
+   S16      ret;                       /* Return Value */
+
+   TRC3(pjDbmDlDeInit);
+
+#ifdef DEBUGP
+   RLOG0(L_DEBUG, "pjDbmDeInit()");
+#endif
+
+   /* Initialize ueCb Hash List */
+   ret = cmHashListDeinit(&(gCb->u.dlCb->ueLstCp));
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG0(L_ERROR, "pjDbmDeInit: cmHashListDeinit Failed for gCb.ueLstCp.");
+#endif
+      RETVALUE(ret);
+   }
+   RETVALUE(ROK);
+} /* pjDbmDeInit */
+
+\f
+/**
+ *
+ * @brief Handler to fetch rbCb in the Upper Interface
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to fetch rbCb from the cellCb/ueCb in
+ *        the upper interface (CPJ/PJU).
+ *
+ *  @param[in]    rlcId    RLC Identifier 
+ *  @param[out]   rbCb     RB Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmFetchDlRbCb
+(
+PjCb           *gCb,
+CmLteRlcId     rlcId,      /* RLC Identifier */
+PjDlRbCb       **rbCb       /* RB Cb */
+)
+#else
+PUBLIC S16 pjDbmFetchDlRbCb(gCb, rlcId, rbCb)
+PjCb           *gCb;
+CmLteRlcId     rlcId;      /* RLC Identifier */
+PjDlRbCb         **rbCb;      /* RB Cb */
+#endif
+{
+   PjDlUeCb      *ueCb;                  /* UE Control Block */
+   PjDlRbCb        *tRbCb;                 /* Local RB CB */
+   S16         ret;                    /* Return Value */
+
+   TRC3(pjDbmFetchDlRbCb)
+
+#ifdef DEBUGP
+   RLOG3(L_DEBUG, "pjDbmFetchRbCbForLi(rlcId(ueId(%d), cellId(%d), rbId(%d)),   rbCb)",
+             rlcId.ueId, rlcId.cellId, rlcId.rbId);
+#endif
+
+   ueCb = NULLP;
+   ret = ROK;
+
+   /* Validate the RBID in case of TM/UM/AM */
+   PJ_VALIDATE_RBID(rlcId.ueId, rlcId.rbId, rlcId.rbType, ret);
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      /* DEBUG_PRINT EROR */
+      RLOG_ARG2(L_ERROR,DBG_UEID,rlcId.ueId, 
+            "PJ_VALIDATE_RBID Failed -- rbId(%d), cellId(%d)",
+               rlcId.rbId, rlcId.cellId);
+
+#endif
+      RETVALUE(ret);
+   }
+   if (pjDbmFetchDlUeCb(gCb, rlcId.ueId, rlcId.cellId, &ueCb) != ROK)
+   {
+         RLOG_ARG1(L_ERROR, DBG_CELLID, rlcId.cellId,"UeId[%u] not found",
+            rlcId.ueId);
+         RETVALUE(RFAILED);
+
+   }
+
+   PJ_DBM_FETCH_DL_RBCB(rlcId.rbId, rlcId.rbType, ueCb, tRbCb);
+
+   if (tRbCb == NULLP)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:RbId[%d] not found",
+            rlcId.cellId, rlcId.rbId);
+      RETVALUE(RFAILED);
+   }
+
+   *rbCb = tRbCb;
+
+   RETVALUE(ROK);
+} /* pjDbmFetchRbCb */
+
+\f
+/**
+ *
+ * @brief Handler to delete RbCb
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to remove RbCb from Ue/Cell hashlist 
+ *
+ *
+ *  @param[in] rbCbLst   - Rb Cb List
+ *  @param[in] numRbCb   - Number of rbCbs
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmDelAllDlRb
+(
+PjCb             *gCb,
+PjDlRbCb         **rbCbLst,              /* RB Cb list */
+U8             numRbCb                 /* Number of rbCbs */
+)
+#else
+PUBLIC S16 pjDbmDelAllDlRb(gCb,rbCbLst, numRbCb)
+PjCb             *gCb;
+PjDlRbCb         **rbCbLst;              /* RB Cb list */
+U8             numRbCb;                /* Number of rbCbs */
+#endif
+{
+   U8          idx;                    /* Index */
+   PjDlRbCb        *rbCb;                  /* RB Control Block */
+
+   TRC3(pjDbmDelAllDlRb)
+
+#ifdef DEBUGP
+   RLOG1(L_DEBUG, "pjDbmDelAllRb(rbCbLst, numRbCb(%d))", numRbCb);
+#endif
+
+   for (idx = 0; idx < numRbCb; idx++)
+   {
+      rbCb = rbCbLst[idx];
+      if (rbCb != NULLP)
+      {
+         PJ_DBM_DELETE_DL_RBCB(gCb, rbCb);
+         rbCbLst[idx] = NULLP;
+      }
+   }
+
+   RETVALUE(ROK);
+} /* pjDbmDelAllRb */
+
+\f
+/**
+ *
+ * @brief Handler to create an UeCb
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to create UeCb and insert into the Ue hashlist 
+ *        of KwCb.
+ *
+ *
+ *  @param[in] ueId     UE Identifier 
+ *  @param[in] cellId   Cell Identifier 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmCreateDlUeCb
+(
+PjCb              *gCb,
+CmLteRnti         ueId,       /* UE Identifier */
+CmLteCellId       cellId,     /* Cell Identifier */
+PjDlUeCb            **ueCb       /* UE Control Block */
+)
+#else
+PUBLIC S16 pjDbmCreateDlUeCb(gCb, ueId, cellId, ueCb)
+PjCb              *gCb; 
+CmLteRnti         ueId;       /* UE Identifier */
+CmLteCellId       cellId;     /* Cell Identifier */
+PjDlUeCb            **ueCb;     /* UE Control Block */
+#endif
+{
+   S16      ret;              /* Return Value */
+   PjDlUeCb   *tUeCb;           /* UE Control Block */
+
+   TRC3(PjDbmCreateDlUeCb)
+
+#ifdef DEBUGP
+   RLOG2(L_DEBUG, "pjDbmCreateUeCb(ueId(%d), cellId(%d))", ueId, cellId);
+#endif
+
+   PJ_ALLOC(gCb, *ueCb, sizeof(PjDlUeCb));
+
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if (*ueCb == NULLP)
+   {
+      ret = RFAILED;
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(ret);
+   }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+
+   tUeCb = *ueCb;
+   tUeCb->key.ueId = ueId;
+   tUeCb->key.cellId = cellId;
+
+   ret = cmHashListInsert(&(gCb->u.dlCb->ueLstCp), (PTR)tUeCb, (U8 *)&(tUeCb->key),
+         (U16) sizeof(PjUeKey));
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG_ARG1(L_ERROR,DBG_UEID,ueId, 
+            "DL UE CB Hash Insert Failed for cellId (%d)", cellId);
+#endif
+      RETVALUE(ret);
+   }
+
+   /* kw005.201 ccpu00117318, updating the statistics */
+   gCb->u.dlCb->pjGenSts.numUe++;
+   (*ueCb)->libInfo.state =  PJ_STATE_NORMAL;
+   cmInitTimers(&((*ueCb)->libInfo.obdTmr), 1);
+   RETVALUE(ret);
+} /* kwDbmCreateUeCb */
+
+\f
+/**
+ *
+ * @brief Handler to Fetch an UeCb
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to fetch UeCb from the Ue hashlist 
+ *        of KwCb.
+ *
+ *
+ *  @param[in]    ueId     UE Identifier 
+ *  @param[in]    cellId   Cell Identifier 
+ *  @param[out]   ueCb     UE Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmFetchDlUeCb
+(
+PjCb              *gCb,
+CmLteRnti         ueId,       /* UE Identifier */
+CmLteCellId       cellId,     /* Cell Identifier */
+PjDlUeCb            **ueCb       /* UE Control Block */
+)
+#else
+PUBLIC S16 pjDbmFetchDlUeCb(gCb, ueId, cellId, ueCb)
+PjCb              *gCb;
+CmLteRnti         ueId;       /* UE Identifier */
+CmLteCellId       cellId;     /* Cell Identifier */
+PjDlUeCb            **ueCb;      /* UE Control Block */
+#endif
+{
+   S16      ret;              /* Return Value */
+   PjUeKey  key;              /* Key for UE Hash List */
+
+   TRC3(pjDbmFetchDlUeCb)
+
+
+   key.ueId = ueId;
+   key.cellId = cellId;
+
+   ret = cmHashListFind(&(gCb->u.dlCb->ueLstCp), (U8 *)&(key), sizeof(PjUeKey),
+         PJ_DEF_SEQ_NUM, (PTR *) ueCb);
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG_ARG0(L_WARNING,DBG_UEID,ueId, 
+            "pjDbmFetchUeCb: cmHashListFind Failed for ueCb.");
+#endif
+      RETVALUE(ret);
+   }
+
+   RETVALUE(ROK);
+} /* pjDbmFetchUeCb */
+
+\f
+/**
+ *
+ * @brief Handler to delete an UeCb
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to delete UeCb from the Ue hashlist 
+ *        of KwCb.
+ *
+ *
+ *  @param[in] ueCb     UE Control Block
+ *  @param[in] abrtFlag Abort Flag
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmDelDlUeCb
+(
+PjCb        *gCb,
+PjDlUeCb      *ueCb,       /* UE Identifier */
+Bool        abortFlag    /* Abort Flag */
+)
+#else
+PUBLIC S16 pjDbmDelDlUeCb(gCb, ueCb, abortFlag)
+PjCb        *gCb;
+PjDlUeCb      *ueCb;       /* UE Identifier */
+Bool        abortFlag;   /* Abort Flag */
+#endif
+{
+   S16         ret;      /* Return Value */
+   U8          idx;      /* Index */
+
+   TRC3(pjDbmDelDlUeCb)
+
+#ifdef DEBUGP
+   RLOG2(L_DEBUG, "pjDbmDelUeCb(ueId(%d), cellId(%d))",
+            ueCb->key.ueId, ueCb->key.cellId);
+#endif
+
+/* kw005.201 Check to see if there is atleast one logical channel */
+
+   for ( idx = 0; idx< PJ_MAX_SRB_PER_UE; idx++)
+       pjCfgDelPjDlRbCb(gCb, ueCb, ueCb->srbCb[idx]);
+
+   for ( idx = 0; idx< PJ_MAX_DRB_PER_UE; idx++) 
+       pjCfgDelPjDlRbCb(gCb, ueCb, ueCb->drbCb[idx]);
+
+   /* Close the Integrity/Ciphering channels */
+   if(ueCb->secInfo.secAct)
+   {
+#ifdef INTEL_QAT_DP
+      pjUtlDlIntClose(gCb,ueCb->secInfo.cpIntSessCxtId);
+      pjUtlDlCipherClose(gCb,ueCb->secInfo.cpCiphSessCxtId);
+      pjUtlDlCipherClose(gCb,ueCb->secInfo.upCiphSessCxtId);
+#else
+      pjUtlDlIntClose(gCb,ueCb->secInfo.intCxtId);
+      pjUtlDlCipherClose(gCb,ueCb->secInfo.cpCxtId);
+      pjUtlDlCipherClose(gCb,ueCb->secInfo.upCxtId);
+#endif
+   }
+
+   /* Delete hoInfo if present */
+   if (ueCb->hoInfo != NULLP)
+   {
+      for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++)
+      {
+         if (ueCb->hoInfo->hoCfmInfo[idx].pres == TRUE)
+         { /* should these be dl? */
+   
+         }
+      }
+
+      PJ_FREE(gCb, ueCb->hoInfo->hoCfmInfo, (PJ_MAX_DRB_PER_UE * sizeof(PjDlHoCfmInfo)));
+      PJ_FREE(gCb, ueCb->hoInfo, sizeof(PjDlHoInfo));  
+   }
+
+   /* Delete ueCb entry from ueLstCp */
+   ret = cmHashListDelete(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb); 
+   if (ret != ROK)
+   {
+
+#ifdef DEBUGP
+      RLOG_ARG0(L_ERROR,DBG_UEID,ueCb->key.ueId,"Hash Delete Failed for ueCb");
+#endif
+   }
+   /* kw005.201 ccpu00117318, updating the statistics */
+   gCb->pjGenSts.numUe--; 
+   /* Deallocate ueCb */
+   PJ_FREE(gCb, ueCb, sizeof(PjDlUeCb));
+
+   RETVALUE(ret);
+} /* pjDbmDelUeCb */
+
+\f
+/**
+ *
+ * @brief Handler to delete all UeCbs
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to delete all UeCbs from the Ue
+ *        hashlist of KwCb.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 PjDbmDelAllDlUe
+(
+PjCb  *gCb
+)
+#else
+PUBLIC S16 PjDbmDelAllDlUe(gCb)
+PjCb  *gCb;
+#endif
+{
+   S16         ret;
+   PjDlUeCb      *ueCb;            /* UE Control Block */
+
+   TRC3(pjDbmDelAllDlUe)
+
+#ifdef DEBUGP
+   RLOG0(L_DEBUG, "pjDbmDelAllUe()");
+#endif
+
+   ret = ROK;
+   ueCb = NULLP;
+
+   /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
+   while (cmHashListGetNext(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb, (PTR *)&ueCb) == ROK)
+   {
+      /* Delete ueCb */
+      ret = pjDbmDelDlUeCb(gCb,ueCb, TRUE);
+      if (ret != ROK)
+      {
+#ifdef DEBUGP
+         RLOG_ARG0(L_ERROR,DBG_UEID,ueCb->key.ueId,"DL Ue Cb Deletion Failed");
+#endif
+         RETVALUE(ret);
+      }
+      ueCb = NULLP;
+   }
+
+   RETVALUE(ret);
+} /* pjDbmDelAllUe */
+
+#ifdef ANSI
+PUBLIC S16 pjDbmDlShutdown 
+(
+PjCb *gCb
+)
+#else
+PUBLIC S16 pjDbmDlShutdown(gCb)
+PjCb *gCb;
+#endif
+{
+#if (ERRCLASS & ERRCLS_DEBUG)
+    S16 ret;
+#endif
+   TRC3(pjDbmDlShutdown)
+
+#if (ERRCLASS & ERRCLS_DEBUG)
+   ret = pjDbmDlDeInit(gCb);
+   if (ret != ROK)
+   {
+      RLOG0(L_FATAL, "DL DeInitialization Failed");
+   }
+#else
+   pjDbmDlDeInit(gCb);
+#endif /* ERRCLASS & ERRCLS_DEBUG */
+
+   RETVALUE(ROK);
+} /* pjDbmShutdown */
+
+/**
+ *
+ * @brief Handler to create a RB control block.
+ *       
+ *
+ * @b Description
+ *        This function is called to create a RLC control block or PDCP 
+ *        control block based on rb flag and update the pointers in RbCb.
+ *        If the RbCb is already allocated, the rbId is updated in KwRbCb
+ *        or PjDlRbCb based on rb. If the RbCb has not been allocated earlier,
+ *        a new RbCb is created and the pointers are updated along with the
+ *        rbIds.
+ *
+ *  @param[in] rbId      RB ID of the entity
+ *  @param[in] rbCbLst   List of the RBs in the UeCb
+ *  @param[in] rb        The RB to be created. This can be
+ *                       PJ_CFG_PDCP when PDCP is created
+ *                       or PJ_CFG_RLC when RLC is being
+ *                       created. 
+ *  
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC PjDlRbCb* pjDbmCreateDlRbCb
+(
+PjCb    *gCb,
+U8      rbId,
+U8      rbType, 
+PjDlUeCb  *ueCb, 
+U8      rb
+)
+#else
+PUBLIC PjDlRbCb* pjDbmCreateDlRbCb(gCb,rbId,rbType,ueCb,rb)
+PjCb    *gCb;
+U8      rbId; 
+U8      rbType;
+PjDlUeCb  *ueCb; 
+U8      rb;
+#endif
+{
+   PjDlRbCb   *rbCb;
+   PjDlRbCb   **rbCbLst;
+
+   TRC2(pjDbmCreateDlRbCb)
+
+   rbCb = NULLP;
+   rbCbLst = NULLP;
+
+   PJ_DBM_FETCH_DL_RBCB(rbId, rbType, ueCb, rbCb);
+
+   if(rbCb == NULLP)
+   {
+      PJ_ALLOC(gCb, rbCb, sizeof(PjDlRbCb));
+      if ( rbCb == NULLP )
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         RETVALUE(rbCb);
+      }
+   }
+
+   rbCb->rbId   = rbId;
+   rbCb->rbType = rbType;
+
+   rbCbLst = ((rbType == CM_LTE_SRB)? ueCb->srbCb:ueCb->drbCb); 
+   rbCbLst[rbId] = rbCb;
+   /* kw005.201 ccpu00117318, updating the statistics */   
+   PJ_LMM_RB_STS_INC(gCb);                                    
+   
+   RETVALUE(rbCb); 
+   
+} /* pjDbmCreateRbCb */
+
+/**
+ *
+ * @brief Handler to fetch a  PDCP RB control block.
+ *       
+ *
+ * @b Description
+ *        This function is used to fetch the PDCP RB control block based on 
+ *        the RB id. The pointer to PjDlRbCb is returned.
+ *       
+ *  @param[in]  ueCb    UE control block of the PDCP RB
+ *  @param[in]  rbId    RB ID of the required PDCP entity.
+ *  @param[out] pjRbCb  PDCP RB Control Block.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjDbmFetchPjDlRbCb
+(
+PjDlUeCb  *ueCb,
+U8       rbId,
+U8       rbType,
+PjDlRbCb  **pjRbCb 
+)
+#else
+PUBLIC S16 pjDbmFetchPjDlRbCb(ueCb,rbId,rbType,pjRbCb)
+PjDlUeCb  *ueCb;      
+U8       rbId;
+U8       rbType;
+PjDlRbCb  **pjRbCb;
+#endif
+{
+   PjDlRbCb    *rbCb;
+
+   TRC2(PjDbmFetchPjDlRbCb)
+
+   *pjRbCb = NULLP;
+
+   PJ_DBM_FETCH_DL_RBCB(rbId, rbType, ueCb, rbCb);
+   if ( rbCb != NULLP )
+   {
+      *pjRbCb = rbCb;
+   }
+
+   RETVALUE(ROK);
+
+} /* pjDbmFetchPjDlRbCb */
+
+/**
+ *
+ * @brief Handler to delete a PDCP/RLC RB control block.
+ *       
+ *
+ * @b Description
+ *        This function is used to delete the PDCP/RLC RB control block based 
+ *        on RB id and the RB type (PDCP/RLC). If the corresponding RB is 
+ *        present, the cfgStat flag is unset. If the cfgStat flag is zero,
+ *        the RBCB is freed.
+ *
+ *  @param[in]  rbId    RB ID of the to be deleted RB
+ *  @param[in]  rbCbLst RbCb list in UE CB
+ *  @param[in]  rb      The RB to be deleted. This can be
+ *                      PJ_CFG_PDCP when PDCP is created
+ *                      or PJ_CFG_RLC when RLC is being
+ *                      created.
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjDbmDelDlRbCb
+(
+PjCb   *gCb,
+U8      rbId,
+U8      rbType,
+PjDlRbCb   **rbCb, 
+U8      rb,
+PjDlUeCb  *ueCb
+)
+#else
+PUBLIC S16 pjDbmDelDlRbCb(gCb,rbId,rbType,rbCb,rb,ueCb)
+PjCb   *gCb;
+U8      rbId;
+U8      rbType;
+PjDlRbCb   **rbCb;
+U8      rb;
+PjDlUeCb  *ueCb;
+#endif
+{
+   S16      ret;
+   PjDlRbCb   **rbCbLst;
+   rbCbLst = NULLP;
+   
+   TRC2(pjDbmDelDlRbCb)
+
+   ret   = RFAILED;
+   /*updating rbCbList */
+   rbCbLst = ((rbType == CM_LTE_SRB)? ueCb->srbCb:ueCb->drbCb);
+
+   if ( (*rbCb) != NULLP )
+   {
+      PJ_DBM_DELETE_DL_RBCB(gCb,*rbCb);
+      ret = ROK;
+      /*updating rbCbList */
+      rbCbLst[rbId] = NULLP;
+   }
+   RETVALUE(ret);
+
+} /* pjDbmDelRbCb */
+
+
+
+
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_dbm_ul.c b/src/5gnrpdcp/pj_dbm_ul.c
new file mode 100755 (executable)
index 0000000..27e70ab
--- /dev/null
@@ -0,0 +1,1479 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    PDCP - Database module file
+    
+        Type:    C source file
+  
+        Desc:    Source code for Database Module functions such as, 
+
+                  -  pjDbmBufInit
+                  -  pjDbmInsTxEnt
+                  -  pjDbmGetTxEnt
+                  -  pjDbmGetTxEntSn
+                  -  pjDbmDelTxEnt
+                  -  pjDbmTxDeInit
+                  -  pjDbmInsRxEnt
+                  -  pjDbmGetRxEnt
+                  -  pjDbmDelRxEnt
+                  -  pjDbmRxDeInit
+
+        File:    pj_dbm_ul.c
+  
+*********************************************************************21*/
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=216;
+
+\f
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"                /* general */
+#include "ssi.h"                /* system services interface */
+#include "cm5.h"                /* Timer Functions */
+#include "cm_lte.h"             /* common LTE header file */
+#include "cm_hash.h"            /* common hash module  file */
+#include "cm_llist.h"           /* common list header file */
+#include "cpj.h"                /* RRC layer */
+#include "pju.h"                /* PDCP service user */
+#include "lpj.h"                /* RRC layer */
+#include "pj_env.h"             /* RLC environment options */
+#include "pj.h"                 /* RLC layer */
+#include "pj_ul.h"                 /* RLC layer */
+#include "pj_err.h"
+/* extern (.x) include files */
+#include "gen.x"                /* general */
+#include "ssi.x"                /* system services interface */
+#include "cm_lib.x"             /* common library */
+#include "cm5.x"                /* Timer Functions */
+#include "cm_hash.x"            /* common hash module */
+#include "cm_lte.x"             /* common LTE file */
+#include "cm_llist.x"           /* common list header file */
+#include "cpj.x"                /* RRC layer */
+#include "pju.x"                /* PDCP service user */
+#include "lpj.x"                /* LM Interface */
+#include "pj.x"                 /* RLC layer */
+#include "pj_udx.h"
+#include "pj_udx.x"
+#include "pj_dl.x"
+#include "pj_ul.x"
+
+\f
+/* local defines */
+
+/* local externs */
+
+/* forward references */
+
+/* public variable declarations */
+PUBLIC S16 pjDeciphStateChek ARGS ((PjCb *gCb, PjRxEnt *delEnt));
+/* This structure holds all the global structs we need. */
+
+/* private variable declarations */
+
+/* private function declarations */
+
+/** @file gp_pj_dbm.c
+@brief PDCP DBM Module
+**/
+
+/*****************************************************************************
+ *                  HANDLER FOR THE TRANSMISSION BUFFER
+ ****************************************************************************/
+
+/*****************************************************************************
+ *                  HANDLERS FOR THE RECEPTION BUFFER
+ ****************************************************************************/
+\f
+/**
+ * @brief Handler to insert packets In-Sequence into RX Buffer
+ *
+ *
+ */
+#ifdef ANSI
+PRIVATE S16 pjDbmInsInSeqRxEnt
+(
+PjBuf       *buf,          /* !< Rx Buffer  */
+PjRxEnt     *rxEnt         /* !< Rx Entry   */              
+)
+#else
+PRIVATE S16 pjDbmInsInSeqRxEnt(buf, rxEnt)
+PjBuf       *buf;
+PjRxEnt     *rxEnt;
+#endif
+{
+
+   PjRxEnt     *tmpEnt = NULLP;
+
+   tmpEnt = (PjRxEnt *) cmLListNode(cmLListFirst(&buf->datPktQ));
+   if((rxEnt->count) < (tmpEnt->count))
+   {         
+      rxEnt->datPktEnt.node = (PTR) rxEnt;
+      cmLListInsCrnt(&buf->datPktQ, &rxEnt->datPktEnt);
+   }
+   else
+   {
+      tmpEnt = (PjRxEnt *) cmLListNode(cmLListLast(&buf->datPktQ));
+      while((rxEnt->count) < (tmpEnt->count))
+      {
+         cmLListPrev(&buf->datPktQ);
+         tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&buf->datPktQ));
+      }
+      rxEnt->datPktEnt.node = (PTR) rxEnt;
+      cmLListInsAfterCrnt(&buf->datPktQ, &rxEnt->datPktEnt);
+   }
+   RETVALUE(ROK);
+}
+
+
+\f
+/**
+ *
+ * @brief Handler to insert into a RX Buffer
+ *
+ * @b Description
+ *        This function is invoked by to insert into
+ *         the reception buffer hash List
+ *
+ *  @param[in]  buf      Rx Buffer 
+ *  @param[in]  rxEnt    Reception Entry
+ *  @param[in]  dupFlag  Search for duplicates(Should be TRUE for AM)
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmInsRxEnt
+(
+PjCb        *gCb,
+PjBuf       *buf,          /* !< Rx Buffer  */
+PjRxEnt     *rxEnt,        /* !< Rx Entry   */              
+Bool        dupFlag        /* !< Boolean to check for duplicate  entries */
+)
+#else
+PUBLIC S16 pjDbmInsRxEnt(gCb, buf, rxEnt, dupFlag)
+PjCb        *gCb;
+PjBuf       *buf;          /* !< Rx Buffer  */
+PjRxEnt     *rxEnt;        /* !< Rx Entry   */                              
+Bool        dupFlag;       /* !< Boolean to check for duplicate  entries */ 
+#endif
+{
+   U8       hashKey;          /* Computed hash key */
+   PjRxEnt  *tmpEnt = NULLP;  /* Rx Entry Ptr */
+
+   TRC3(pjDbmInsRxEnt)
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
+            "pjDbmInsRxEnt buf, rxEnt(%ld), dupFlag(%d)\n",\
+            rxEnt->count, dupFlag));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
+            "pjDbmInsRxEnt buf, rxEnt(%d), dupFlag(%d)\n",\
+            rxEnt->count, dupFlag));
+#endif
+
+   if(dupFlag)
+   {
+      /* Search for duplicates */
+      tmpEnt = pjDbmGetRxEnt(gCb, buf, rxEnt->count);
+      if(tmpEnt != NULLP)
+      {
+         RETVALUE(ROKDUP);
+      }
+   }
+
+   /* Compute the hash index */
+   hashKey = (U8)PJ_HASH_FN(buf, rxEnt->count);  /*KW_FIX*/
+
+   rxEnt->lstEnt.node   =  (PTR) rxEnt;
+   cmLListAdd2Tail(&buf->datQ[hashKey], &rxEnt->lstEnt);
+   buf->numEntries ++;
+
+   if(buf->datPktQ.count == 0)
+   {
+      rxEnt->datPktEnt.node = (PTR) rxEnt;
+      cmLListAdd2Tail(&buf->datPktQ, &rxEnt->datPktEnt);
+   }
+   else
+   {
+      pjDbmInsInSeqRxEnt(buf, rxEnt);
+   }
+
+   RETVALUE(ROK);
+} /* pjDbmRxBufIns */
+
+\f
+/**
+ *
+ * @brief Handler to fetch from a RX Buffer
+ *
+ * @b Description
+ *        This function is invoked to fetch an entry from
+ *         the transaction buffer hash List
+ *
+ *  @param[in]    buf         Rx Buffer 
+ *  @param[in]    count       Count value of the entry to retrieve
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC PjRxEnt* pjDbmGetRxEnt
+(
+PjCb   *gCb,
+PjBuf  *buf,       /* !< Rx Buffer  */                               
+U32    count       /* !< Count value of the entry to retrieve */                               
+)
+#else
+PUBLIC PjRxEnt* pjDbmGetRxEnt(gCb, buf, count)
+PjCb   *gCb;
+PjBuf  *buf;       /* !< Rx Buffer  */                               
+U32    count;      /* !< Count value of the entry to retrieve */   
+#endif
+{
+   U8         hashKey;   /* Computed hashKey */
+   CmLListCp *datQ;      /* Ptr to the CmLListCp */
+   PjRxEnt   *tmpEnt = NULLP;  /* Loop var - Rx Entr Ptr */
+
+   TRC3(pjDbmGetRxEnt)
+   /* Compute the hask key*/
+   hashKey = (U8)PJ_HASH_FN(buf, count); /*KW_FIX*/
+
+   datQ = &buf->datQ[hashKey];
+
+   /* Loop through and search */
+   cmLListFirst(datQ);
+   while(cmLListCrnt(datQ))
+   {
+      tmpEnt = (PjRxEnt *)cmLListNode(cmLListCrnt(datQ));
+      if((tmpEnt->count) == count)
+      {
+         RETVALUE(tmpEnt);
+      }
+      cmLListNext(datQ);
+   }
+   RETVALUE(NULLP);
+} /* pjDbmGetRxEnt */
+/**
+ *  @brief This fn is called to chek the state of the PDCP pkts in UL before Deciphering operation
+ *         and appropriate action is taken accordingly
+ *
+ *  @details
+ *      Function : pjDeciphStateChek
+ *
+ *  Processing Steps:
+ *
+ *
+ * @return  S16
+ *        -# Success : ROK
+ *        -# Failure : RFAILED
+*/
+
+/* ccpu00136902 */
+#if (defined (LTE_PAL_ENB) || defined (TENB_ACC))
+#ifdef ANSI
+PUBLIC S16 pjDeciphStateChek
+(
+PjCb        *gCb,
+PjRxEnt     *delEnt
+)
+#else
+PUBLIC S16 pjDeciphStateChek(gCb, delEnt)
+PjCb        *gCb;
+PjRxEnt     *delEnt;
+#endif
+{
+  TRC3(pjDeciphStateChek);
+  PJ_FREE_BUF(delEnt->mBuf);
+  PJ_FREE(gCb, delEnt, sizeof(PjRxEnt));
+  RETVALUE(ROK);
+}
+#endif
+
+\f
+/**
+ *
+ * @brief Handler to delete from a RX Buffer
+ *
+ * @b Description
+ *        This function is invoked by to delete from
+ *         the transaction buffer hash List
+ *
+ *  @param[in]    buf         Rx Buffer Control Point
+ *  @param[in]    count       Count value of the Rx Entry to delete
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmDelRxEnt
+(
+PjCb   *gCb,
+PjBuf  *buf,        /* !< Rx Buffer  */                                                          
+U32    count        /* !< Count value of the entry to retrieve */                                
+)
+#else
+PUBLIC S16 pjDbmDelRxEnt(gCb, buf, count)
+PjCb   *gCb;
+PjBuf  *buf;        /* !< Rx Buffer  */                                                          
+U32    count;       /* !< Count value of the entry to retrieve */                                
+#endif
+{
+   U8          hashKey;      /* Computed hash value */
+   CmLListCp   *datQ;        /* Pointer to the the ListCp */
+   PjRxEnt     *delEnt;      /* Loop var - entry to be deleted */
+
+   TRC3(pjDbmDelRxEnt)
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
+            "pjDbmDelRxEnt(buf, count(%ld)\n", count));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
+            "pjDbmDelRxEnt(buf, count(%d)\n", count));
+#endif
+
+   /* Get the node */
+   delEnt   =  pjDbmGetRxEnt(gCb, buf, count);
+
+   if(delEnt == NULLP)
+   {
+      RETVALUE(ROK);
+   }
+
+   hashKey = (U8)PJ_HASH_FN(buf, count); /*KW_FIX*/
+   datQ = &buf->datQ[hashKey];
+
+   /* delete the entity and free it*/
+   cmLListDelFrm(datQ, &delEnt->lstEnt);
+   if(delEnt->datPktEnt.node != NULLP)
+   {
+      cmLListDelFrm(&buf->datPktQ, &delEnt->datPktEnt);
+      delEnt->datPktEnt.node = NULLP;
+   }
+   /* ccpu00136902 */
+   pjDeciphStateChek(gCb, delEnt);
+   buf->numEntries --;
+
+   RETVALUE(ROK);
+} /* pjDbmDelRxEnt */
+
+\f
+/**
+ *
+ * @brief Handler to Delete all the elements in the hashlist
+ *       
+ *
+ * @b Description
+ *        This function is invoked by delete all the elements in th3
+ *        hash List
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmRxDelAll
+(
+PjCb  *gCb,
+PjBuf *buf        /* !< Rx Buffer  */                                                          
+)                 
+#else
+PUBLIC S16 pjDbmRxDelAll(gCb,buf)
+PjCb  *gCb;
+PjBuf *buf;       /* !< Rx Buffer  */                                                          
+#endif
+{
+   U8         listInd;   /* loop index */
+   CmLListCp *datQ;      /* CmLListCp Ptr */
+   CmLList   *lstEnt;   /* loop ptr to CmLlistEnt */
+   PjRxEnt   *delEnt;    /* loop ptr to entry to be deleted */
+
+   TRC3(pjDbmRxDelAll);
+
+   RLOG0(L_DEBUG, "pjDbmRxDelAll(buf)");
+
+   for(listInd = 0; listInd< buf->numBins; listInd++)
+   {
+      datQ = &buf->datQ[listInd];
+      while(cmLListFirst(datQ))
+      {
+         lstEnt = cmLListDelFrm(datQ, cmLListCrnt(datQ));
+         if(lstEnt != NULLP)
+         {
+            delEnt   =  (PjRxEnt *)cmLListNode(lstEnt);
+            if(delEnt->datPktEnt.node != NULLP)
+            {
+               cmLListDelFrm(&buf->datPktQ, &delEnt->datPktEnt);
+               delEnt->datPktEnt.node = NULLP;
+            }
+            /* ccpu00136902 */
+            pjDeciphStateChek(gCb, delEnt);
+         }
+      }
+      cmLListInit(datQ);
+   }
+
+   RETVALUE(ROK);
+} /* pjDbmRxDelAll */
+\f
+/**
+ *
+ * @brief Handler to De initialize hash list
+ *       
+ *
+ * @b Description
+ *        This function is invoked by LMM to De initialize the 
+ *        hash List
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmRxDeInit
+(
+PjCb  *gCb,
+PjBuf *buf        /* !< Rx Buffer  */                                                          
+)                 
+#else
+PUBLIC S16 pjDbmRxDeInit(gCb,buf)
+PjCb  *gCb;
+PjBuf *buf;       /* !< Rx Buffer  */                                                          
+#endif
+{
+
+   TRC3(pjDbmRxDeInit);
+
+   RLOG0(L_DEBUG, "pjDbmRxDeInit(buf)");
+
+   /* Cleanup all entries */
+   pjDbmRxDelAll(gCb,buf);
+
+   /* Cleanup hashlist */
+   PJ_FREE(gCb, buf->datQ, (sizeof(CmLListCp) * buf->numBins));
+   buf->numBins   =  NULLP;
+
+   RETVALUE(ROK);
+} /* pjDbmDeInit */
+
+\f
+/**
+ *
+ * @brief Handler to initialize hash list
+ *       
+ *
+ * @b Description
+ *        This function is invoked by LMM to initialize the UeCb and CellCb
+ *        hash List
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmUlInit  
+(
+PjCb *gCb
+)
+#else
+PUBLIC S16 pjDbmUlInit(gCb)
+PjCb *gCb;
+#endif
+{
+   S16      ret;              /* Return Value */
+
+   TRC3(pjDbmUlInit)
+
+#ifdef DEBUGP
+   RLOG0(L_DEBUG, "pjDbmInit()");
+#endif
+
+   /* Initialize ueCb Hash List */
+   ret = cmHashListInit(&(gCb->u.ulCb->ueLstCp), (U16) PJ_UE_LIST_BUCKET_SIZE,
+         (U16) 0, (Bool) FALSE, (U16) CM_HASH_KEYTYPE_DEF,
+         gCb->init.region, gCb->init.pool);
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG0(L_ERROR, "cmHashListInit Failed for gCb.ueLstCp.");
+#endif
+      RETVALUE(ret);
+   }
+
+   ret = cmHashListInit(&(gCb->u.ulCb->transIdLstCp), 
+                        (U16) PJ_TRANS_ID_LST_BKT_SIZE,
+         (U16) 0, (Bool) FALSE, (U16) CM_HASH_KEYTYPE_DEF,
+         PJ_GET_MEM_REGION(gCb), PJ_GET_MEM_POOL(gCb));
+   if (ret != ROK)
+   {
+      cmHashListDeinit(&gCb->u.ulCb->ueLstCp);
+#ifdef DEBUGP
+      RLOG0(L_ERROR, "cmHashListInit Failed for pjCb.transIdLstCp.");
+#endif
+   }
+
+
+   RETVALUE(ROK);
+} /* pjDbmInit */
+
+\f
+/**
+ *
+ * @brief Handler to De initialize hash list
+ *       
+ *
+ * @b Description
+ *        This function is invoked by LMM to De initialize the UeCb and CellCb
+ *        hash List
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmUlDeInit
+(
+PjCb *gCb
+)
+#else
+PUBLIC S16 pjDbmUlDeInit(gCb)
+PjCb *gCb;
+#endif
+{
+   S16      ret;                       /* Return Value */
+
+   TRC3(pjDbmUlDeInit);
+
+#ifdef DEBUGP
+   RLOG0(L_DEBUG, "pjDbmDeInit()");
+#endif
+
+   /* Initialize ueCb Hash List */
+   ret = cmHashListDeinit(&(gCb->u.ulCb->ueLstCp));
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG0(L_ERROR, "cmHashListDeinit Failed for gCb.ueLstCp.");
+#endif
+      RETVALUE(ret);
+   }
+   /* Initialize transId Hash List */
+   /*MEM_LEAK_FIX*/
+   ret = cmHashListDeinit(&(gCb->u.ulCb->transIdLstCp));
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG0(L_ERROR, "cmHashListDeinit Failed for gCb.transIdLstCp.");
+#endif
+      RETVALUE(ret);
+   }
+
+   ret = cmHashListDeinit(&(gCb->u.ulCb->transIdLstCp));
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG0(L_ERROR, "cmHashListDeinit Failed for gCb->u.ulCb->transIdLstCp");
+#endif
+      RETVALUE(ret);
+   }
+   RETVALUE(ROK);
+} /* pjDbmDeInit */
+
+\f
+/**
+ *
+ * @brief Handler to fetch rbCb in the Upper Interface
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to fetch rbCb from the cellCb/ueCb in
+ *        the upper interface (CPJ/PJU).
+ *
+ *  @param[in]    rlcId    RLC Identifier 
+ *  @param[out]   rbCb     RB Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmFetchUlRbCb
+(
+PjCb           *gCb,
+CmLteRlcId     rlcId,      /* RLC Identifier */
+PjUlRbCb       **rbCb       /* RB Cb */
+)
+#else
+PUBLIC S16 pjDbmFetchUlRbCb(gCb, rlcId, rbCb)
+PjCb           *gCb;
+CmLteRlcId     rlcId;      /* RLC Identifier */
+PjUlRbCb         **rbCb;      /* RB Cb */
+#endif
+{
+   PjUlUeCb      *ueCb;                  /* UE Control Block */
+   PjUlRbCb        *tRbCb;                 /* Local RB CB */
+   S16         ret;                    /* Return Value */
+
+   TRC3(pjDbmFetchUlRbCb)
+
+   ueCb = NULLP;
+   ret = ROK;
+
+   /* Validate the RBID in case of TM/UM/AM */
+   PJ_VALIDATE_RBID(rlcId.ueId, rlcId.rbId, rlcId.rbType, ret);
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      /* DEBUG_PRINT EROR */
+      RLOG_ARG2(L_ERROR,DBG_UEID,rlcId.ueId, 
+            "PJ_VALIDATE_RBID Failed rbId(%d), cellId(%d)",
+                       rlcId.rbId, rlcId.cellId);
+#endif
+      RETVALUE(ret);
+   }
+   if (pjDbmFetchUlUeCb(gCb, rlcId.ueId, rlcId.cellId, &ueCb) != ROK)
+   {
+#ifdef DEBUGP
+      RLOG_ARG0(L_ERROR,DBG_UEID,rlcId.ueId, "Failed to Fetch UE Cb");
+#endif
+      RETVALUE(RFAILED);
+   }
+   else
+   {
+      PJ_DBM_FETCH_UL_RBCB(rlcId.rbId, rlcId.rbType, ueCb, tRbCb);
+   }
+
+   if (tRbCb == NULLP)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:RbId[%d] not found",
+            rlcId.cellId, rlcId.rbId);
+      RETVALUE(RFAILED);
+   }
+
+   *rbCb = tRbCb;
+
+   RETVALUE(ROK);
+} /* pjDbmFetchRbCb */
+
+
+\f
+/**
+ *
+ * @brief Handler to delete RbCb
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to remove RbCb from Ue/Cell hashlist 
+ *
+ *
+ *  @param[in] rbCbLst   - Rb Cb List
+ *  @param[in] numRbCb   - Number of rbCbs
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmDelAllUlRb
+(
+PjCb             *gCb,
+PjUlRbCb         **rbCbLst,              /* RB Cb list */
+U8             numRbCb                 /* Number of rbCbs */
+)
+#else
+PUBLIC S16 pjDbmDelAllUlRb(gCb,rbCbLst, numRbCb)
+PjCb             *gCb;
+PjUlRbCb         **rbCbLst;              /* RB Cb list */
+U8             numRbCb;                /* Number of rbCbs */
+#endif
+{
+   U8          idx;                    /* Index */
+   PjUlRbCb        *rbCb;                  /* RB Control Block */
+
+   TRC3(pjDbmDelAllUlRb)
+
+#ifdef DEBUGP
+   RLOG1(L_DEBUG, "pjDbmDelAllRb(rbCbLst, numRbCb(%d))", numRbCb);
+#endif
+
+   for (idx = 0; idx < numRbCb; idx++)
+   {
+      rbCb = rbCbLst[idx];
+      if (rbCb != NULLP)
+      {
+         PJ_DBM_DELETE_UL_RBCB(gCb,rbCb);
+         rbCbLst[idx] = NULLP;
+      }
+   }
+
+   RETVALUE(ROK);
+} /* pjDbmDelAllRb */
+
+\f
+/**
+ *
+ * @brief Handler to create an UeCb
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to create UeCb and insert into the Ue hashlist 
+ *        of PjCb.
+ *
+ *
+ *  @param[in] ueId     UE Identifier 
+ *  @param[in] cellId   Cell Identifier 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmCreateUlUeCb
+(
+PjCb              *gCb,
+CmLteRnti         ueId,       /* UE Identifier */
+CmLteCellId       cellId,     /* Cell Identifier */
+PjUlUeCb            **ueCb       /* UE Control Block */
+)
+#else
+PUBLIC S16 pjDbmCreateUlUeCb(gCb, ueId, cellId, ueCb)
+PjCb              *gCb; 
+CmLteRnti         ueId;       /* UE Identifier */
+CmLteCellId       cellId;     /* Cell Identifier */
+PjUlUeCb            **ueCb;     /* UE Control Block */
+#endif
+{
+   S16      ret;              /* Return Value */
+   PjUlUeCb   *tUeCb;           /* UE Control Block */
+
+   TRC3(pjDbmCreateUlUeCb)
+
+#ifdef DEBUGP
+   RLOG2(L_DEBUG, "pjDbmCreateUeCb(ueId(%d), cellId(%d))", ueId, cellId);
+#endif
+
+   PJ_ALLOC(gCb, *ueCb, sizeof(PjUlUeCb));
+
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if (*ueCb == NULLP)
+   {
+      ret = RFAILED;
+      RLOG0(L_FATAL, "Memory Allocation failure");
+      RETVALUE(ret);
+   }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+
+   tUeCb = *ueCb;
+   tUeCb->key.ueId = ueId;
+   tUeCb->key.cellId = cellId;
+
+   ret = cmHashListInsert(&(gCb->u.ulCb->ueLstCp), (PTR)tUeCb, (U8 *)&(tUeCb->key),
+         (U16) sizeof(PjUeKey));
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG_ARG1(L_ERROR,DBG_UEID,ueId,"Ul UeCb Hash Insert Failed : cellId(%d)",
+                            cellId);
+#endif
+      RETVALUE(ret);
+   }
+
+   /* kw005.201 ccpu00117318, updating the statistics */
+   gCb->pjGenSts.numUe++;
+
+   (*ueCb)->libInfo.state =  PJ_STATE_NORMAL;
+   cmInitTimers(&((*ueCb)->libInfo.obdTmr), 1);
+   RETVALUE(ret);
+} /* kwDbmCreateUeCb */
+
+\f
+/**
+ *
+ * @brief Handler to Fetch an UeCb
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to fetch UeCb from the Ue hashlist 
+ *        of PjCb.
+ *
+ *
+ *  @param[in]    ueId     UE Identifier 
+ *  @param[in]    cellId   Cell Identifier 
+ *  @param[out]   ueCb     UE Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmFetchUlUeCb
+(
+PjCb              *gCb,
+CmLteRnti         ueId,       /* UE Identifier */
+CmLteCellId       cellId,     /* Cell Identifier */
+PjUlUeCb            **ueCb       /* UE Control Block */
+)
+#else
+PUBLIC S16 pjDbmFetchUlUeCb(gCb, ueId, cellId, ueCb)
+PjCb              *gCb;
+CmLteRnti         ueId;       /* UE Identifier */
+CmLteCellId       cellId;     /* Cell Identifier */
+PjUlUeCb            **ueCb;      /* UE Control Block */
+#endif
+{
+   S16      ret;              /* Return Value */
+   PjUeKey  key;              /* Key for UE Hash List */
+
+   TRC3(pjDbmFetchUlUeCb)
+
+
+   key.ueId = ueId;
+   key.cellId = cellId;
+
+   ret = cmHashListFind(&(gCb->u.ulCb->ueLstCp), (U8 *)&(key), sizeof(PjUeKey),
+         PJ_DEF_SEQ_NUM, (PTR *) ueCb);
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG_ARG0(L_INFO,DBG_UEID,ueId, "Hash Find Failed for fetching ueCb");
+#endif
+      RETVALUE(ret);
+   }
+
+   RETVALUE(ROK);
+} /* pjDbmFetchUeCb */
+
+\f
+/**
+ *
+ * @brief Handler to delete an UeCb
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to delete UeCb from the Ue hashlist 
+ *        of PjCb.
+ *
+ *
+ *  @param[in] ueCb     UE Control Block
+ *  @param[in] abrtFlag Abort Flag
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmDelUlUeCb
+(
+PjCb        *gCb,
+PjUlUeCb      *ueCb,       /* UE Identifier */
+Bool        abortFlag    /* Abort Flag */
+)
+#else
+PUBLIC S16 pjDbmDelUlUeCb(gCb, ueCb, abortFlag)
+PjCb        *gCb;
+PjUlUeCb      *ueCb;       /* UE Identifier */
+Bool        abortFlag;   /* Abort Flag */
+#endif
+{
+   S16         ret;      /* Return Value */
+   U8          idx;      /* Index */
+
+   TRC3(pjDbmDelUlUeCb)
+
+#ifdef DEBUGP
+   RLOG2(L_DEBUG, "pjDbmDelUeCb(ueId(%d), cellId(%d))",
+            ueCb->key.ueId, ueCb->key.cellId);
+#endif
+
+/* kw005.201 Check to see if there is atleast one logical channel */
+
+   for ( idx = 0; idx< PJ_MAX_SRB_PER_UE; idx++)
+       pjCfgDelPjUlRbCb(gCb, ueCb, ueCb->srbCb[idx]);
+
+   for ( idx = 0; idx< PJ_MAX_DRB_PER_UE; idx++) 
+       pjCfgDelPjUlRbCb(gCb, ueCb, ueCb->drbCb[idx]);
+
+   /* Close the Integrity/Ciphering channels */
+   if(ueCb->secInfo.secAct)
+   {
+#ifdef INTEL_QAT_DP
+      pjUtlUlIntClose(gCb,ueCb->secInfo.cpIntSessCxtId);
+      pjUtlUlCipherClose(gCb,ueCb->secInfo.cpCiphSessCxtId);
+      pjUtlUlCipherClose(gCb,ueCb->secInfo.upCiphSessCxtId);
+#else
+      pjUtlUlIntClose(gCb,ueCb->secInfo.intCxtId); 
+      pjUtlUlCipherClose(gCb,ueCb->secInfo.cpCxtId);
+      pjUtlUlCipherClose(gCb,ueCb->secInfo.upCxtId);
+#endif
+   }
+
+   /* Delete hoInfo if present */
+   if (ueCb->hoInfo != NULLP)
+   {
+      for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++)
+      {
+         if (ueCb->hoInfo->hoCfmInfo[idx].pres == TRUE)
+         {
+            PJ_FREE(gCb, ueCb->hoInfo->hoCfmInfo[idx].ulBitMap,
+                  (ueCb->hoInfo->hoCfmInfo[idx].numBits % 8)?
+                  ((ueCb->hoInfo->hoCfmInfo[idx].numBits / 8) + 1):
+                  (ueCb->hoInfo->hoCfmInfo[idx].numBits / 8 ));
+         }
+      }
+
+      PJ_FREE(gCb, ueCb->hoInfo->hoCfmInfo, 
+                 (PJ_MAX_DRB_PER_UE * sizeof(PjUlHoCfmInfo)));
+      PJ_FREE(gCb, ueCb->hoInfo, sizeof(PjUlHoInfo));  
+   }
+
+   /* Delete ueCb entry from ueLstCp */
+   ret = cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb);
+   if (ret != ROK)
+   {
+
+#ifdef DEBUGP
+      RLOG_ARG0(L_ERROR,DBG_UEID,ueCb->key.ueId, 
+            "Hash Delete Failed for deleting ueCb.");
+#endif
+   }
+   /* kw005.201 ccpu00117318, updating the statistics */
+   gCb->pjGenSts.numUe--;
+
+   /* Deallocate ueCb */
+   PJ_FREE(gCb, ueCb, sizeof(PjUlUeCb));
+
+   RETVALUE(ret);
+} /* pjDbmDelUeCb */
+
+\f
+/**
+ *
+ * @brief Handler to delete all UeCbs
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to delete all UeCbs from the Ue
+ *        hashlist of PjCb.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmDelAllUlUe
+(
+PjCb  *gCb
+)
+#else
+PUBLIC S16 pjDbmDelAllUlUe(gCb)
+PjCb  *gCb;
+#endif
+{
+   S16         ret;
+   PjUlUeCb      *ueCb;            /* UE Control Block */
+
+   TRC3(pjDbmDelAllUlUe)
+
+#ifdef DEBUGP
+   RLOG0(L_DEBUG, "pjDbmDelAllUe()");
+#endif
+
+   ret = ROK;
+   ueCb = NULLP;
+
+   /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
+   while (cmHashListGetNext(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb, (PTR *)&ueCb) == ROK)
+   {
+      /* Delete ueCb */
+      ret = pjDbmDelUlUeCb(gCb,ueCb, TRUE);
+      if (ret != ROK)
+      {
+#ifdef DEBUGP
+         RLOG_ARG0(L_ERROR,DBG_UEID,ueCb->key.ueId, "UE deletion Failed");
+#endif
+         RETVALUE(ret);
+      }
+      ueCb = NULLP;
+   }
+
+   RETVALUE(ret);
+} /* pjDbmDelAllUe */
+
+/**
+ *
+ * @brief Handler to Shutdown all UeCbs
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to shutdown UeCbs from the PjCb.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmUlShutdown 
+(
+PjCb *gCb
+)
+#else
+PUBLIC S16 pjDbmUlShutdown(gCb)
+PjCb *gCb;
+#endif
+{
+#if (ERRCLASS & ERRCLS_DEBUG)
+S16  ret
+#endif
+
+   TRC3(pjDbmUlShutdown)
+
+#if (ERRCLASS & ERRCLS_DEBUG)
+   ret = pjDbmUlDeInit(gCb);
+   if (ret != ROK)
+   {
+      RLOG0(L_FATAL, "UL DeInitialization Failed");
+   }
+#else
+   pjDbmUlDeInit(gCb);
+#endif /* ERRCLASS & ERRCLS_DEBUG */
+
+   RETVALUE(ROK);
+} /* pjDbmShutdown */
+
+/**
+ *
+ * @brief Handler to create a RB control block.
+ *       
+ *
+ * @b Description
+ *        This function is called to create a RLC control block or PDCP 
+ *        control block based on rb flag and update the pointers in RbCb.
+ *        If the RbCb is already allocated, the rbId is updated in PjRbCb
+ *        or PjUlRbCb based on rb. If the RbCb has not been allocated earlier,
+ *        a new RbCb is created and the pointers are updated along with the
+ *        rbIds.
+ *
+ *  @param[in] rbId      RB ID of the entity
+ *  @param[in] rbCbLst   List of the RBs in the UeCb
+ *  @param[in] rb        The RB to be created. This can be
+ *                       PJ_CFG_PDCP when PDCP is created
+ *                       or PJ_CFG_RLC when RLC is being
+ *                       created. 
+ *  
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC PjUlRbCb* pjDbmCreateUlRbCb
+(
+PjCb    *gCb,
+U8      rbId,
+U8      rbType, 
+PjUlUeCb  *ueCb, 
+U8      rb
+)
+#else
+PUBLIC PjUlRbCb* pjDbmCreateUlRbCb(gCb,rbId,rbType,ueCb,rb)
+PjCb    *gCb;
+U8      rbId; 
+U8      rbType;
+PjUlUeCb  *ueCb; 
+U8      rb;
+#endif
+{
+   PjUlRbCb   *rbCb;
+   PjUlRbCb   **rbCbLst;
+
+   TRC2(pjDbmCreateUlRbCb)
+
+   rbCb = NULLP;
+   rbCbLst = NULLP;
+   PJ_ALLOC(gCb, rbCb, sizeof(PjUlRbCb) );
+   if ( rbCb == NULLP )
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed");
+      RETVALUE(rbCb);
+   }
+   rbCb->rbId   = rbId;
+   rbCb->rbType = rbType;
+
+   rbCbLst = ((rbType == CM_LTE_SRB)? ueCb->srbCb:ueCb->drbCb); 
+   rbCbLst[rbId] = rbCb;
+   /* kw005.201 ccpu00117318, updating the statistics */   
+   PJ_LMM_RB_STS_INC(gCb);                                    
+   
+   RETVALUE(rbCb); 
+   
+} /* pjDbmCreateRbCb */
+
+/**
+ *
+ * @brief Handler to fetch a  PDCP RB control block.
+ *       
+ *
+ * @b Description
+ *        This function is used to fetch the PDCP RB control block based on 
+ *        the RB id. The pointer to PjUlRbCb is returned.
+ *       
+ *  @param[in]  ueCb    UE control block of the PDCP RB
+ *  @param[in]  rbId    RB ID of the required PDCP entity.
+ *  @param[out] pjRbCb  PDCP RB Control Block.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjDbmFetchPjUlRbCb
+(
+PjUlUeCb  *ueCb,
+U8       rbId,
+U8       rbType,
+PjUlRbCb  **pjRbCb 
+)
+#else
+PUBLIC S16 pjDbmFetchPjUlRbCb(ueCb,rbId,rbType,pjRbCb)
+PjUlUeCb  *ueCb;      
+U8       rbId;
+U8       rbType;
+PjUlRbCb  **pjRbCb;
+#endif
+{
+   PjUlRbCb    *rbCb;
+
+   TRC2(pjDbmFetchPjUlRbCb)
+
+   *pjRbCb = NULLP;
+
+   PJ_DBM_FETCH_UL_RBCB(rbId, rbType, ueCb, rbCb);
+   if ( rbCb != NULLP )
+   {
+      *pjRbCb = rbCb;
+   }
+
+   RETVALUE(ROK);
+
+} /* pjDbmFetchPjUlRbCb */
+
+/**
+ *
+ * @brief Handler to delete a PDCP/RLC RB control block.
+ *       
+ *
+ * @b Description
+ *        This function is used to delete the PDCP/RLC RB control block based 
+ *        on RB id and the RB type (PDCP/RLC). If the corresponding RB is 
+ *        present, the cfgStat flag is unset. If the cfgStat flag is zero,
+ *        the RBCB is freed.
+ *
+ *  @param[in]  rbId    RB ID of the to be deleted RB
+ *  @param[in]  rbCbLst RbCb list in UE CB
+ *  @param[in]  rb      The RB to be deleted. This can be
+ *                      PJ_CFG_PDCP when PDCP is created
+ *                      or PJ_CFG_RLC when RLC is being
+ *                      created.
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjDbmDelUlRbCb
+(
+PjCb   *gCb,
+U8      rbId,
+U8      rbType,
+PjUlRbCb   **rbCb, 
+U8      rb,
+PjUlUeCb  *ueCb
+)
+#else
+PUBLIC S16 pjDbmDelUlRbCb(gCb,rbId,rbType,rbCb,rb)
+PjCb   *gCb;
+U8      rbId;
+U8      rbType;
+PjUlRbCb   **rbCb;
+U8      rb;
+PjUlUeCb  *ueCb;
+#endif
+{
+   S16      ret;
+   PjUlRbCb   **rbCbLst;
+   rbCbLst = NULLP;     
+   TRC2(pjDbmDelUlRbCb)
+
+   ret   = RFAILED;
+   /*updating rbCbList */                              
+   rbCbLst = ((rbType == CM_LTE_SRB)? ueCb->srbCb:ueCb->drbCb); 
+   if ( (*rbCb) != NULLP )
+   {
+      PJ_DBM_DELETE_UL_RBCB(gCb,(*rbCb));
+      ret = ROK;
+      /*updating rbCbList */
+      rbCbLst[rbId] = NULLP;         
+   }
+   RETVALUE(ret);
+
+} /* pjDbmDelRbCb */
+
+/**
+ *
+ * @brief Handler to add UL Transaction Id to List 
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to add all itransaction IDs to
+ *        hashlist of PjCb.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmAddUlTransIdLst
+(
+PjCb              *gCb,
+PjCfgInfo         *cfg       /* UE Control Block */
+)
+#else
+PUBLIC S16 pjDbmAddUlTransIdLst(gCb,cfg)
+PjCb              *gCb;
+PjCfgInfo         *cfg;     /* UE Control Block */
+#endif
+{
+   S16      ret;              /* Return Value */
+
+   TRC3(pjDbmAddUlTransIdLst)
+
+#ifdef DEBUGP
+#ifndef ALIGN_64BIT
+   RLOG1(L_UNUSED, "pjDbmAddUlTransIdLst(transId(%ld))", cfg->transId);
+#else
+   RLOG1(L_UNUSED, "pjDbmAddUlTransIdLst(transId(%d))", cfg->transId);
+#endif
+#endif
+
+   ret = cmHashListInsert(&(gCb->u.ulCb->transIdLstCp), (PTR)cfg, 
+         (U8 *)&(cfg->transId), (U16) sizeof(cfg->transId));
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG0(L_ERROR, "Hash Insert Failed for Inserting UL transId");
+#endif
+      RETVALUE(ret);
+   }
+
+   RETVALUE(ret);
+} /* pjDbmAddUlTransIdLst */
+
+/**
+ *
+ * @brief Handler to Find UL Transaction Id in the List 
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to Find transaction IDs in the
+ *        hashlist of PjCb.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmFindUlTransIdLst
+(
+PjCb              *gCb,
+U32               transId,
+PjCfgInfo         **cfg       /* UE Control Block */
+)
+#else
+PUBLIC S16 pjDbmFindUlTransIdLst(gCb,cfg)
+PjCb              *gCb;
+U32                transId;
+PjCfgInfo         *cfg;     /* UE Control Block */
+#endif
+{
+   S16      ret;              /* Return Value */
+
+   TRC3(pjDbmFindUlTransIdLst)
+
+#ifdef DEBUGP
+#ifndef ALIGN_64BIT
+   RLOG1(L_DEBUG, "pjDbmFindUlTransIdLst(transId(%ld))", transId);
+#else
+   RLOG1(L_DEBUG, "pjDbmFindUlTransIdLst(transId(%d))", transId);
+#endif
+#endif
+
+   ret = cmHashListFind(&(gCb->u.ulCb->transIdLstCp),(U8 *) &transId, 
+                  sizeof (transId), PJ_DEF_SEQ_NUM,(PTR *) cfg); 
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG1(L_ERROR,"Hash Find Failed Fetch for transId [%d]", transId);
+#endif
+   }
+   ret = pjDbmDelUlTransIdLst(gCb, cfg);
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG0(L_ERROR,"Deleting Trans ID Failed");
+#endif
+      RETVALUE(ret);
+   }
+
+   RETVALUE(ret);
+} /* pjDbmAddUlTransIdLst */
+
+/**
+ *
+ * @brief Handler to Delete UL Transaction Id to List 
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to Delete transaction IDs From the
+ *        hashlist of PjCb.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmDelUlTransIdLst
+(
+PjCb              *gCb,
+PjCfgInfo         **cfg       /* UE Control Block */
+)
+#else
+PUBLIC S16 pjDbmDelUlTransIdLst(gCb,cfg)
+PjCb              *gCb;
+PjCfgInfo         **cfg;     /* UE Control Block */
+#endif
+{
+   S16      ret;              /* Return Value */
+
+   TRC3(pjDbmDelUlTransIdLst)
+
+#ifdef DEBUGP
+   RLOG0(L_DEBUG, "pjDbmFindUlTransIdLst(transId()" );
+#endif
+
+   ret = cmHashListDelete(&(gCb->u.ulCb->transIdLstCp),(PTR) (*cfg)); 
+   if (ret != ROK)
+   {
+#ifdef DEBUGP
+      RLOG1(L_ERROR," Hash Delete Failed for transId(%d)",(*cfg)->transId);
+#endif
+   }
+
+   RETVALUE(ret);
+} /* pjDbmAddUlTransIdLst */
+
+/**
+ *
+ * @brief Handler to Delete All  UL Transaction Ids from the List 
+ *       
+ *
+ * @b Description
+ *        This function is invoked by CFG to Delete all itransaction IDs from the
+ *        hashlist of PjCb.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+#ifdef ANSI
+PUBLIC S16 pjDbmDelAllUlTransIdLst
+(
+PjCb              *gCb
+)
+#else
+PUBLIC S16 pjDbmDelAllUlTransIdLst(gCb)
+PjCb              *gCb;
+#endif
+{
+   S16      ret;              /* Return Value */
+   PjCfgInfo *cfg;
+
+   TRC3(pjDbmDelAllUlTransIdLst)
+
+#ifdef DEBUGP
+   RLOG0(L_DEBUG, "pjDbmFindUlTransIdLst");
+#endif
+   ret = ROK;
+   cfg = NULLP; /*KW_FIX*/
+   /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
+   while (cmHashListGetNext(&(gCb->u.ulCb->transIdLstCp), 
+               (PTR) cfg, (PTR *)&cfg) == ROK)
+
+   {
+      /* Delete ueCb */
+      ret = pjDbmDelUlTransIdLst(gCb,&cfg);
+      if (ret != ROK)
+      {
+#ifdef DEBUGP
+         RLOG0(L_ERROR, " pjDbmDelTransIdLst Failed.");
+#endif
+         RETVALUE(ret);
+      }
+      
+      cfg = NULLP;
+   }
+
+   RETVALUE(ret);
+} /* pjDbmAddUlTransIdLst */
+
+
+
+
+
+
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_dl.h b/src/5gnrpdcp/pj_dl.h
new file mode 100755 (executable)
index 0000000..37d2d2a
--- /dev/null
@@ -0,0 +1,88 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:     LTE PDCP file 
+    
+        Type:     C include file
+  
+        Desc:     This file contain the hash definations for PDCP
+        File:     pj_dl.h
+  
+*********************************************************************21*/
+/** @file pj_dl.h
+@brief PDCP Hash definitions
+*/
+
+#ifndef __PJ_DLH__
+#define __PJ_DLH__
+
+\f 
+#define PJ_DBM_FETCH_DL_RBCB(_rbId, _rbType, _ueCb, _rbCb)     \
+{                                                           \
+   _rbCb = (_rbType==CM_LTE_SRB)?_ueCb->srbCb[_rbId]:_ueCb->drbCb[_rbId];\
+}
+
+/* HO_FIX: RRC expects the results as ROK or RFAILED 
+           Hence, changing the vlaue to ROK from CPJ_CFG_CFM_OK */
+#define  PJ_FILL_DL_SDU_CFM_INFO(_cb,_cfmInfo, _ueCb)                    \
+{                                                                 \
+   U8 _rbCnt;                                                     \
+   U8 _numRb = 0;                                                 \
+   PjDlHoCfmInfo *_hoCfmInfo;                                       \
+   UdxSduStaInfo  *_staInfo;                                      \
+   _cfmInfo->ueId    = _ueCb->key.ueId;                           \
+   _cfmInfo->cellId  = _ueCb->key.cellId;                         \
+   _cfmInfo->transId = _ueCb->hoInfo->transId;                    \
+   for(_rbCnt = 0; _rbCnt < PJ_MAX_DRB_PER_UE && _numRb < CPJ_MAX_DRB; _rbCnt++)          \
+   {                                                              \
+      _hoCfmInfo   =  &_ueCb->hoInfo->hoCfmInfo[_rbCnt];          \
+      _staInfo     =  &_cfmInfo->sduStaInfo[_numRb];              \
+      if(_hoCfmInfo->pres != TRUE)                                \
+      {                                                           \
+         continue;                                                \
+      }                                                           \
+                                                                  \
+      _staInfo->rbId  =  _hoCfmInfo->rbId;                        \
+      _staInfo->dir   =  _hoCfmInfo->dir;                         \
+      _staInfo->dlSduStaInfo.count     =  _hoCfmInfo->count;   \
+      _staInfo->dlSduStaInfo.hoPres    =  TRUE;                \
+      _numRb++;                                                   \
+   }                                                              \
+   _cfmInfo->numRb = _numRb;                                      \
+   _cfmInfo->status = ROK;                                      \
+   _cfmInfo->reason = CPJ_CFG_REAS_NONE;                                      \
+   PJ_FREE(_cb,_ueCb->hoInfo->hoCfmInfo,                          \
+              (PJ_MAX_DRB_PER_UE * sizeof(PjDlHoCfmInfo))) \
+   PJ_FREE(_cb,_ueCb->hoInfo, sizeof(PjDlHoInfo));                      \
+}
+#define PJ_DBM_DELETE_DL_RBCB(_cb, _rbCb)                           \
+{                                                           \
+   /* Free memory for rbCb */                               \
+   PJ_FREE(_cb, _rbCb, sizeof(PjDlRbCb));                            \
+   PJ_LMM_RB_STS_DEC(_cb);                                     \
+}
+
+#endif /* __PJH__ */
+\f  
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_dl.x b/src/5gnrpdcp/pj_dl.x
new file mode 100755 (executable)
index 0000000..6bb5a9a
--- /dev/null
@@ -0,0 +1,792 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE PDCP file 
+    
+        Type:    C include file
+  
+        Desc:    This file contains all the data structures and 
+                 prototypes for LTE PDCP.
+        File:    pj_dl.x
+  
+*********************************************************************21*/
+/** @file pj_dl.x
+@brief PDCP Product Structures, prototypes
+*/
+
+#ifdef TENB_STATS
+#include "pj_tenb_stats.x"   
+#endif
+
+
+#ifndef __PJ_DL_X__
+#define __PJ_DL_X__
+
+\f
+/*
+ *     The structures and variables declared in this file
+ *     correspond to structures and variables used by
+ *     the following TRILLIUM software:
+ *
+ *     part no.             description
+ *     --------     ----------------------------------------------
+ *     1000371      LTE-RLC
+ *
+*/
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct pjDlUeCb PjDlUeCb;
+typedef struct pjDlRbCb PjDlRbCb;               /* PDCP RB control block */
+
+
+
+/** @addtogroup dldata */
+/*@{*/
+
+/**
+ *  @brief
+ *  PDCP SDU Status Information for a DRB mapped to RLC AM.
+ */
+
+typedef struct pjDlHoCfmInfo
+{
+   U8         rbId;                     /*!< RB ID */
+   Bool       pres;                     /*!< Is handover info present for this RB */
+   U8         dir;                      /*!< Direction of the RB */
+   U8         res1;
+   U32        count;                    /*!< Count of the next SN to be assigned */
+}PjDlHoCfmInfo;
+
+/**
+ *  @brief
+ *  Handover information maintainned during processing of SduStaReq
+ */
+typedef struct pjDlHoInfo
+{
+   U32           transId;                   /*!< Transaction ID */
+   PjDlHoCfmInfo   *hoCfmInfo;                /*!< SDU Status Confirm */
+}PjDlHoInfo;
+
+/** @struct PjTxEnt
+PDCP Tx Entry - SDU received from Relay */
+typedef struct pjTxEnt
+{
+   CmLList     lstEnt;                      /*!< List entry for SDU */
+   CmLList     datCfmEnt;                   /*!< List entry for SDU */
+   CmLList     sduSubmitEnt;                /*!< List entry for SDU */
+   CmLList     reEstPktEnt;                /*!< List entry for SDU */
+   U8          state;                       /*!< SDU state */
+   U8          res;                         /*!< reserved */
+   PjSn        sn;                          /*!< PDCP SN associated with this SDU */
+   U32         count;                       /*!< COUNT associated with this SDU */  
+   Data        *ciphDBuf;                   /*Pointer to flat buffer created for ciphering */
+   Buffer      *pdu;                        /*!< Pdu Buffer */
+   Buffer      *sdu;                        /*!< Sdu Buffer */
+#ifdef FLAT_BUFFER_OPT
+   FlatBuffer  fb;
+#endif
+   U32         sduId;                       /*!< SDU ID */
+   PjDlRbCb      *rbCb;
+   MsgLen         bufLen;
+#ifdef LTE_L2_MEAS
+   EpcTime     epcTime;                     /*!< Arrival Time of the SDU for dl delay */
+#endif
+}PjTxEnt;
+
+/** @struct PjDlCb 
+PDCP downlink control block */
+typedef struct pjDlCb
+{
+   S16         discTmrInt;                  /*!< Discard timer Interval */
+   U32         txNext;                       /*!<indicates the COUNT value of the next PDCP SDU to be transmitted */
+   Bool        cfmReqd;                     /*!< Flag to indicate if
+                                                 confirmation is required for the
+                                                 SDUs delivered to the peer PDCP */
+   U8          res[3];                      /*!< reserved */
+   PjBuf       txBuf;                       /*!< Transmission buffer */
+   U32         count;                       /*!< DL COUNT associated with the
+                                                 recent SDU */
+   PjSn        sn;                          /*<Sn for PDCP SDU */
+   U32         nxtToSub;                    /*!< COUNT of the next PDU to be
+                                                 submitted to RLC */
+   U32         cfmExp;                      /*!< COUNT of the next PDU for which
+                                                 confirmation is expected */
+   CmTimer     discTmr;                     /*!< Discard timer */
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+   CmTimer     obdTmr;                      /*!< Offboard timer */
+   U32         obdCount;                    /*!< OBD Count */
+#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
+   CmLListCp   dlPktQ;                   /*!< Queues the message during
+                                             Re-establishment/Handover */ 
+   Buffer     *staRep;
+}PjDlCb;
+/*@}*/
+
+
+/** @struct PjRbCb 
+PDCP RB control block */
+struct pjDlRbCb
+{
+   CmLteRbId   rbId;                        /*!< RB Id for PDCP Cb */
+   U8          rbType;                      /*!< RB Type : 0 - PJ_SRB, 1 - PJ_DRB */
+   CmLteRlcMode mode;                       /*!< Mapped RLC entity's mode */
+   U8          dir;                         /*!< Direction for UL/DL/biderctional */
+   U8          snLen;                       /*!< Sequence number length */
+   U8          state;                       /*!< RB state - Used only for DRBs*/
+   PjSn        firstSn;                     /*!< SN of the first message sent
+                                                 for Integrity Protection */
+   PjRohc      rohc;                        /*!< ROHC Information */ 
+   PjCmpCxt    cmpCxt;                      /*!< Context for ROHC */
+   PTR         cmpCxtId;                    /*!< Context Id for ROHC */ 
+   Bool        firstDlMsg;                  /*!< Flag for firstDlMsg 
+                                                 Set to FALSE at start */
+   Bool        dropOnlyOne;              /*!< Indicates whether too many packets 
+                                                 are waiting on this RB */
+   U32         pktAdmitCnt;              /*!< Indicates how many packets 
+                                                 can be admitted */
+   U32         pktCnt;                   /*!< counts number of packets 
+                                                 admitted */
+/* pj005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+   U8          qci;                         /*!< QCI value associated with rb */
+   PjL2MeasRbCb rbL2Cb;                     /*!< L2 Meas Cb for RB */
+#endif /* LTE_L2_MEAS */
+/** @defgroup dldata DL Module Info 
+*/
+   PjDlCb      dlCb;                        /*!< Downlink PDCP RbCb */
+   PjDlUeCb    *ueCb;                       /*!< Pointer to the UE in which RB is present */
+   U32         maxTxSn;                     /*!< Sequence number length */
+   PjUeKey     key;                       /*!< Hash list key for UeCb */
+   CmLListCp   dlPktLst;                    /*!< List of DL packets */
+   U32         rbOverloadCnt;              /*!< Count to track consecutive PDB breach report on an RB*/ 
+};
+
+/** @brief SDU Confirmation Structure from RLC */
+typedef struct pjDatCfm
+{
+   CmLteRlcId        rlcId;                 /*!< RLC identifier */
+   U32               numSdu;                /*!< Number of SDUs */
+   U32               sduId[PJ_MAX_DAT_CFM]; /*!< SDU Id Array */
+}PjDatCfm;
+
+
+/** @struct PjUeCb
+UE control block */
+struct pjDlUeCb
+{
+   CmHashListEnt ueHlEnt;                   /*!< Hash list entry for UeCb */
+   Inst          inst;
+   PjUeKey       key;                       /*!< Hash list key for UeCb */ 
+   U8            numSrbs;
+   U8            numDrbs;
+   PjDlRbCb     *srbCb[PJ_MAX_SRB_PER_UE]; /*!< SRB RbCbs within a UE */ 
+   PjDlRbCb     *drbCb[PJ_MAX_DRB_PER_UE]; /*!< DRB RbCbs within a UE */ 
+   PjSec         secInfo;                   /*!< Security Info */
+   PjDlHoInfo      *hoInfo;                   /*!< SDU Status Confirm */
+   PjLibInfo     libInfo;                   /*!< Hook Info - to wait for
+                                                 Init Cfm */
+   U32            waitForReEstTrig;
+
+/* pj005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+   U16           numActRb[LPJ_MAX_QCI]; /* number of RBs Active */
+#endif /* LTE_L2_MEAS */
+#ifdef TENB_STATS
+   TSL2UeStatsCb   *tenbStats; /*!< UE Stats Holder */
+#endif
+};
+
+typedef struct pjDlPkt
+{
+   CmLList lnk;
+   U8      type;
+   U32     sduId;
+   PjSn    sn;
+   Buffer  *pdu;
+#ifdef FLAT_BUFFER_OPT
+   FlatBuffer  fb;
+#endif
+} PjDlPkt;
+
+/* CFG Module */
+EXTERN S16 pjCfgAddDlRb ARGS ((PjCb *gCb,CmLteRnti  ueId,CmLteCellId  cellId,
+            U8 isHo, UdxCfgEnt  *entCfg, PjDlUeCb **ueCb,UdxCfmEnt  *entCfm ));
+
+EXTERN S16 pjCfgReCfgDlRb ARGS ((PjCb *gCb,PjDlUeCb *ueCb,
+                          UdxCfgEnt *entCfg, UdxCfmEnt *entCfm));
+
+EXTERN S16 pjCfgDelDlRb ARGS ((PjCb *gCb,PjDlUeCb *ueCb,
+                        UdxCfgEnt *entCfg,UdxCfmEnt *entCfm));
+
+EXTERN S16 pjCfgReEstDlRb ARGS ((
+PjCb             *gCb,
+PjDlUeCb         *ueCb,
+UdxCfgEnt         *entCfg,
+UdxCfmEnt         *entCfm
+));
+
+EXTERN S16 pjCfgDelDlUe ARGS ((
+PjCb             *gCb,
+PjDlUeCb         *ueCb,
+UdxCfgEnt         *entCfg,
+UdxCfmEnt         *entCfm
+));
+
+EXTERN S16 pjCfgPrcSecDlCfg ARGS ((
+PjCb             *gCb,
+UdxSecCfgReqInfo *secCfg,
+UdxSecCfgCfmInfo *cfgCfm
+));
+
+EXTERN S16 pjCfgDlUeIdChng ARGS((
+PjCb      *gCb,
+UdxUeInfo *ueInfo,
+UdxUeInfo *newUeInfo,
+CmStatus  *status
+));
+
+EXTERN S16 pjCfgPrcDlCount ARGS ((
+PjCb                  *gCb,
+UdxCountReqInfo       *countReq,
+UdxCountCfmInfo       *countCfm
+));
+
+EXTERN S16  pjCfgDelPjDlRbCb ARGS ((
+PjCb                  *gCb,
+PjDlUeCb               *ueCb,
+PjDlRbCb                 *rbCb
+));
+
+
+EXTERN  S16 pjCfgDlReEstReq ARGS ((
+PjCb                  *gCb,
+UdxReEstReqInfo *reEstReq,
+UdxReEstCfmInfo   *reEstCfm
+));
+/* DB Module */
+EXTERN S16 pjDbmInsTxEnt  ARGS ((
+PjCb        *gCb,
+PjBuf       *buf,             
+PjTxEnt     *txEnt       
+));
+EXTERN S16 pjDbmDlBufInit ARGS ((  
+PjCb        *gCb,
+PjBuf       *buf,            /* !< Rx/Tx Buffer */
+U8          numBins          /* !< number of Bins */
+));
+
+EXTERN PjTxEnt* pjDbmGetTxEnt ARGS ((
+PjCb        *gCb,
+PjBuf       *buf,        
+U32          count      
+));
+EXTERN PjTxEnt* pjDbmGetTxEntSn ARGS ((
+PjCb        *gCb,
+PjBuf       *buf,      
+U16          sn          
+));
+EXTERN S16 pjDbmDelTxEnt  ARGS ((
+PjCb        *gCb,
+PjBuf       *buf,    
+U32         count     
+));
+EXTERN S16 pjDbmTxDelAll ARGS((
+PjCb        *gCb,
+PjBuf *buf       
+));
+EXTERN S16 pjDbmTxDeInit ARGS ((
+PjCb        *gCb,
+PjBuf *buf       
+));
+
+EXTERN S16 pjDbmFetchDlUeCb ARGS ((
+PjCb        *gCb,
+CmLteRnti         ueId,       /* UE Identifier */
+CmLteCellId       cellId,     /* Cell Identifier */
+PjDlUeCb            **ueCb       /* UE Control Block */
+));
+
+EXTERN S16 pjDbmCreateDlUeCb ARGS ((
+PjCb        *gCb,
+CmLteRnti         ueId,       /* UE Identifier */
+CmLteCellId       cellId,     /* Cell Identifier */
+PjDlUeCb            **ueCb       /* UE Control Block */
+));
+EXTERN  PjDlRbCb* pjDbmCreateDlRbCb ARGS ((
+PjCb        *gCb,
+U8      rbId,
+U8      rbType,
+PjDlUeCb  *ueCb,
+U8      rb
+));
+EXTERN  S16 pjDbmDelDlRbCb ARGS ((
+PjCb        *gCb,
+U8      rbId,
+U8      rbType,
+PjDlRbCb   **rbCb,
+U8      rb,
+PjDlUeCb  *ueCb
+));
+
+EXTERN S16 pjDbmDelDlUeCb  ARGS((
+PjCb        *gCb,
+PjDlUeCb      *ueCb,       /* UE Identifier */
+Bool        abortFlag    /* Abort Flag */
+));
+
+EXTERN S16 pjDbmFetchDlRbCb ARGS((
+PjCb           *gCb,
+CmLteRlcId     rlcId,      /* RLC Identifier */
+PjDlRbCb       **rbCb       /* RB Cb */
+));
+
+EXTERN S16 PjDbmDelAllDlUe ARGS((PjCb *gCb));
+EXTERN S16 pjDbmDelAllDlRb ARGS((
+PjCb        *gCb,
+PjDlRbCb         **rbCbLst,              /* RB Cb list */
+U8             numRbCb                 /* Number of rbCbs */
+));
+
+EXTERN S16 pjDbmDlInit  ARGS (( PjCb *gCb));
+EXTERN S16 pjDbmDlDeInit  ARGS (( PjCb *gCb));
+EXTERN S16 pjDbmDlShutdown ARGS((PjCb *gCb));
+
+EXTERN S16 pjDlUtlCmpReset ARGS(( 
+PjCb        *gCb,
+PjDlRbCb      *pjRbCb                 /* Context to be reset for compression */
+));
+
+/* UTL Module */
+EXTERN S16 pjUtlDlCmpInit ARGS((
+PjCb        *gCb,
+PjDlRbCb   *pjRbCb                  /* PDCP RbCb */
+));
+EXTERN S16 pjUtlDlIntInit ARGS((
+PjCb        *gCb,
+PjDlUeCb   *ueCb                   /* UE CB Ptr */
+));
+EXTERN S16 pjUtlDlCpInit ARGS((
+PjCb        *gCb,
+PjDlUeCb   *ueCb                    /* UE CB Ptr */
+));
+EXTERN S16 pjUtlDlUpInit ARGS((
+PjCb        *gCb,
+PjDlUeCb   *ueCb                    /* UE CB Ptr */
+));
+EXTERN S16 pjUtlDlCmpReset ARGS((
+PjCb        *gCb,
+PjDlRbCb      *pjRbCb                 /* Context to be reset for compression */
+));
+EXTERN S16 pjUtlCmpReq ARGS((
+PjCb        *gCb,
+PjDlRbCb   *pjRbCb,                 /* PDCP RbCb */
+Buffer   *mBuf,                   /* SDU to be compressed */
+Buffer   **opSdu,                 /* Compressed SDU */
+U32      count                    /* COUNT - transaction Id */
+));
+EXTERN S16 pjUtlIntProtReq ARGS((
+PjCb        *gCb,
+PjDlRbCb   *pjRbCb,                 /* PDCP RbCb */
+PjSecInp secInp ,                 /* Input parameters for integrity */ 
+Buffer   **mBuf                   /* SDU to be compressed */
+));
+EXTERN S16 pjUtlCipherReq ARGS((
+PjCb        *gCb,
+PjDlRbCb   *pjRbCb,               /* PDCP RbCb */
+U32      count,                   /* COUNT associated with SDU/PDU */ 
+Buffer   *mBuf,                   /* Data to be ciphered */
+Buffer   **opSdu                  /* ciphered SDU */
+));
+
+#ifdef FLAT_BUFFER_OPT
+EXTERN S16 pjUtlCipherReqFB ARGS((
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb,                 /* PDCP RbCb */
+U32        count,                   /* COUNT associated with SDU/PDU */ 
+FlatBuffer *mBuf,                   /* Data to be deciphered */
+Buffer   **opSdu                    /* Deciphered SDU */ 
+));
+#endif
+
+EXTERN S16 pjUtlDlCmpClose ARGS((
+PTR      cmpCxtId                 /* ROHC Context to be closed */
+));
+EXTERN S16 pjUtlDlIntClose ARGS((
+PjCb     *gCb,
+Void     *intCxtId            /* Handle to be closed */
+));
+
+EXTERN S16 pjUtlDlCipherClose ARGS((
+PjCb     *gCb,
+Void     *cpCxtId                  /* Context Id for Ciphering to be closed */
+));
+EXTERN S16 pjUtlDlReEstSrb1 ARGS((
+PjCb        *gCb,
+PjDlRbCb      *pjRbCb                    /* PDCP Control Block Pointer */
+));
+EXTERN S16 pjUtlDlReEstStart ARGS((
+PjCb        *gCb,
+PjDlUeCb         *ueCb,          /* UE Control Block Pointer */
+UdxCfgReqInfo  *cfgReq         /* CfgReq for Reestablishment */
+));
+EXTERN S16 pjUtlDlReEstHOStart ARGS((
+PjCb        *gCb,
+PjDlUeCb      *ueCb,           /* Number of RBs undergoing reestablishment*/ 
+U32         transId,          /* Transaction id of Sdu Status cfm */
+U32       waitForHoTrig
+));
+EXTERN S16 pjUtlDlReEstReconfig ARGS((
+PjCb        *gCb,
+PjDlUeCb       *ueCb           /* UE Control Block */ 
+));
+EXTERN S16 pjUtlDlReEstDl ARGS((
+PjCb        *gCb,
+PjDlUeCb       *ueCb           /* UE Control Block */ 
+));
+EXTERN S16 pjUtlDlSndReEstCfgCfm ARGS((
+PjCb        *gCb,
+PjDlUeCb       *ueCb           /* UE Control Block */ 
+));
+EXTERN S16 pjUtlDlSndSduStaCfm ARGS((
+PjCb        *gCb,
+PjDlUeCb       *ueCb           /* UE Control Block */ 
+));
+EXTERN S16 pjUtlDlShutdown ARGS((
+PjCb        *gCb
+));
+EXTERN Void pjUtlDlFreeRb ARGS((
+PjCb        *gCb,
+PjDlRbCb *pjRbCb
+));
+/* kw005.201 added function to send data forward indication mesage */
+EXTERN S16 pjUtlDlSndDatFwdInd ARGS((
+PjCb        *gCb,
+PjDlRbCb           *pjRbCb,
+PjuDatFwdIndInfo *datFwdInd
+));
+
+EXTERN S16 pjUtlDlHdlObdInitCfm ARGS((
+PjCb        *gCb,
+PjDlUeCb    *ueCb,           /* Pointer to UeCb */ 
+U16         txIdx,           /* Transaction Index for UeCb */
+U8          cfmType,         /* Confirm type */
+U8          maskVal          /* mask value */
+));
+EXTERN S16 pjUtlDlHdlInitObdTmrExp ARGS((
+PjCb      *gCb,
+PjDlUeCb *ueCb
+));
+
+EXTERN S16 pjCfgPrcDlSduSta ARGS((
+PjCb        *gCb,
+UdxSduStaReqInfo *staReq   
+));
+
+EXTERN S16 pjUtlDlSaveCfmInfo  ARGS((
+PjCb        *gCb,
+PjDlUeCb      *ueCb,           /* Pointer to UeCb */ 
+U8          cfmType,         /* Confirm type */
+Bool        startTmr,        /* Whether to start timer */
+U8          entity,          /* Confirm type */
+PTR         cfmPtr,          /* Pointer to the structure for confirm */
+PTR         cfgPtr           /* Pointer to the structure for request */
+));
+
+/* DL Module */
+EXTERN S16 pjDlmProcessSdus ARGS ((
+PjCb        *gCb,
+PjDlRbCb *pjRbCb, 
+Buffer *sdu,
+U32    sduId,
+U32    count
+));
+
+EXTERN S16 pjDlmProcDrb ARGS ((
+PjCb        *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+));
+
+#ifdef FLAT_BUFFER_OPT
+EXTERN S16 pjDlmProcDrbFB ARGS ((
+PjCb        *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+));
+#endif
+
+EXTERN S16 pjDlmProcSrb ARGS ((
+PjCb        *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+));
+EXTERN Void pjDlmReEstSrb ARGS ((
+PjCb        *gCb,
+PjDlRbCb *pjRbCb
+));
+
+EXTERN S16 pjDlmReEstDrbUm ARGS ((
+PjCb        *gCb,
+PjDlRbCb *pjRbCb
+));
+
+EXTERN S16 pjDlmReEstDrbAm ARGS ((
+PjCb        *gCb,
+PjDlRbCb *pjRbCb
+));
+EXTERN S16 pjDlmProcessCfm ARGS ((
+PjCb        *gCb,
+PjDlRbCb        *pjRbCb,
+PjDatCfm      *pjDatCfm,
+U8            cfmType
+));
+EXTERN S16 pjDlmHndlStaRep ARGS ((
+PjCb        *gCb,
+PjDlRbCb   *pjRbCb,
+PjSn     fms,
+Buffer   *staPdu
+));
+EXTERN S16 pjDlmReEstHoDrbAm ARGS ((
+PjCb        *gCb,
+PjDlRbCb *pjRbCb
+));
+EXTERN S16 pjDlmHdlDatFwdReq ARGS ((
+PjCb        *gCb,
+PjDlRbCb  *pjRbCb,
+PjuDatFwdReqInfo *datFwdReq
+));
+EXTERN S16 pjDlmDeliverPdu ARGS ((
+PjCb        *gCb,
+PjDlRbCb     *pjRbCb,
+PjTxEnt    *txEnt
+));
+EXTERN S16 pjDlmObdTmrExp ARGS ((
+PjCb        *gCb,
+PjDlRbCb     *pjRbCb
+));
+EXTERN  S16 pjDlmHdlIntProt ARGS ((
+PjCb        *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+));
+EXTERN S16 pjDlmHdlCmp ARGS (( 
+PjCb        *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+));
+
+#ifdef FLAT_BUFFER_OPT
+EXTERN S16 pjDlmHdlCmpFB ARGS (( 
+PjCb        *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+));
+#endif
+
+EXTERN S16 pjDlmHdlCiph ARGS ((
+PjCb        *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+));
+
+#ifdef FLAT_BUFFER_OPT
+EXTERN S16 pjDlmHdlCiphFB ARGS ((
+PjCb        *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+));
+#endif
+
+EXTERN S16 pjDlmDiscTmrExp ARGS ((
+PjCb        *gCb,
+PjDlRbCb  *pjRbCb
+));
+
+EXTERN S16 pjDlmSendDatReq ARGS(( PjCb *gCb, PjDlRbCb *pjRbCb, U32 sduId, 
+                                Buffer *mBuf));
+EXTERN S16 pjDlmSendDiscSdu ARGS(( PjCb *gCb, PjDlRbCb  *pjRbCb, U32 sduId));
+
+EXTERN Void pjLimDatCfm ARGS((
+PjCb          *gCb,
+PjDlRbCb      *pjRbCb,
+PjDatCfm    *datCfm 
+));
+EXTERN S16 pjUtlReEstDl ARGS (( 
+PjCb        *gCb,
+PjDlUeCb       *ueCb           /* UE Control Block */
+));
+
+EXTERN Void pjLimStaInd  ARGS((
+PjCb        *gCb,
+PjDlRbCb    *pjRbCb,
+PjDatCfm    *staInd
+));
+
+EXTERN S16 pjDbmFetchPjDlRbCb ARGS((
+PjDlUeCb           *ueCb,
+U8      rbId,
+U8      rbType,
+PjDlRbCb      **pjRbCb
+));
+
+EXTERN Void pjDlmProcessDlPktQ ARGS((
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb           /* !< PDCP Control Block */
+));
+
+EXTERN Void pjDlmEnqueueDlPkt ARGS((
+PjCb               *gCb, 
+PjDlRbCb           *pjRbCb,          /* !< PDCP Control Block */
+U8                 datType,
+PjuDatFwdReqInfo   *datFwd,          /* !< SN value of PDU */
+PjuSduId           sduId,
+Buffer             *pdu              /* !< PDU message buffer */
+));
+
+#ifdef FLAT_BUFFER_OPT
+EXTERN Void pjDlmEnqueueDlPktFB ARGS((
+PjCb               *gCb, 
+PjDlRbCb           *pjRbCb,          /* !< PDCP Control Block */
+U8                 datType,
+PjuDatFwdReqInfo   *datFwd,          /* !< SN value of PDU */
+PjuSduId           sduId,
+FlatBuffer         *pdu             /* !< Flat Buffer PDU */ 
+));
+
+EXTERN Void pjDlmRbDataResumeFB ARGS((
+PjCb   *gCb,
+PjDlRbCb *pjRbCb
+));
+
+EXTERN Void pjDlmProcessDlPktQFB ARGS((
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb           /* !< PDCP Control Block */
+));
+
+EXTERN S16 pjDlmStartDataFrwdPerRbFB ARGS((
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb
+));
+
+#endif
+
+EXTERN S16 pjDlmStartDataFrwdPerRb ARGS((
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb
+));
+
+EXTERN S16 pjDlmHndlDatFwdReq ARGS((
+PjCb               *gCb,
+PjDlRbCb           *pjRbCb,
+PjuDatFwdReqInfo   *datFwdReq
+));
+
+EXTERN S16 pjUtlDlUpdUpSecKeys ARGS((
+PjCb       *gCb,
+PjDlUeCb   *ueCb           /* UE Control Block */ 
+));
+
+EXTERN S16 pjUtlDlUpdCpSecKeys ARGS((
+PjCb       *gCb,
+PjDlUeCb   *ueCb           /* UE Control Block */ 
+));
+
+EXTERN S16 pjUtlDlReEstHO ARGS((
+PjCb              *gCb,
+PjDlUeCb          *ueCb           /* Number of RBs undergoing reestablishment*/ 
+));
+
+EXTERN Void pjUtlEmptyDlPktList ARGS((
+PjCb *gCb, 
+PjDlRbCb *pjRbCb));
+
+EXTERN Void pjDlmRbDataResume ARGS((
+PjCb   *gCb,
+PjDlRbCb *pjRbCb
+));
+
+EXTERN PUBLIC S16 pjDlmHdlNullCiph ARGS((
+PjCb       *gCb,
+PjDlRbCb     *pjRbCb,
+PjTxEnt    *txEnt
+));
+
+#ifdef FLAT_BUFFER_OPT
+EXTERN PUBLIC S16 pjDlmProcessSdusFB ARGS((
+PjCb   *gCb,
+PjDlRbCb *pjRbCb,                   
+FlatBuffer *sdu,                      
+U32    sduId,                      
+U32        count
+));
+
+EXTERN PUBLIC S16 pjUtlConvFbToBuf ARGS((
+PjCb       *gCb,
+FlatBuffer *fb,
+Buffer     **mBuf
+));
+
+EXTERN PUBLIC S16 pjUtlCopyFbToBuf ARGS((
+PjCb       *gCb,
+FlatBuffer *fb,
+Buffer     **mBuf
+));
+#endif
+
+#ifdef LTE_L2_MEAS
+S16 pjUtlL2MeasDlInit(PjCb *gCb);
+
+EXTERN Void pjUtlResetDlL2MeasCntr ARGS((
+PjCb         *gCb,
+PjL2MeasCb   *measCb,
+U8           measType
+));
+
+EXTERN Void pjUtlPlcMeasDatInDlL2Sts ARGS((
+PjL2Cntr       *measData, 
+PjL2MeasRbCb   *rbL2Cb,
+U8             measType
+));
+S16 pjUtlSndDlL2MeasCfm  ARGS ((PjCb *gCb, PjL2MeasEvtCb *measEvtCb));
+
+#endif
+
+
+void DumpPDCPDlDebugInformation(void);
+void dumpPDCPDlRbInformation(PjDlRbCb* dlRbCb, U16 ueId);
+void ResetPDCPStats(void);
+void PrintPDCPStats(void);
+EXTERN Void pjDeInitCiphQ(Void);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __PJX__ */
+
+\f  
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_dl_ex_ms.c b/src/5gnrpdcp/pj_dl_ex_ms.c
new file mode 100755 (executable)
index 0000000..d6d647a
--- /dev/null
@@ -0,0 +1,671 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+
+   Name:    LTE-PDCP Layer - System Services Interface Functions
+
+   Type:    C file
+
+   Desc:    C source code for the interface to System Services of LTE-PDCP
+
+   File:    pj_dl_ex_ms.c
+
+*********************************************************************21*/
+  
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=217;
+/** @file pj_dl_ex_ms.c
+  @brief PDCP System Services Interface
+ */
+
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "kwu.h"           /* KWU defines */
+#include "cpj.h"           /* CPJ defines */
+#include "ctf.h"           /* CPJ defines */
+#include "pju.h"           /* PJU defines */
+#include "lpj.h"           /* LPJ defines */
+#include "pj_err.h"        /* Err defines */
+#include "pj_env.h"        /* RLC environment options */
+#include "pj.h"            /* RLC defines */
+#include "pj_udx.h"
+#include "pj_dl.h"
+#include "pj_lib.h"
+#include "pj_ptsec.h"
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "kwu.x"           /* KWU */
+#include "cpj.x"           /* CPJ defines */
+#include "pju.x"           /* PJU defines */
+#include "lpj.x"           /* LPJ defines */
+#include "pj.x"
+#include "pj_udx.x"
+#include "pj_dl.x"
+#include "pj_ul.x"
+#include "pj_lib.x"
+#ifdef SS_RBUF
+#include "ss_rbuf.h"
+#include "ss_rbuf.x"
+PUBLIC S16 pjBatchProcTick(Void);
+EXTERN S16 pjRBufFreeMsg(void);
+#endif
+#ifdef LC_EGTP_THREAD
+#include "ss_rbuf.h"
+#include "ss_rbuf.x"
+EXTERN void egWrReadRingBuf(SsRngBufId ringId);
+#endif
+
+PUBLIC U32 ysPjPrcTtiInd = 0;   /* UDAY */
+
+/***********************************************************************
+  System Service Interface Functions
+ ***********************************************************************/
+/**
+ *
+ * @brief
+ *
+ *    <b> Activates Initialization </b>
+ *
+ *    @b Description:
+ *    This function is invoked by system services to initialize the LTE-PDCP
+ *    layer. This is an entry point used by LTE_PDCP layer to initialize its
+ *    global variables, before becoming operational.
+ *
+ *    Allowable values for parameters are specified in ssi.h.
+ *
+ *    @param[in] ent    - Specify the entity id of the LTE-RLC task.
+ *    @param[in] inst   - Specify the entity id of the LTE-RLC task.
+ *    @param[in] region - Specifies the memory region from which
+ *                         LTE-PDCP should allocate structures and buffers.
+ *    @param[in] reason - Specifies the reason for calling this
+ *                         initialization function.
+ *
+ *  @return  S16
+ *      -# ROK
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjDlActvInit
+(
+ Ent    ent,                 /* entity */
+ Inst   inst,                /* instance */
+ Region region,              /* region */
+ Reason reason               /* reason */
+ )
+#else
+PUBLIC S16 pjDlActvInit(ent, inst, region, reason)
+  Ent    ent;                 /* entity */
+  Inst   inst;                /* instance */
+  Region region;              /* region */
+  Reason reason;              /* reason */
+#endif
+{
+   PjCb   *tPjCb;
+   TRC3(pjDlActvInit)
+   if (inst >= PJ_MAX_PDCP_INSTANCES)
+   {
+       /* intance greater than MAX instances */ 
+       RETVALUE(RFAILED); 
+   }
+
+   if (pjCb[inst] != NULLP)
+   {
+      RETVALUE (RFAILED);
+   }
+
+   if (SGetSBuf(region, 0, (Data **)&tPjCb,
+            (Size)sizeof (PjCb)) != ROK)
+   {
+      RETVALUE(RFAILED);
+   }
+   /* Initialize kwCb */
+   PJ_MEM_SET(tPjCb, 0, sizeof(PjCb));
+
+   /* Initialize task configuration parameters */
+   /* We will take only entity name */
+   tPjCb->init.ent     = ent;           /* entity */
+   tPjCb->init.inst    = inst;          /* instance */
+   tPjCb->init.region  = region;        /* static region */
+   tPjCb->init.pool    = 0;             /* static pool */
+   tPjCb->init.reason  = reason;        /* reason */
+   tPjCb->init.cfgDone = FALSE;         /* configuration done */
+   tPjCb->init.acnt    = TRUE;          /* enable accounting */
+   tPjCb->init.usta    = TRUE;          /* enable unsolicited status */
+   tPjCb->init.trc     = FALSE;         /* enable trace */
+#ifdef DEBUGP
+   tPjCb->init.dbgMask = 0x00000000;
+#endif
+   tPjCb->init.procId  = SFndProcId();
+
+   pjCb[inst] = tPjCb;
+
+  RETVALUE(ROK);
+} /* pjActvInit */
+
+\f
+/**
+ *
+ * @brief
+ *
+ *  <b> Activation Task </b>
+ *
+ *  @b Description:
+ *  Processes events received for LTE-PDCP layer via System Services from
+ *  other layers.
+ *
+ *  @param[in] pst   - Pst Structure
+ *  @param[in] mBuf  - Message Buffer
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjDlActvTsk
+(
+Pst *pst,              /* pst structure */
+Buffer *mBuf            /* message buffer */
+)
+#else
+PUBLIC S16 pjDlActvTsk(pst, mBuf)
+Pst *pst;              /* pst structure */
+Buffer *mBuf;           /* message buffer */
+#endif
+{
+   S16 ret = ROK;
+
+   TRC3(pjDlActvTsk);
+
+   switch(pst->srcEnt)
+   {
+      case ENTSM:
+         {
+            switch(pst->event)
+            {
+#ifdef LCLPJ
+               case LPJ_EVT_CFG_REQ:
+                  {
+                     ret = cmUnpkLpjCfgReq(PjMiLpjCfgReq, pst, mBuf);
+                     break;
+                  }
+
+               case LPJ_EVT_CNTRL_REQ:
+                  {
+                     ret = cmUnpkLpjCntrlReq(PjMiLpjCntrlReq, pst, mBuf);
+                     break;
+                  }
+
+               case LPJ_EVT_STS_REQ:
+                  {
+                     ret = cmUnpkLpjStsReq(PjMiLpjStsReq, pst, mBuf);
+                     break;
+                  }
+
+               case LPJ_EVT_STA_REQ:
+                  {
+                     ret = cmUnpkLpjStaReq(PjMiLpjStaReq, pst, mBuf);
+                     break;
+                  }
+                  /* kw005.201 added support for L2 Measurement */
+
+               default:
+                  {
+                     RLOG0(L_ERROR, "Received Invalid Event from SM");
+                     ret = RFAILED;
+                     break;
+                  }
+#endif  /* LCLPJ */
+            }
+            break;
+         }
+
+      case ENTPJ:
+         {
+            switch(pst->event)
+            {
+#ifdef LCUDX
+            case EVTUDXBNDREQ:
+                  {
+                     cmUnpkPjUdxBndReq(PjDlUdxBndReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXUBNDREQ:
+                  {
+                     cmUnpkPjUdxUbndReq(PjDlUdxUbndReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXCFGREQ:
+                  {
+                     cmUnpkPjUdxCfgReq(PjDlUdxCfgReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXULSTAREP:
+                  {
+                     cmUnpkPjUdxUlStaRep(PjDlUdxUlStaRep, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXDLSTAREP:
+                  {
+                     cmUnpkPjUdxDlStaRep(PjDlUdxDlStaRep, pst, mBuf);
+                     break;
+                  }            
+
+            case EVTUDXULROHCFDB:
+                  {
+                      cmUnpkPjUdxUlFdbkPkt(PjDlUdxUlFdbkPktInfo, pst, mBuf);
+                      break;
+                  }
+
+            case EVTUDXDLROHCFDB:
+                  {
+                      cmUnpkPjUdxDlFdbkPkt(PjDlUdxDlFdbkPktInfo, pst, mBuf);
+                      break;
+                  }
+            
+            case EVTUDXREESTREQ:
+                  {
+                     cmUnpkPjUdxReEstReq(PjDlUdxReEstReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXSECCFGREQ:
+                  {
+                     cmUnpkPjUdxSecCfgReq(PjDlUdxSecCfgReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXUEIDCHGREQ:
+                  {
+                     cmUnpkPjUdxUeIdChgReq(PjDlUdxUeIdChgReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXCOUNTREQ:
+                  {
+                     cmUnpkPjUdxCountReq(PjDlUdxCountReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXSDUSTAREQ:
+                  {
+                     cmUnpkPjUdxSduStaReq(PjDlUdxSduStaReq, pst, mBuf);
+                     break;
+                  }
+             case EVTUDXDATRESUME:
+                  {
+#ifdef FLAT_BUFFER_OPT
+                       cmUnpkPjUdxDatResumeReq(PjDlUdxDatResumeReq, pst, mBuf);
+#else
+                       cmUnpkPjUdxDatResumeReq(PjDlUdxDatResumeReq, pst, mBuf);
+#endif
+                       break;
+                  }
+             case EVTUDXDATFRWD:
+                  {
+#ifdef FLAT_BUFFER_OPT
+                     printf("Received Event EVTUDXDATFRWD at PDCP DL \n");
+                     cmUnpkPjUdxDatForwardReq(PjDlUdxDatForwardReqFB, pst, mBuf);
+#else
+                     cmUnpkPjUdxDatForwardReq(PjDlUdxDatForwardReq, pst, mBuf);
+#endif
+                     break;
+                  }
+#ifdef LTE_L2_MEAS
+               case PJ_UDX_EVT_L2MEAS_REQ:
+                  {
+                     ret = cmUnpkPjUdxL2MeasReq(PjDlUdxL2MeasReq, pst, mBuf);
+                     break;
+                  }
+               case PJ_UDX_EVT_L2MEAS_SEND_REQ:
+                 {
+
+                    ret = cmUnpkPjUdxL2MeasSendReq(PjDlUdxL2MeasSendReq, pst, mBuf); 
+  
+                     break;
+                 }
+               case PJ_UDX_EVT_L2MEAS_STOP_REQ:
+                 {
+                     ret = cmUnpkPjUdxL2MeasStopReq(PjDlUdxL2MeasStopReq, pst, mBuf);
+                     break;
+                 }
+#endif
+               default:
+                  {
+                     RLOG0(L_ERROR, "Received Invalid Event from PDCP UL");
+                     ret = RFAILED;
+                     break;
+                  }
+#endif  /* LCLPJ */
+            }
+            break;
+         }
+
+
+      case ENTNH:
+         {
+            switch(pst->event)
+            {
+#ifdef LCPJU
+               case EVTPJUBNDREQ:
+                  {
+                     cmUnpkPjuBndReq(PjUiPjuBndReq, pst, mBuf);
+                     break;
+                  }
+
+               case EVTPJUUBNDREQ:
+                  {
+                     cmUnpkPjuUbndReq(PjUiPjuUbndReq, pst, mBuf);
+                     break;
+                  }
+
+               case EVTPJUDATREQ:
+                  {
+                     cmUnpkPjuDatReq(PjUiPjuDatReq, pst, mBuf);
+                     break;
+                  }
+
+               case EVTPJUDATFWDREQ:
+                  {
+                     cmUnpkPjuDatFwdReq(PjUiPjuDatFwdReq, pst, mBuf);
+                     break;
+                  }
+#endif /* LCPJU */
+               default:
+                  SPutMsg(mBuf);
+                  RLOG0(L_ERROR, " Received Invalid Event From RRC");
+                  ret = RFAILED;
+                  break;
+
+            }
+            break;
+         }
+
+      case ENTPX:
+         {
+            switch(pst->event)
+            {
+#ifdef LCPJU
+               case EVTPJUBNDREQ:
+                  {
+                     cmUnpkPjuBndReq(PjUiPjuBndReq, pst, mBuf);
+                     break;
+                  }
+
+               case EVTPJUUBNDREQ:
+                  {
+                     cmUnpkPjuUbndReq(PjUiPjuUbndReq, pst, mBuf);
+                     break;
+                  }
+
+               case EVTPJUDATREQ:
+                  {
+#ifdef SS_RBUF
+                     cmUnpkFpPjuDatReq(PjUiPjuDatReq, pst, mBuf);
+#else
+                     cmUnpkPjuDatReq(PjUiPjuDatReq, pst, mBuf);
+#endif
+                     break;
+                  }
+
+               case EVTPJUDATFWDREQ:
+                  {
+                     cmUnpkPjuDatFwdReq(PjUiPjuDatFwdReq, pst, mBuf);
+                     break;
+                  }
+#endif
+#ifdef PCAP_IP_DATGEN_LOAD_5GTF
+               case EVTPCAPIPDATIND:
+                  {
+                    //printf("ENTPX!!!!EVTPCAPIPDATIND:\n\r ");
+                     //RLOG0(L_ERROR, " Received Invalid Event from Relay");
+                     wrDamPcapDatInd(mBuf);
+                    break;
+                  }
+#endif
+               default:
+                  SPutMsg(mBuf);
+                  RLOG0(L_ERROR, " Received Invalid Event from Relay");
+                  ret = RFAILED;
+                  break;
+            }
+            break;
+         }
+
+      case ENTOC:
+         {
+            switch(pst->event)
+            {
+#ifdef PJ_CMP_ASYNC
+               /* Compression Confirmations */
+               case OBD_EVT_CMP_INIT_CFM:
+                  ret = cmUnpkLibObdCmpInitCfm(PjLibObdCmpInitCfm, pst,mBuf);
+                  break;
+
+               case OBD_EVT_CMP_CFM:
+                  ret = cmUnpkLibObdCmpCfm(PjLibObdCmpCfm, pst, mBuf);
+                  break;
+
+#endif /* PJ_CMP_ASYNC */
+               default:
+                  SPutMsg(mBuf);
+                  RLOG0(L_ERROR, "Received Invalid Event from Offboard Ciphering");
+                  ret = RFAILED;
+                  break;
+            }
+            break;
+         }
+
+      case ENTOS:
+         {
+            switch(pst->event)
+            {
+#ifdef PJ_SEC_ASYNC
+                  /* Integrity Confirmations */
+               case OBD_EVT_INT_INIT_CFM:
+                  ret = cmUnpkLibObdIntInitCfm(PjLibObdIntInitCfm, pst, mBuf);
+                  break;
+
+               case OBD_EVT_INT_PROT_CFM:
+                  ret = cmUnpkLibObdIntProtCfm(PjLibObdIntProtCfm, pst, mBuf);
+                  break;
+
+                  /* Ciphering Confirmations */
+               case OBD_EVT_CP_INIT_CFM:
+                  ret = cmUnpkLibObdCpInitCfm(PjLibObdCpInitCfm, pst, mBuf);
+                  break;
+
+               case OBD_EVT_UP_INIT_CFM:
+                  ret = cmUnpkLibObdUpInitCfm(PjLibObdUpInitCfm, pst, mBuf);
+                  break;
+
+               case OBD_EVT_CIPHER_CFM:
+                  ret = cmUnpkLibObdCipherCfm(PjLibObdCipherCfm, pst, mBuf);
+                  break;
+
+#endif /* PJ_SEC_ASYNC */
+               default:
+                  SPutMsg(mBuf);
+                  RLOG0(L_ERROR, "Received Invalid Event from Offboard Security");
+                  ret = RFAILED;
+                  break;
+            }
+            break;
+         }
+      case ENTKW:
+         {
+            switch(pst->event)
+            {
+#ifdef LCKWU
+               case KWU_EVT_BND_CFM:     /* Bind request */
+                  {
+                     ret = cmUnpkKwuBndCfm(PjLiKwuBndCfm, pst, mBuf );
+                     break;
+                  }
+
+                case KWU_EVT_DAT_CFM:    /* Dedicated Channel Data request */
+                  {
+                     ret = cmUnpkKwuDatCfm(PjLiKwuDatCfm, pst, mBuf);
+                     break;
+                  }
+
+               case KWU_EVT_DISC_SDU_REQ:    /* Coomon Channel Status Response */
+                  {
+                     ret = cmUnpkKwuDiscSduReq(PjLiKwuDiscSduReq, pst , mBuf);
+                     break;
+                  }
+
+               case KWU_EVT_STA_IND:    /* Dedicated Channel Status Response */
+                  {
+                     ret = cmUnpkKwuStaInd(PjLiKwuStaInd, pst, mBuf);
+                     break;
+                  }
+               case KWU_EVT_DISC_SDU_CFM:    /* Harq status indication */
+                  {
+                     ret = cmUnpkKwuDiscSduCfm(PjLiKwuDiscSduCfm, pst, mBuf);
+                     break;
+                  }
+               case KWU_EVT_FLOW_CNTRL_IND:    /* Flow control indication*/
+                  {
+                     ret = cmUnpkKwuFlowCntrlInd(PjLiKwuFlowCntrlInd, pst, mBuf);
+                     break;
+                  }
+               default:
+                  {
+                     SPutMsg(mBuf);
+                     RLOG0(L_ERROR, "Received Invalid Event from RLC");
+                     ret = RFAILED;
+                     break;
+                   }
+
+#endif  /* LCRGU */
+            }
+            break;
+         }
+#ifdef TENB_AS_SECURITY
+      case ENTYS:
+         {
+            switch(pst->event)
+            {
+               case EVTPJUTTIIND:
+               {
+#ifndef SS_RBUF
+                  static U32 ttitick = 0;
+#endif
+
+                  ysPjPrcTtiInd++; /* UDAY */
+                  SPutMsg(mBuf);
+                  /*Trigger batching of the packets queued for ciphering
+                   * and deciphering*/
+                  /*Note: UL trigger should be posted to UL thread if UL
+                   * and DL are on different threads.*/
+#ifndef L2_L3_SPLIT
+#ifdef MAC_RLC_UL_RBUF
+                        kwUlBatchProc();
+#endif 
+#endif 
+#ifdef XEON_SPECIFIC_CHANGES 
+#ifdef INTEL_QAT_DP
+                        PjCb  *tPjCb = PJ_GET_PJCB(pst->dstInst);
+                        pjPollQatDat(tPjCb,ttitick);
+#endif /* INTEL_QAT_DP */
+#else
+#ifndef SS_RBUF
+                  pjProcessSpaccRdWr(ttitick);
+#endif
+#endif
+#if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
+#ifndef UL_RLC_NET_CLUSTER
+                  pjUlBatchProcSplit();
+#endif
+#endif
+#ifndef SS_RBUF
+                  ttitick++;
+#endif
+#ifdef LC_EGTP_THREAD
+                  egWrReadRingBuf(SS_RNG_BUF_EGTP_FREE_RING);
+#endif
+                  break;
+               } 
+            }
+            break;
+         }
+#endif
+#ifdef SS_RBUF
+      case ENTTF:
+      {
+            switch(pst->event)
+            {
+               case EVTCTFBTCHPROCTICK:
+               {
+                  pjBatchProcTick();
+                  break;
+               }
+               case EVTCTFNRTRBUFCLEAN:
+               {
+                  pjRBufFreeMsg();
+               }
+             }
+         SPutMsg(mBuf);
+         break;
+      }
+#endif
+      default:
+         {
+            RLOG0(L_ERROR, "Recieved Invalid Source Entity ");
+            SPutMsg(mBuf);
+            ret = RFAILED;
+            break;
+         }
+   }
+
+   SExitTsk();
+
+   RETVALUE(ret);
+} /* pjActvTsk */
+
+\f  
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_dl_utl.c b/src/5gnrpdcp/pj_dl_utl.c
new file mode 100755 (executable)
index 0000000..b236af7
--- /dev/null
@@ -0,0 +1,2710 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/**********************************************************************
+
+     Name:     LTE-PDCP Layer
+  
+     Type:     C file
+  
+     Desc:     Source code for PDCP Utility Module
+
+               This file contains following functions:
+
+                  --PjLibObdCmpCfm
+                  --PjLibObdIntProtCfm
+                  --PjLibObdCipherCfm
+                  --PjLibObdDecipherCfm
+                  --PjLibObdIntVerCfm
+                  --PjLibObdDecmpCfm
+                  -- pjUtlCmpReq
+                  -- pjUtlCipherReq
+                  -- pjUtlIntProtReq
+  
+     File:     pj_dl_utl.c
+
+**********************************************************************/
+ static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=218;
+
+/** @file pj_dl_utl.c 
+@brief PDCP Utility Module 
+*/
+
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "cpj.h"                /* CPJ defines */
+#include "pju.h"                /* PJU defines */
+#include "lpj.h"                /* LPJ defines */
+
+#include "pj_env.h"        /* RLC environment options */
+#include "pj.h"            /* RLC defines */
+#include "pj_dl.h"
+#include "pj_err.h"        /* Error defines */
+#include "pj_udx.h"
+#include "pj_ptsec.h"
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "cpj.x"                /* CPJ */
+#include "pju.x"                /* PJU */
+#include "lpj.x"                /* LPJ */
+#include "pj.x"
+#include "pj_udx.h"
+#include "pj_udx.x"
+#include "pj_dl.x"
+#include "pj_lib.x"          /* LIB */
+
+
+EXTERN CmLListCp pjMsCiphQ;
+EXTERN CmLListCp pjMsDeCiphQ;
+#ifndef XEON_SPECIFIC_CHANGES
+EXTERN U32 dbgPdcpMemCount,pdcpdrop, dbgSpaccThreshHoldDropCnt;
+EXTERN U32 dbgPdcpQSizeThreshHoldDropCnt;
+U32 spaccDropCount = 0;
+EXTERN U32 pjMsDlSpaccQCnt;
+EXTERN U32 pjMsUlSpaccQCnt;
+#endif
+#ifdef __cplusplus
+EXTERN "C" {
+#endif /* __cplusplus */
+
+#ifdef INTEL_SW_SEC 
+EXTERN S16 PjLibObdSwCipherReq(PjLibTrans  *libTrans, Buffer *mBuf, PjCb *gCb, Buffer **opSdu);
+
+EXTERN S16 pjSendToSwCipherFB ARGS((PjLibTrans *libTrans, FlatBuffer *mBuf,
+                                           PjCb *gCb, Buffer **opSdu));
+#endif
+
+PUBLIC S16 pjUtlReEstDl 
+(
+PjCb        *gCb,
+PjDlUeCb       *ueCb           /* UE Control Block */ 
+);
+
+PRIVATE S16 pjUtlDlHdlSecInitCfm ARGS((PjCb *gCb,PjDlUeCb *ueCb, 
+              U16 txIdx,PjAsyncCfm *asyncCfm, UdxSecCfgCfmInfo *secCfgCfm,UdxReEstCfmInfo *reEstCfm));
+PRIVATE S16 pjUtlDlHdlCmpInitCfm ARGS((PjCb *gCb,PjDlUeCb *ueCb, 
+              U16 txIdx,PjAsyncCfm *asyncCfm, UdxCfgCfmInfo *cfgCfm));
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to apply the new security algorithms and 
+ *        reset the compression unit.
+ *
+ * @b Description:
+ *
+ *        This function 
+ *        1. Creates new contexts for Control Plane Ciphering and Integrity.
+ *        2. Closes the old contexts for Control Plane Ciphering and Integrity.
+ *
+ *  @param[in] ueCb   UE Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlDlUpdUpSecKeys
+(
+PjCb       *gCb,
+PjDlUeCb   *ueCb           /* UE Control Block */ 
+)
+#else
+PUBLIC S16 pjUtlDlUpdUpSecKeys(gCb,ueCb)
+PjCb         *gCb;
+PjDlUeCb     *ueCb;           /* UE Control Block */ 
+#endif
+{
+   Void     *tmpUpCxt;
+
+   TRC2(pjUtlDlUpdUpSecKeys);
+
+   RLOG2(L_DEBUG, "pjUtlReEstReconfig(ueCb(%d,%d))",
+         ueCb->key.ueId, ueCb->key.cellId);
+
+   if(ueCb->secInfo.secAct == TRUE)
+   {
+      /* Initialisation is done first followed by closure since we
+       * do not want the same ctxId to be returned for the new init.
+       * In ASYNC case, we drop packets if they are returned from a
+       * different ctxId. */
+
+#ifdef INTEL_QAT_DP
+      tmpUpCxt  = ueCb->secInfo.upCiphSessCxtId;
+#else
+      tmpUpCxt  = ueCb->secInfo.upCxtId;    
+#endif
+
+      pjUtlDlUpInit(gCb,ueCb);
+      pjUtlDlCipherClose(gCb,tmpUpCxt);
+   }
+
+   RETVALUE(ROK);
+} /* pjUtlDlUpdUpSecKeys */
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to apply the new security algorithms and 
+ *        reset the compression unit.
+ *
+ * @b Description:
+ *
+ *        This function 
+ *        1. Creates new contexts for Control Plane Ciphering and Integrity.
+ *        2. Closes the old contexts for Control Plane Ciphering and Integrity.
+ *
+ *  @param[in] ueCb   UE Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlDlUpdCpSecKeys
+(
+PjCb       *gCb,
+PjDlUeCb   *ueCb           /* UE Control Block */ 
+)
+#else
+PUBLIC S16 pjUtlDlUpdCpSecKeys(gCb,ueCb)
+PjCb         *gCb;
+PjDlUeCb     *ueCb;           /* UE Control Block */ 
+#endif
+{
+   Void     *tmpIntCxt;
+   Void     *tmpCpCxt;
+
+   TRC2(pjUtlDlUpdCpSecKeys);
+
+   RLOG2(L_DEBUG, "pjUtlReEstReconfig(ueCb(%d,%d))",
+         ueCb->key.ueId, ueCb->key.cellId);
+
+   if(ueCb->secInfo.secAct == TRUE)
+   {
+      /* Initialisation is done first followed by closure since we
+       * do not want the same ctxId to be returned for the new init.
+       * In ASYNC case, we drop packets if they are returned from a
+       * different ctxId. */
+
+#ifdef INTEL_QAT_DP
+      tmpIntCxt = ueCb->secInfo.cpIntSessCxtId;
+      tmpCpCxt  = ueCb->secInfo.cpCiphSessCxtId;
+#else
+      tmpIntCxt = ueCb->secInfo.intCxtId;  
+      tmpCpCxt  = ueCb->secInfo.cpCxtId;    
+#endif
+
+      pjUtlDlCpInit(gCb,ueCb);
+      pjUtlDlIntInit(gCb,ueCb);
+
+      pjUtlDlIntClose(gCb,tmpIntCxt);
+      pjUtlDlCipherClose(gCb,tmpCpCxt);
+
+   }
+
+   RETVALUE(ROK);
+
+} /* pjUtlDlUpdCpSecKeys */
+
+/********************************************************************
+ *    Utility Handler for Sending to Offboarding unit               *
+ *******************************************************************/
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler for opening the context with the compression unit (either 
+ *        synchronous or asynchronous) for RB within an UE.
+ *
+ * @b Description:
+ *
+ *        This function opens the context with the compression unit per RB per
+ *        UE, by sending ROHC configuration elements using synchronous / asynchronous 
+ *        function calls with relevant input parameters.
+ *
+ *
+ *  @param[in]  pjRbCb   PDCP RbCb
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlDlCmpInit
+(
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb                  /* PDCP RbCb */
+)
+#else
+PUBLIC S16 pjUtlDlCmpInit(pjRbCb)
+PjCb       *gCb;
+PjDlRbCb   *pjRbCb;                 /* PDCP RbCb */
+#endif
+{
+   TRC3(pjUtlDlCmpInit)
+
+   RLOG2(L_DEBUG, "pjUtlDlCmpInit(pjRbCb(%d,%d))",pjRbCb->rbId, pjRbCb->rbType);
+#ifdef PJ_CMP_ASYNC
+
+   pjRbCb->ueCb->libInfo.tCmpInitBitMask |= (1 << (pjRbCb->rbId - 1));
+   pjRbCb->ueCb->libInfo.tLibInitBitMask |= PJ_LIB_COMP_BIT_MASK;
+   pjRbCb->cmpCxt.cfgTxId  =  pjRbCb->ueCb->libInfo.nxtAvlbTxId;
+
+   PjLibObdCmpInitReq(&gCb->pjGenCfg.obdPst.cmpPst, 
+                                    pjRbCb->cmpCxt, pjRbCb->rohc);
+#else
+   pjLibCmpInitReq(pjRbCb->cmpCxt, pjRbCb->rohc, &(pjRbCb->cmpCxtId));
+#endif  /* PJ_CMP_ASYNC */
+
+   RETVALUE(ROK);
+
+} /* end of pjUtlCmpInit */
+\f
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for opening the context with the Integration unit (either 
+ *        synchronous or asynchronous) for all SRBs of an UE.
+ *
+ * @b Description:
+ *
+ *        This function opens the context with the security algo unit per UE
+ *        for Integration protection/verification by sending the configured
+ *        Integrity Info using synchronous / asynchronous function calls with 
+ *        relevant input parameters.
+ *
+ *  @param[in]  pjRbCb     Pointer to RB control Block
+ *
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlDlIntInit
+(
+PjCb     *gCb,
+PjDlUeCb   *ueCb                   /* UE CB Ptr */
+)
+#else
+PUBLIC S16 pjUtlDlIntInit(*gCb, *ueCb)
+PjCb     *gCb;
+PjDlUeCb   *ueCb;                   /* UE CB Ptr */
+#endif
+{
+
+   S16 ret=ROK;
+   Void *ctxId = NULLP;   
+#ifdef PJ_SEC_ASYNC
+   U8  txIdx;
+   U32 *libInitBitMask = NULLP;
+#endif
+   
+   TRC3(pjUtlDlIntInit)
+
+   RLOG2(L_DEBUG, "pjUtlDlIntInit(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
+
+#ifdef PJ_SEC_ASYNC
+
+   if(ueCb->libInfo.state == PJ_STATE_REEST)
+   {
+      for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
+      {
+         if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
+               (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM))
+         {
+            libInitBitMask =  &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask;
+            break;
+         }
+      }
+   }
+   else if(ueCb->libInfo.state == PJ_STATE_NORMAL)
+   {
+      libInitBitMask =  &ueCb->libInfo.tLibInitBitMask;
+   }
+
+   if(libInitBitMask)
+   {
+      (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_INT_BIT_MASK;
+   }
+
+   ret = PjLibObdIntInitReq(&gCb->pjGenCfg.obdPst.secPst, 
+                           ueCb->secInfo.secCxt, ueCb->secInfo.intInfo);
+#else
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+   pjLibIntInitReq(gCb->u.dlCb->instHndl, ueCb->secInfo.intInfo,&ctxId);
+#else
+   pjLibIntInitReq(gCb, ueCb->secInfo.intInfo,&ctxId);
+#endif
+   ueCb->secInfo.cpIntSessCxtId  =  ctxId;
+#else
+   pjLibIntInitReq(ueCb->secInfo.secCxt, ueCb->secInfo.intInfo,&(ctxId));
+   ueCb->secInfo.intCxtId    =  ctxId;
+#endif /* INTEL_QAT_DP */
+#endif /* PJ_SEC_ASYNC */
+
+   RETVALUE(ret);
+
+} /* end of pjUtlIntInit */
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler for opening the context with the Ciphering unit (either 
+ *        synchronous or asynchronous) for SRBs of an UE.
+ *
+ * @b Description:
+ *
+ *        This function opens the context with the security algo unit per UE
+ *        for ciphering / deciphering by key by sending the configured
+ *        Ciphering Info with control plane key using synchronous / asynchronous 
+ *        function calls with relevant input parameters.
+ *
+ *  @param[in]  pjRbCb     Pointer to RB control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlDlCpInit
+(
+PjCb     *gCb,
+PjDlUeCb   *ueCb                    /* UE CB Ptr */
+)
+#else
+PUBLIC S16 pjUtlDlCpInit(*gCb, *ueCb)
+PjCb     *gCb;
+PjDlUeCb   *ueCb;                   /* UE CB Ptr */
+#endif
+{
+   Void *ctxId = NULLP;
+#ifdef PJ_SEC_ASYNC
+   U8  txIdx;
+   U32 *libInitBitMask = NULLP;
+#endif
+   S16   ret = ROK;
+
+   TRC3(pjUtlDlCpInit)
+
+   RLOG2(L_DEBUG, "pjUtlCpInit(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
+
+#ifdef PJ_SEC_ASYNC
+
+   if(ueCb->libInfo.state == PJ_STATE_REEST)
+   {
+      for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
+      {
+         if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
+               (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM))
+         {
+            libInitBitMask =  &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask;
+            break;
+         }
+      }
+   }
+   else if(ueCb->libInfo.state == PJ_STATE_NORMAL)
+   {
+      libInitBitMask =  &ueCb->libInfo.tLibInitBitMask;
+   }
+
+   if(libInitBitMask)
+   {
+      (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_CP_CIP_BIT_MASK;
+   }
+   ret = PjLibObdCpInitReq(&gCb->pjGenCfg.obdPst.secPst, ueCb->secInfo.secCxt, 
+         ueCb->secInfo.cipherInfo.algoType, ueCb->secInfo.cipherInfo.cpKey);
+#else
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+   ret = pjLibCpInitReq(gCb->u.dlCb->instHndl, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
+         ueCb->secInfo.cipherInfo.cpKey, &ctxId);
+#else
+  ret = pjLibCpInitReq(gCb, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
+                  ueCb->secInfo.cipherInfo.cpKey, &ctxId); 
+#endif
+   ueCb->secInfo.cpCiphSessCxtId= ctxId;
+#else
+   ret = pjLibCpInitReq(ueCb->secInfo.secCxt, (U8)ueCb->secInfo.cipherInfo.algoType,
+                  ueCb->secInfo.cipherInfo.cpKey, &ctxId);    /*KW_FIX*/
+   ueCb->secInfo.cpCxtId = ctxId;
+#endif /* INTEL_QAT_DP */
+#endif /* PJ_SEC_ASYNC */
+
+   RETVALUE(ret);
+
+} /* end of pjUtlCpInit */
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for opening the context with the Ciphering unit (either 
+ *        synchronous or asynchronous) for DRBs of an UE.
+ *
+ * @b Description:
+ *
+ *        This function opens the context with the security algo unit per UE
+ *        for ciphering / deciphering by sending the configured
+ *        Ciphering Info with user plane key using synchronous / asynchronous 
+ *        function calls with relevant input parameters.
+ *
+ *  @param[in]  pjRbCb     Pointer to RB control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlDlUpInit
+(
+PjCb     *gCb,
+PjDlUeCb   *ueCb                    /* UE CB Ptr */
+)
+#else
+PUBLIC S16 pjUtlDlUpInit(*gCb,*ueCb) 
+PjCb     *gCb;
+PjDlUeCb   *ueCb;                   /* UE CB Ptr */
+#endif
+{
+
+   Void  *ctxId = NULLP;
+#ifdef PJ_SEC_ASYNC
+   U8  txIdx;
+   U32 *libInitBitMask = NULLP;
+#endif
+   S16 ret = ROK;
+
+   TRC3(pjUtlDlUpInit)
+
+   RLOG2(L_DEBUG, "pjUtlUpInit(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
+
+#ifdef PJ_SEC_ASYNC
+
+   if(ueCb->libInfo.state == PJ_STATE_REEST)
+   {
+      for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
+      {
+         if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
+               (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM))
+         {
+            libInitBitMask =  &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask;
+            break;
+         }
+      }
+   }
+   else if(ueCb->libInfo.state == PJ_STATE_NORMAL)
+   {
+      libInitBitMask =  &ueCb->libInfo.tLibInitBitMask;
+   }
+
+   if(libInitBitMask)
+      (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_UP_CIP_BIT_MASK;
+
+   ret = PjLibObdUpInitReq(&gCb->pjGenCfg.obdPst.secPst, ueCb->secInfo.secCxt, 
+         ueCb->secInfo.cipherInfo.algoType, ueCb->secInfo.cipherInfo.upKey);
+#else
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+   pjLibUpInitReq(gCb->u.dlCb->instHndl, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
+                              ueCb->secInfo.cipherInfo.upKey, &ctxId);
+#else
+   pjLibUpInitReq(gCb, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
+                              ueCb->secInfo.cipherInfo.upKey, &ctxId);
+#endif
+   ueCb->secInfo.upCiphSessCxtId= ctxId;
+#else
+   pjLibUpInitReq(ueCb->secInfo.secCxt, (U8)ueCb->secInfo.cipherInfo.algoType, 
+                              ueCb->secInfo.cipherInfo.upKey, &ctxId);   /*KW_FIX*/
+   ueCb->secInfo.upCxtId = ctxId;
+#endif /* INTEL_QAT_DP */
+#endif /* PJ_SEC_ASYNC */
+   RETVALUE(ret);
+} /* end of pjUtlUpInit */
+
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for redirecing ciphering request to either synchronous
+ *        or asynchronous module.
+ *
+ * @b Description:
+ *
+ *        This function sends ciphering protection request as either synchronous or
+ *        asynchronous function calls with relevant input parameters.
+ *
+ *  @param[in]   pjRbCb           PDCP RbCb 
+ *  @param[in]   secInp           Input parameters for deciphering 
+ *  @param[in]   mBuf             Data to be deciphered 
+ *  @param[in]   opSdu            Deciphered SDU 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+//#ifdef TENB_AS_SECURITY
+#ifdef ANSI
+PUBLIC S16 pjUtlCipherReq
+(
+PjCb     *gCb,
+PjDlRbCb   *pjRbCb,              /* PDCP RbCb */
+U32      count,                  /* Input parameters for deciphering */ 
+Buffer   *mBuf,                  /* Data to be deciphered */
+Buffer   **opSdu                 /* Deciphered SDU */
+)
+#else
+PUBLIC S16 pjUtlCipherReq(gCb, pjRbCb, count, mBuf, opSdu)
+PjCb     *gCb,
+PjDlRbCb   *pjRbCb;               /* PDCP RbCb */
+U32      count;                   /* Input parameters for deciphering */ 
+Buffer   *mBuf;                   /* Data to be deciphered */
+Buffer   **opSdu;                 /* Deciphered SDU */
+#endif
+{
+   S16 ret = ROK;
+   PjDlUeCb *dlUeCb;
+   PjLibTrans libTrans; /* Transaction Id for deciphering */
+
+#if PJ_SEC_ASYNC
+   Void   *cxtId;    /* Context Identifier */
+#endif
+
+   TRC3(pjUtlCipherReq)
+
+   dlUeCb = pjRbCb->ueCb;
+   libTrans.pdcpInstance = gCb->init.inst;
+   libTrans.count = count;
+
+   libTrans.rbId = pjRbCb->rbId - 1;
+   libTrans.dir = PJ_SEC_DIR_DL;
+   libTrans.rbType = pjRbCb->rbType;
+   libTrans.snLen = pjRbCb->snLen;
+   libTrans.ciphAlgoType = dlUeCb->secInfo.cipherInfo.algoType;
+   libTrans.ueCb = (PTR)dlUeCb;
+   libTrans.ueId = dlUeCb->key.ueId;
+   libTrans.cellId = dlUeCb->key.cellId;
+   if(PJ_SRB == pjRbCb->rbType)
+   {
+      libTrans.key = dlUeCb->secInfo.cipherInfo.cpKey;
+#ifdef INTEL_QAT_DP
+      libTrans.sessCxtId = dlUeCb->secInfo.cpCiphSessCxtId;
+#ifdef QAT_TWO_INSTANCE
+      libTrans.instHndl = gCb->u.dlCb->instHndl;
+#else
+      libTrans.instHndl = gCb->instHndl;
+#endif
+#endif
+   }
+   else
+   {
+      libTrans.key = dlUeCb->secInfo.cipherInfo.upKey;
+#ifdef INTEL_QAT_DP
+      libTrans.sessCxtId = dlUeCb->secInfo.upCiphSessCxtId;
+#ifdef QAT_TWO_INSTANCE
+      libTrans.instHndl = gCb->u.dlCb->instHndl;
+#else
+      libTrans.instHndl = gCb->instHndl;
+#endif
+#endif
+   }
+
+#ifdef PJ_SEC_ASYNC
+   /* Start the timer if it is not started already */
+   if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR)) == FALSE)
+   {
+      pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR);
+   }
+
+   if (pjRbCb->rbType == PJ_SRB)
+   {
+      cxtId = pjRbCb->ueCb->secInfo.cpCxtId;
+   }
+   else
+   {
+      cxtId = pjRbCb->ueCb->secInfo.upCxtId;
+   } 
+
+   ret = PjLibObdCipherReq(&(gCb->pjGenCfg.obdPst.secPst), cxtId, 
+                                             secInp, libTrans, mBuf);
+
+#else
+#ifdef INTEL_SW_SEC
+   ret = PjLibObdSwCipherReq(&libTrans, mBuf, gCb,opSdu);
+#else
+   ret = PjLibObdCipherReq(&libTrans, mBuf, opSdu);
+#endif /* INTEL_SW_SEC */
+#endif
+
+   RETVALUE(ret);
+
+}
+
+
+#ifdef FLAT_BUFFER_OPT
+/**
+ *
+ * @brief 
+ *
+ *        Handler for redirecing ciphering request to either synchronous
+ *        or asynchronous module.
+ *
+ * @b Description:
+ *
+ *        This function sends ciphering protection request as either synchronous or
+ *        asynchronous function calls with relevant input parameters.
+ *
+ *  @param[in]   pjRbCb           PDCP RbCb 
+ *  @param[in]   secInp           Input parameters for deciphering 
+ *  @param[in]   mBuf             Flat Buffer to be deciphered 
+ *  @param[in]   opSdu            Deciphered SDU 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUtlCipherReqFB
+(
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb,                /* PDCP RbCb */
+U32        count,                  /* Input parameters for deciphering */ 
+FlatBuffer *mBuf,                  /* Data to be deciphered */
+Buffer     **opSdu                 /* Deciphered SDU */
+)
+#else
+PUBLIC S16 pjUtlCipherReqFB(gCb, pjRbCb, count, mBuf, opSdu)
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb;                /* PDCP RbCb */
+U32        count;                  /* Input parameters for deciphering */ 
+FlatBuffer *mBuf;                  /* Data to be deciphered */
+Buffer     **opSdu;                /* Deciphered SDU */
+#endif
+{
+   S16 ret = ROK;
+#ifdef PJ_SEC_ASYNC
+   Void   *cxtId;    /* Context Identifier */
+#endif
+   PjDlUeCb *dlUeCb;
+   PjLibTrans libTrans;
+
+   TRC3(pjUtlCipherReqFB)
+
+#ifdef PJ_SEC_ASYNC
+   cxtId = pjRbCb->ueCb->secInfo.upCxtId;
+#endif
+
+   dlUeCb = pjRbCb->ueCb;
+   libTrans.pdcpInstance = gCb->init.inst;
+   libTrans.count = count;
+
+   libTrans.rbId = pjRbCb->rbId - 1;
+   libTrans.dir = PJ_SEC_DIR_DL;
+   libTrans.rbType = pjRbCb->rbType;
+   libTrans.snLen = pjRbCb->snLen;
+   libTrans.ciphAlgoType = dlUeCb->secInfo.cipherInfo.algoType;
+   libTrans.ueCb = (PTR)dlUeCb;
+   libTrans.ueId = dlUeCb->key.ueId;
+   libTrans.cellId = dlUeCb->key.cellId;
+   if(PJ_SRB == pjRbCb->rbType)
+   {
+      libTrans.key = dlUeCb->secInfo.cipherInfo.cpKey;
+#ifdef INTEL_QAT_DP
+      libTrans.sessCxtId = dlUeCb->secInfo.cpCiphSessCxtId;
+#ifdef QAT_TWO_INSTANCE
+      libTrans.instHndl = gCb->u.dlCb->instHndl;
+#else
+      libTrans.instHndl = gCb->instHndl;
+#endif
+#endif
+   }
+   else
+   {
+      libTrans.key = dlUeCb->secInfo.cipherInfo.upKey;
+#ifdef INTEL_QAT_DP
+          libTrans.sessCxtId = dlUeCb->secInfo.upCiphSessCxtId;
+#ifdef QAT_TWO_INSTANCE
+      libTrans.instHndl = gCb->u.dlCb->instHndl;
+#else
+          libTrans.instHndl = gCb->instHndl;
+#endif
+#endif
+   }
+
+#ifdef PJ_SEC_ASYNC
+   /* Start the timer if it is not started already */
+   if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR)) == FALSE)
+   {
+      pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR);
+   }
+
+   ret = PjLibObdCipherReq(&(gCb->pjGenCfg.obdPst.secPst), cxtId, 
+                                             secInp, libTrans, mBuf);  
+
+#else
+#ifndef INTEL_SW_SEC
+      ret = PjLibObdCipherReqFB(&libTrans, mBuf, opSdu);
+#else
+      ret = pjSendToSwCipherFB(&libTrans, mBuf,gCb,opSdu);
+#endif
+#endif
+
+   RETVALUE(ret);
+
+}
+#endif
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for redirecing Integration request to either synchronous
+ *        or asynchronous module.
+ *
+ * @b Description:
+ *
+ *        This function sends Intergrity protection request as either synchronous or
+ *        asynchronous function calls with relevant input parameters.
+ *
+ *  @param[in]   pjRbCb       PDCP RbCb 
+ *  @param[in]   secInp       Input parameters for integrity 
+ *  @param[in]   mBuf         SDU to be compressed 
+ *  @param[out]  macI         Message authentication code for the SDU 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlIntProtReq
+(
+PjCb     *gCb,
+PjDlRbCb   *pjRbCb,             /* PDCP RbCb */
+PjSecInp secInp,              /* Input parameters for integrity */ 
+Buffer   **mBuf               /* SDU to be compressed */
+)
+#else
+PUBLIC S16 pjUtlIntProtReq(gCb, pjRbCb, secInp, mBuf)
+PjCb     *gCb;
+PjDlRbCb   *pjRbCb;             /* PDCP RbCb */
+PjSecInp secInp;              /* Input parameters for integrity */ 
+Buffer   **mBuf;               /* SDU to be compressed */
+#endif
+{
+   S16 ret = ROK;
+   PjDlUeCb *dlUeCb;
+   PjLibTrans libTrans;
+#if PJ_SEC_ASYNC
+   Void   *cxtId;    /* Context Identifier */
+#endif
+
+   TRC3(pjUtlIntProtReq)
+
+#if PJ_SEC_ASYNC
+   cxtId = pjRbCb->ueCb->secInfo.intCxtId;
+#endif
+
+   dlUeCb = pjRbCb->ueCb;
+   libTrans.pdcpInstance = gCb->init.inst;
+   libTrans.count = secInp.count;
+   libTrans.rbId = pjRbCb->rbId - 1;
+   libTrans.dir = secInp.dir;
+   libTrans.rbType = pjRbCb->rbType;
+   /*pSecInfo.snLen = pjRbCb->snLen;*/
+   libTrans.intAlgoType = dlUeCb->secInfo.intInfo.algoType;
+   libTrans.ueCb = (PTR)dlUeCb;
+   libTrans.ueId = dlUeCb->key.ueId;
+   libTrans.cellId = dlUeCb->key.cellId;
+   libTrans.key = &(dlUeCb->secInfo.intInfo.intKey[0]);
+   PJ_SEC_FILL_FRESH(libTrans.fresh, libTrans.rbId);
+   
+#ifdef INTEL_QAT_DP
+   libTrans.sessCxtId = dlUeCb->secInfo.cpIntSessCxtId;
+#ifdef QAT_TWO_INSTNACES
+   libTrans.instHndl = gCb->u.dlCb->instHndl;
+#else
+   libTrans.instHndl = gCb->instHndl;
+#endif
+#endif
+
+#ifdef PJ_SEC_ASYNC
+   /* Start the timer if it is not started already */
+   if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR)) == FALSE)
+   {
+      pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR);
+   }
+
+   ret = PjLibObdIntProtReq(&(gCb->pjGenCfg.obdPst.secPst), cxtId, 
+                                 secInp, libTrans, mBuf);  
+
+#else
+#ifdef INTEL_SW_INTEG
+   ret = PjLibObdIntProtReq(gCb, &libTrans, mBuf);
+#else
+   ret = PjLibObdIntProtReq(&libTrans, mBuf);
+#endif /* INTEL_SW_INTEG */
+#endif
+
+   RETVALUE(ret);
+
+} /* end of pjUtlIntProtReq */
+
+//#endif
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for closing the DL context with the Ciphering unit (either 
+ *        synchronous or asynchronous) for SRBs of an UE.
+ *
+ * @b Description:
+ *
+ *        This function closes an existing DL context with the security algo unit per UE
+ *        for ciphering / deciphering with control plane key using synchronous / asynchronous 
+ *        function calls with relevant input parameters.
+ *
+ *
+ *  @param[in] cpCxtId          Context Id for Ciphering to be closed 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI 
+PUBLIC S16 pjUtlDlCipherClose
+(
+PjCb     *gCb,
+Void     *cpCxtId                  /* Context Id for Ciphering to be closed */
+)
+#else
+PUBLIC S16 pjUtlDlCipherClose(gCb, cpCxtId)
+PjCb     *gCb;
+Void     *cpCxtId;                 /* Context Id for Ciphering to be closed */
+#endif
+{
+#ifdef INTEL_QAT_DP
+   S16 ret;
+#endif
+   TRC3(pjUtlDlCipherClose)
+
+   RLOG0(L_DEBUG, "pjUtlDlCipherClose");
+
+#ifndef PJ_SEC_ASYNC
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+   ret = PjLibObdCipherCloseReq(gCb->u.dlCb->instHndl, cpCxtId);
+#else
+   ret = PjLibObdCipherCloseReq(gCb->instHndl, cpCxtId);
+#endif
+#else
+   PjLibObdCipherCloseReq(cpCxtId);
+#endif
+#else
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+   ret = PjLibObdCipherCloseReq(gCb->u.dlCb->instHndl, cpCxtId);
+#else
+   ret = PjLibObdCipherCloseReq(gCb->instHndl, cpCxtId);
+#endif
+#else
+   PjLibObdCipherCloseReq(&gCb->pjGenCfg.obdPst.secPst, cpCxtId);
+#endif
+#endif
+
+#ifdef INTEL_QAT_DP
+   RETVALUE(ret);
+#else
+   RETVALUE(ROK);
+#endif
+
+} /* end of pjUtlCipherClose */
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for closing the DL context with the Integration unit (either 
+ *        synchronous or asynchronous) for all RBs of an UE.
+ *
+ * @b Description:
+ *
+ *        This function closes an existing DL context with the security algo unit per UE
+ *        for Integration protection/verification using synchronous / asynchronous function 
+ *        calls with relevant input parameters.
+ *
+ *
+ *  @param[in] intCxtId        Integration CxtId to be closed 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI 
+PUBLIC S16 pjUtlDlIntClose
+(
+PjCb     *gCb,
+Void      *intCxtId                 /* Integration CxtId to be closed */
+)
+#else
+PUBLIC S16 pjUtlDlIntClose(gCb, intCxtId)
+PjCb     *gCb;
+Void      *intCxtId;                /* Integration CxtId to be closed */
+#endif
+{
+#ifdef INTEL_QAT_DP
+   S16 ret = ROK;
+#endif
+   TRC3(pjUtlDlIntClose)
+
+   RLOG0(L_DEBUG, "pjUtlDlIntClose");
+
+#ifdef PJ_SEC_ASYNC
+   PjLibObdIntCloseReq(&gCb->pjGenCfg.obdPst.secPst,intCxtId);
+#else   
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+   ret = PjLibObdIntCloseReq(gCb->u.dlCb->instHndl,intCxtId);
+#else
+   ret = PjLibObdIntCloseReq(gCb->instHndl,intCxtId);
+#endif
+#else
+   PjLibObdIntCloseReq(intCxtId);
+#endif /* INTEL_QAT_DP */
+#endif /* PJ_SEC_ASYNC */
+
+#ifdef INTEL_QAT_DP
+   RETVALUE(ret);
+#else
+   RETVALUE(ROK);
+#endif
+
+} /* end of pjUtlIntClose */
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for resetting the context with the compression unit (either 
+ *        synchronous or asynchronous) for RB within an UE.
+ *
+ * @b Description:
+ *
+ *        This function resets the context with the compression unit per RB per
+ *        UE by using synchronous / asynchronous function calls.
+ *
+ *
+ *  @param[in] cmpCxtId     Context to be reset for compression 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlDlCmpReset
+(
+PjCb        *gCb,
+PjDlRbCb      *pjRbCb                 /* Context to be reset for compression */
+)
+#else
+PUBLIC S16 pjUtlDlCmpReset(pjRbCb) 
+PjCb        *gCb;
+PjDlRbCb      *pjRbCb;                 /* Context to be reset for compression */
+#endif
+{
+   TRC3(pjUtlDlCmpReset)  
+
+   RLOG2(L_DEBUG, "pjUtlCmpReset(pjRbCb(%d,%d))",pjRbCb->rbId, pjRbCb->rbType);
+
+#ifdef PJ_CMP_ASYNC
+   PjLibObdCmpResetReq(&gCb->pjGenCfg.obdPst.cmpPst, pjRbCb->cmpCxtId);
+#else
+   pjLibCmpResetReq(pjRbCb->cmpCxtId);
+#endif
+
+   RETVALUE(ROK);
+
+} /* end of pjUtlCmpReset */
+
+
+/**
+ *
+ * @brief 
+ *        Handle re-establishment on SRB1. 
+ *
+ * @b Description:
+ *        This function 
+ *        1. Marks the state of the RBs as PJ_STATE_REEST.
+ *        2. Calculates the number of RBs undergoing reestablishment.
+ *
+ *  @param[in] gCb     PDCP Instance control block
+ *  @param[in] pjRbCb  Downlink Rb control block 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlDlReEstSrb1
+(
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb                    /* PDCP Control Block Pointer */
+)
+#else
+PUBLIC S16 pjUtlDlReEstSrb1(gCb, pjRbCb)
+PjCb       *gCb;
+PjDlRbCb   *pjRbCb;                   /* PDCP Control Block Pointer */
+#endif
+{
+   PjDlUeCb   *ueCb;
+
+   TRC2(pjUtlDlReEstSrb1)
+
+   RLOG2(L_DEBUG, "pjUtlReEstSrb1(pjRbCb(%d,%d))",pjRbCb->rbId, pjRbCb->rbType);
+
+   ueCb = pjRbCb->ueCb;
+
+   ueCb->libInfo.state  =  PJ_STATE_REEST;
+
+   /* SRB Reconfiguration we can update the control Plane keys and
+      the Integrity Keys in the OBD module */
+
+   pjUtlDlUpdCpSecKeys(gCb,ueCb);
+
+   /* Perform downlink reestablishment of SRB1 */
+   pjDlmReEstSrb(gCb,pjRbCb);
+
+   /*  If Only SRB1 configured then we can update userplane 
+       keys also */
+   if ((ueCb->numSrbs == 1) && (ueCb->numDrbs == 0))
+   {
+      pjUtlDlUpdUpSecKeys(gCb,ueCb);
+   }
+
+   RETVALUE(ROK);
+} /* pjUtlReEstSrb1 */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler to start reestablishment processing
+ *
+ * @b Description:
+ *
+ *        This function 
+ *        1. Marks the state of the RBs as PJ_STATE_REEST_HO.
+ *        2. Calculates the number of RBs undergoing reestablishment.
+ *
+ *  @param[in] ueCb    Number of RBs undergoing reestablishment
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlDlReEstHO
+(
+PjCb              *gCb,
+PjDlUeCb          *ueCb           /* Number of RBs undergoing reestablishment*/ 
+)
+#else
+PUBLIC S16 pjUtlDlReEstHO(gCb,ueCb)    
+PjCb              *gCb;
+PjDlUeCb          *ueCb;           /* Number of RBs undergoing reestablishment*/ 
+#endif
+{
+   U8             rbCnt;
+   PjDlRbCb     **rbCbLst;
+   PjDlRbCb     * pjRbCb;
+
+   TRC2 (pjUtlDlReEstHO); 
+
+#ifdef ALIGN_64BIT
+   RLOG2(L_DEBUG, "pjUtlReEstHO(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
+#else
+   RLOG2(L_DEBUG, "pjUtlReEstHO(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
+#endif
+
+   /* Initialisations */
+   ueCb->libInfo.numReEstDrb = 0;
+   ueCb->libInfo.state = PJ_STATE_REEST_HO;
+
+   /* Perform initialisations on the HO Info structure */
+   PJ_ALLOC(gCb,ueCb->hoInfo, sizeof(PjDlHoInfo));
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if (ueCb->hoInfo == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+
+   PJ_ALLOC(gCb,ueCb->hoInfo->hoCfmInfo, sizeof(PjDlHoCfmInfo) *  PJ_MAX_DRB_PER_UE );
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if (ueCb->hoInfo->hoCfmInfo == NULLP )
+   {
+      /*ccpu00136858 */      
+      PJ_PST_FREE(gCb->u.dlCb->udxDlSap[0].pst.region,
+                  gCb->u.dlCb->udxDlSap[0].pst.pool, 
+                           ueCb->hoInfo, sizeof(PjDlHoInfo));
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+
+   /* Initialise the reestablishment states for the RBs */
+   rbCbLst      = ueCb->drbCb;
+   for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt ++)
+   {
+      /* Check of rbCb available */
+      if( (pjRbCb = rbCbLst[rbCnt]) == NULLP)
+      {
+         continue;
+      }
+
+      /* Fetch the rbCb and intialise the states */
+      pjRbCb->state  =  PJ_STATE_REEST_HO;
+      
+      if(pjRbCb->mode == PJ_DRB_AM)
+      {
+         pjDlmReEstHoDrbAm(gCb, pjRbCb);
+      }
+
+   }/* for(rbCnt .. */ 
+
+   RETVALUE(ROK);
+} /* pjUtlReEstHO */
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Called after the new security algorithms have been applied
+ *        and header compression/decompression reset. It starts
+ *        reestablishment procedures for downlink DRBs.
+ *
+ * @b Description:
+ *
+ *        This function 
+ *        1. Creates new contexts for Ciphering and Integrity.
+ *        2. Closes the old contexts for Ciphering and Integrity.
+ *        3. Resets the ROHC unit.
+ *
+ *  @param[in] ueCb   UE Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlReEstDl
+(
+PjCb       *gCb,
+PjDlUeCb   *ueCb           /* UE Control Block */ 
+)
+#else
+PUBLIC S16 pjUtlReEstDl(gCb, ueCb)
+PjCb       *gCb;
+PjDlUeCb   *ueCb;           /* UE Control Block */ 
+#endif
+{
+   TRC2(pjUtlReEstDl);
+
+   RLOG2(L_DEBUG, "pjUtlReEstDl(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
+
+
+   /* Send Cfms and update the state  only 
+      when there is some cfgreq cfm is present for other RBs*/
+   if(ueCb->libInfo.state == PJ_STATE_REEST)
+   {
+      pjUtlDlSndReEstCfgCfm(gCb, ueCb);
+   }
+   else if(ueCb->libInfo.state == PJ_STATE_REEST_HO)
+   {
+      pjUtlDlSndSduStaCfm(gCb, ueCb);
+   }
+   ueCb->libInfo.state = PJ_STATE_NORMAL;
+
+   RETVALUE(ROK);
+
+} /* pjUtlReEstDl */
+
+
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function to sent the REESTABLISHMENT COMPPLETE 
+ *        to the RRC.
+ *
+ * @b Description:
+ *
+ *        This function 
+ *        1. Sends a ReEstablishment Confirm for normal reestablishment.
+ *        2. Sends a SDU status confirm for handover reestablishment.
+ *
+ *  @param[in] ueCb   UE Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlDlSndReEstCfgCfm
+(
+PjCb         *gCb,
+PjDlUeCb       *ueCb           /* UE Control Block */ 
+)
+#else
+PUBLIC S16 pjUtlDlSndReEstCfgCfm(ueCb)
+PjCb         *gCb;
+PjDlUeCb       *ueCb;           /* UE Control Block */ 
+#endif
+{
+   U8             rbCnt;
+   PjDlRbCb        *tRbCb;
+   CpjCfgCfmInfo *cfgCfmInfo;
+   U8             txIdx;
+   PjAsyncCfm    *asyncCfm    = NULLP;
+   PjUdxDlSapCb *udxSap;
+   S16          ret = ROK;
+
+   TRC2(pjUtlDlSndReEstCfgCfm);
+
+   RLOG2(L_DEBUG, "pjUtlSndReEstCfgCfm(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
+
+   ueCb->libInfo.state  =  PJ_STATE_NORMAL;
+
+   /* Pick up the confirm info */
+   for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
+   {
+      if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
+         (ueCb->libInfo.asyncCfm[txIdx]->cfmType & PJ_CFG_REEST_ASYNC_CFM))
+      {
+         asyncCfm =  ueCb->libInfo.asyncCfm[txIdx];
+         break;
+      }
+   }
+
+   /* its a reestablishment with only srb1 configured */
+   if(asyncCfm == NULLP)
+   {
+      RETVALUE(ROK);
+   }
+
+   for(rbCnt = 0; rbCnt < PJ_MAX_SRB_PER_UE; rbCnt ++)
+   {
+      if( ((tRbCb = ueCb->srbCb[rbCnt]) == NULLP)    ||
+          (tRbCb->state ==  PJ_STATE_NORMAL))
+      {
+         continue;
+      }
+
+      /* Fetch the rbCb and intialise the states */
+      tRbCb->state  =  PJ_STATE_NORMAL;
+   } 
+   
+   /* Memory leak fix ccpu00135359 */
+   udxSap    = &(gCb->u.dlCb->udxDlSap[0]);
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfgCfmInfo,
+      sizeof (CpjCfgCfmInfo), ret);
+   if(ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   PJ_FILL_REEST_CFG_CFM_INFO(cfgCfmInfo, asyncCfm);
+   PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+   PjDlUdxCfgCfm(&gCb->u.dlCb->udxDlSap[0].pst, 
+                  gCb->u.dlCb->udxDlSap[0].suId, 
+                   (UdxCfgCfmInfo *)cfgCfmInfo);         
+
+   RETVALUE(ROK);
+} /* pjUtlSndReEstCfgCfm */
+
+
+/**
+ *
+ * @brief Handler to store the confirms while we wait for the init
+ *        confirms from the off-board.
+ *       
+ *
+ * @b Description
+ *        This function is invoked during security config request,
+ *        reestablishment request and config request if the libraries
+ *        are off-boarded. This stores the entries in a confirm list
+ *        while waiting for the confirm from the offboard.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+
+#ifdef ANSI
+PUBLIC S16 pjUtlDlSaveCfmInfo
+(
+PjCb        *gCb,
+PjDlUeCb      *ueCb,           /* Pointer to UeCb */ 
+U8          cfmType,         /* Confirm type */
+Bool        startTmr,        /* Start Timer */
+U8          entity,          /* Confirm type */
+PTR         cfmPtr,          /* Pointer to the structure for confirm */
+PTR         cfgPtr           /* Pointer to the structure for request */
+)
+#else
+PUBLIC S16 pjUtlDlSaveCfmInfo(ueCb, cfmType, startTmr, entity, cfmPtr, cfgPtr)
+PjCb        *gCb;
+PjDlUeCb      *ueCb;           /* Pointer to UeCb */ 
+U8          cfmType;         /* Confirm type */
+Bool        startTmr;        /* Start Timer */
+U8          entity;          /* Confirm type */
+PTR         cfmPtr;          /* Pointer to the structure for confirm */
+PTR         cfgPtr;          /* Pointer to the structure for request */
+#endif
+{
+   S16               ret;        /* Return value            */
+   CpjSecCfgCfmInfo  *secCfm;    /* Security confirm        */
+   CpjReEstCfmInfo   *reEstCfm;  /* Reestablishment confirm */
+   CpjCfgCfmInfo     *cfgCfm;    /* Config confirm          */
+   U16               txId;       /* Transaction Id          */
+   PjAsyncCfm        *tAsyncCfm; /* Pointer to the async Cfm*/
+   CpjCfgReqInfo     *cfgReq;    /* Pointer to the config request */
+   U8                cfmIdx;     /* index for loopoing */
+
+
+   TRC3(pjUtlDlSaveCfmInfo) 
+
+   RLOG_ARG4(L_DEBUG,DBG_UEID,ueCb->key.ueId, 
+         "pjUtlSaveCfmInfo cellId(%d),cfmType(%d),startTmr(%d),entity(%d))",
+         ueCb->key.cellId, cfmType, startTmr, entity);
+
+   /* Initialisations */
+   ret      = ROK;
+   secCfm   = NULLP;
+   reEstCfm = NULLP;
+   cfgCfm   = NULLP;
+   cfgReq   = NULLP;
+   txId     = ueCb->libInfo.nxtAvlbTxId;
+
+   if(txId == PJ_MAX_ASYNC_CFM)
+   {
+      /* The entire list is full, have to return negative confirms */
+      RETVALUE(RFAILED);
+   }
+
+   /* is entry already present */
+   if(ueCb->libInfo.asyncCfm[txId] != NULLP)
+   {
+      RETVALUE(RFAILED);
+   }
+
+   /* Allocate the structure */
+   PJ_ALLOC(gCb,ueCb->libInfo.asyncCfm[txId],  sizeof(PjAsyncCfm));
+   if(ueCb->libInfo.asyncCfm[txId]== NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   /* Initialise the structure */
+   tAsyncCfm   =   ueCb->libInfo.asyncCfm[txId];
+   tAsyncCfm->libInitBitMask   =   ueCb->libInfo.tLibInitBitMask;
+   tAsyncCfm->cmpInitBitMask   =   ueCb->libInfo.tCmpInitBitMask;
+   tAsyncCfm->entity           =   entity;
+   tAsyncCfm->startTmr         =   startTmr;
+
+   ueCb->libInfo.tLibInitBitMask =  0; 
+   ueCb->libInfo.tCmpInitBitMask =  0; 
+   
+   /* Assign the values */
+   if(cfmType  ==   PJ_SEC_ASYNC_CFM)
+   {
+      secCfm   =  (CpjSecCfgCfmInfo *)cfmPtr;
+      tAsyncCfm->cfmType =  cfmType;
+      tAsyncCfm->ueId    = secCfm->ueId;
+      tAsyncCfm->cellId  = secCfm->cellId;
+      tAsyncCfm->transId = secCfm->transId;
+   }
+   else if(cfmType  ==   PJ_REEST_ASYNC_CFM)
+   {
+      reEstCfm   =  (CpjReEstCfmInfo *)cfmPtr;
+      tAsyncCfm->cfmType =  cfmType;
+      tAsyncCfm->ueId    = reEstCfm->ueId;
+      tAsyncCfm->cellId  = reEstCfm->cellId;
+      tAsyncCfm->transId = reEstCfm->transId;
+   }
+   else if((cfmType  & PJ_CFG_ASYNC_CFM)  ||
+           (cfmType  & PJ_CFG_REEST_ASYNC_CFM)||
+           (cfmType  & PJ_CFG_UEDEL_ASYNC_CFM))
+   {
+      if(entity   == ENTPJ)
+      {
+         cfgCfm   =  (CpjCfgCfmInfo *)cfmPtr;
+         cfgReq   =  (CpjCfgReqInfo *)cfgPtr;
+
+         tAsyncCfm->cfmType = cfmType;
+         tAsyncCfm->ueId    = cfgCfm->ueId;
+         tAsyncCfm->cellId  = cfgCfm->cellId;
+         tAsyncCfm->transId = cfgCfm->transId;
+         tAsyncCfm->numEnt  = cfgReq->numEnt;
+
+         for ( cfmIdx = 0; cfmIdx < cfgReq->numEnt; cfmIdx++ )
+         {
+            tAsyncCfm->cfmEnt[cfmIdx].status  = cfgCfm->cfmEnt[cfmIdx].status;
+            tAsyncCfm->cfmEnt[cfmIdx].reason  = cfgCfm->cfmEnt[cfmIdx].reason;
+            tAsyncCfm->cfmEnt[cfmIdx].rbId    = cfgCfm->cfmEnt[cfmIdx].rbId;
+            tAsyncCfm->cfmEnt[cfmIdx].rbType  = cfgCfm->cfmEnt[cfmIdx].rbType;
+            tAsyncCfm->cfmEnt[cfmIdx].cfgType = cfgReq->cfgEnt[cfmIdx].cfgType;
+         }
+      }
+      else if(entity == ENTPJ)
+      {
+         CpjCfgCfmInfo  *pjCfgCfm;       /* Configuraiton Confirm */
+
+         pjCfgCfm   =  (CpjCfgCfmInfo *)cfmPtr;
+
+         tAsyncCfm->cfmType = cfmType;
+         tAsyncCfm->transId = pjCfgCfm->transId;
+         tAsyncCfm->ueId    = pjCfgCfm->ueId;
+         tAsyncCfm->cellId  = pjCfgCfm->cellId;
+         tAsyncCfm->numEnt  = pjCfgCfm->numEnt;
+
+         for ( cfmIdx = 0; cfmIdx < pjCfgCfm->numEnt; cfmIdx++ )
+         {
+            tAsyncCfm->cfmEnt[cfmIdx].status  = 
+                                 pjCfgCfm->cfmEnt[cfmIdx].status;
+            tAsyncCfm->cfmEnt[cfmIdx].reason  = 
+                                 pjCfgCfm->cfmEnt[cfmIdx].reason;
+            tAsyncCfm->cfmEnt[cfmIdx].rbId    = 
+                                 pjCfgCfm->cfmEnt[cfmIdx].rbId;
+            tAsyncCfm->cfmEnt[cfmIdx].rbType  = 
+                                 pjCfgCfm->cfmEnt[cfmIdx].rbType;
+         }
+      }
+   }
+
+   /* Start timer */
+   /* Timer should not be started when SEC is SYNC for ReEst Req
+    * and for the subsequent config req for REEST. The config req
+    * after reest req can still start the timer in the case comp being
+    * async and sec being sync if it also adds a RB and a compInit has
+    * to be sent . 
+    * */
+
+   if(tAsyncCfm->startTmr  == TRUE)
+   {
+      if((pjChkTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR)) == FALSE)
+      {
+         pjStartTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR);
+         ueCb->libInfo.crntTmrTxId  =  ueCb->libInfo.nxtAvlbTxId;
+      }
+   }
+
+   /* update nxtAvlbTxId to the next empty slot */
+   for(cfmIdx = 0; cfmIdx < PJ_MAX_ASYNC_CFM; cfmIdx++)
+   {
+      ueCb->libInfo.nxtAvlbTxId = 
+        (U16)((ueCb->libInfo.nxtAvlbTxId + 1) % PJ_MAX_ASYNC_CFM);  /*KW_FIX*/
+
+      if(ueCb->libInfo.asyncCfm[ueCb->libInfo.nxtAvlbTxId] == NULLP)
+      {
+         break;
+      }
+   }
+
+   /* Cant find an empty slot ? */
+   if(cfmIdx == PJ_MAX_ASYNC_CFM)
+   {
+      ueCb->libInfo.nxtAvlbTxId = PJ_MAX_ASYNC_CFM;
+   }
+
+   RETVALUE(ret);
+}/* pjUtlSaveCfmInfo */
+\f
+/**
+ *
+ * @brief Handler to store update the bitmaks and send confirms if necessary.
+ *       
+ *
+ * @b Description
+ *        This function is invoked when receiving a InitCfm from Offboard.
+ *        It updates the bit masks and checks if it is necesary to send a 
+ *        confirm.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+
+#ifdef ANSI
+PUBLIC S16 pjUtlDlHdlObdInitCfm
+(
+PjCb        *gCb,
+PjDlUeCb      *ueCb,           /* Pointer to UeCb */ 
+U16         txIdx,           /* Transaction Index for UeCb */
+U8          cfmType,         /* Confirm type */
+U8          maskVal          /* mask value */
+)
+#else
+PUBLIC S16 pjUtlDlHdlObdInitCfm(ueCb, txIdx, cfmType, maskVal)
+PjCb        *gCb;
+PjDlUeCb      *ueCb;           /* Pointer to UeCb */ 
+U16         txIdx;           /* Transaction Index for UeCb */
+U8          cfmType;         /* Confirm type */
+U8          maskVal;         /* mask value */
+#endif
+{
+   UdxSecCfgCfmInfo *secCfgCfm;   /* Security config confirm */
+   UdxReEstCfmInfo  *reEstCfm;    /* Reest config confirm */
+   PjAsyncCfm       *asyncCfm;
+   UdxCfgCfmInfo    *cfgCfm;
+   U8               idx;
+   S16              ret;
+
+   TRC3(pjUtlDlHdlObdInitCfm)
+
+   RLOG_ARG4(L_DEBUG,DBG_UEID,ueCb->key.ueId, 
+         "pjUtlHdlDlObdInitCfm cellId(%d), txIdx(%d), cfmType(%d), maskVal(%d))",
+          ueCb->key.cellId, txIdx, cfmType, maskVal);
+
+   /* Initialisations */
+   secCfgCfm   =  NULLP;
+   reEstCfm    =  NULLP;
+   cfgCfm      =  NULLP;
+   asyncCfm    =  NULLP;
+   ret         =  ROK;
+
+   if((txIdx  == PJ_MAX_ASYNC_CFM) ||
+      (ueCb->libInfo.asyncCfm[txIdx] == NULLP))
+   {
+      RETVALUE(RFAILED);
+   }
+
+   asyncCfm =  ueCb->libInfo.asyncCfm[txIdx];
+
+   if(cfmType & PJ_SEC_INIT_CFM)
+   {
+      /* Update bit mask and check if all confirms have been received */
+      asyncCfm->libInitBitMask ^= (maskVal);
+      ret = pjUtlDlHdlSecInitCfm(gCb,ueCb,txIdx,asyncCfm,secCfgCfm,reEstCfm);
+   }
+   else if(cfmType  & PJ_CMP_INIT_CFM)
+   {
+      /* Check if all confirms have been received */
+      asyncCfm->cmpInitBitMask &= ~(1 << (maskVal - 1));
+
+      /* Update the status and reason for the received CmpInitCfm */
+      for ( idx = 0; idx < asyncCfm->numEnt; idx++ )
+      {
+         if ( asyncCfm->cfmEnt[idx].rbId == maskVal)
+         {
+            asyncCfm->cfmEnt[idx].status = CPJ_CFG_CFM_OK;
+            asyncCfm->cfmEnt[idx].reason = CPJ_CFG_REAS_NONE;
+            break;
+         }
+      }
+
+      /* Check if we can send confirm */
+      if(asyncCfm->cmpInitBitMask == 0)
+      {
+         ret = pjUtlDlHdlCmpInitCfm(gCb,ueCb,txIdx,asyncCfm,cfgCfm);
+      }
+   }
+   RETVALUE(ret);
+}/* pjUtlHdlDlObdInitCfm */
+\f
+/**
+ *
+ * @brief Handler for init off-board timer expiry.
+ *
+ *
+ * @b Description
+ *        This function is called when the off-board timer expires for
+ *        a Init Req of a channel (either for ciphering/integrity/compression).
+ *        This function sends a confirm with failure for SecCfgReq if the
+ *        state of the RB is normal. It sends a confirm with failure
+ *        for config request(only for RBs with Re-establishment Req, a failure 
+ *        is stored in the confirm) if the state of the RB is re-establishment.
+ *
+ *  @param[in] ueCb    UE control block.
+ *
+ *
+ *  @return  S16
+ *      -# ROK
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUtlDlHdlInitObdTmrExp
+(
+PjCb     *gCb,
+PjDlUeCb *ueCb
+)
+#else
+PUBLIC S16 pjUtlDlHdlInitObdTmrExp(ueCb)
+PjCb     *gCb;
+PjDlUeCb *ueCb;
+#endif
+{
+   S16               ret;           /* Return Value */
+   UdxSecCfgCfmInfo  *secCfgCfm;    /* Security Cfg Confirm Info */
+   UdxCfgCfmInfo     *cfgCfm;       /* Config Confirm Info */
+   UdxReEstCfmInfo   *reEstCfm;     /* Reest config confirm */
+   UdxCfgCfmInfo     *pjCfgCfm;
+   PjLibInfo         *libInfo;      /* Off-board Info */
+   PjAsyncCfm        *asyncCfm;     /* Async Cfm Info */
+   PjUdxDlSapCb      *udxSap;
+   U16               txIdx;         /* Tx Idx */
+   U16               idx;           /* Index for looping */
+   U16               cfgIdx;
+
+   TRC3(pjUtlDlHdlInitObdTmrExp)
+
+   RLOG2(L_DEBUG, "pjUtlDlHdlInitObdTmrExp(ueCb(%d,%d))",
+         ueCb->key.ueId, ueCb->key.cellId);
+
+   ret       = ROK;
+   udxSap    = &(gCb->u.dlCb->udxDlSap[0]);
+   secCfgCfm = NULLP;
+   libInfo   = &ueCb->libInfo;
+   txIdx     = libInfo->crntTmrTxId;
+
+   /* Restart the timer */
+   PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx);
+
+   /* Shouldnt happen, nevertheless, check */
+   if( txIdx >= PJ_MAX_ASYNC_CFM || libInfo->asyncCfm[txIdx] == NULLP)
+   {
+      RETVALUE(ROK);
+   }
+
+   asyncCfm =  libInfo->asyncCfm[txIdx];
+
+   /* Security confirm */
+   if(asyncCfm->cfmType & PJ_SEC_ASYNC_CFM)
+   {
+      PJ_ALLOC_BUF_SHRABL(udxSap->pst,secCfgCfm,
+          sizeof (UdxSecCfgCfmInfo), ret);
+      if(ret != ROK)
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         RETVALUE(RFAILED);
+      }
+      PJ_FILL_SEC_CFM_INFO(secCfgCfm, asyncCfm);
+      secCfgCfm->status = CPJ_CFG_CFM_NOK;
+      secCfgCfm->reason = CPJ_CFG_REAS_OBD_TIMEOUT;
+
+      PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+      PjDlUdxSecCfgCfm((&udxSap->pst), udxSap->suId, secCfgCfm);
+   }
+
+   /* Configuration confirms */
+   else if ((asyncCfm->cfmType & PJ_CFG_ASYNC_CFM) ||
+            (asyncCfm->cfmType & PJ_CFG_REEST_ASYNC_CFM))
+   {
+      PJ_FILL_TIMEOUT_CFG_CFM_INFO(gCb,cfgCfm, asyncCfm);
+
+      PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+      PjDlUdxCfgCfm(&(gCb->u.dlCb->udxDlSap[0].pst), 
+                         gCb->u.dlCb->udxDlSap[0].suId, 
+                        cfgCfm);
+   }
+   else if (asyncCfm->cfmType & PJ_REEST_ASYNC_CFM)
+   {
+      /* Send ReEstCfm */
+      /* Memory leak fix ccpu00135359 */
+      PJ_ALLOC_BUF_SHRABL(udxSap->pst,reEstCfm,
+          sizeof (UdxReEstCfmInfo), ret);
+      if(ret != ROK)
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         RETVALUE(RFAILED);
+      }
+      PJ_FILL_REEST_CFM_INFO(reEstCfm, asyncCfm, LCM_PRIM_NOK);
+
+      PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+      PjDlUdxReEstCfm(&udxSap->pst, 
+                       udxSap->suId, reEstCfm);
+
+      /* Send the config confirm also if any exists */
+      cfgIdx   = (U16)( txIdx + 1); /*KW_FIX*/
+
+      for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++, cfgIdx++)
+      {
+         cfgIdx %=   PJ_MAX_ASYNC_CFM;
+         if((libInfo->asyncCfm[cfgIdx] != NULLP) &&
+            (libInfo->asyncCfm[cfgIdx]->cfmType & PJ_CFG_REEST_ASYNC_CFM))
+         {
+            break;
+         }
+      }
+
+      /* This scenario occurs when only SRB1 is configured */
+      if(idx == PJ_MAX_ASYNC_CFM)
+      {
+         RETVALUE(ROK);
+      }
+
+      PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, cfgIdx);
+      asyncCfm =  libInfo->asyncCfm[cfgIdx];
+
+      PJ_FILL_TIMEOUT_CFG_CFM_INFO(gCb,cfgCfm, asyncCfm);
+
+      PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+      PjDlUdxCfgCfm(&gCb->u.dlCb->udxDlSap[0].pst, 
+                  gCb->u.dlCb->udxDlSap[0].suId, cfgCfm);         
+   }
+   else if(asyncCfm->cfmType & PJ_CFG_UEDEL_ASYNC_CFM)
+   {
+      /* Delete ueCb entry from ueLstCp */
+      pjStopTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR);
+      ret = cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb);
+      if (ret != ROK)
+      {
+
+#ifdef DEBUGP
+         RLOG_ARG0(L_ERROR, DBG_UEID,ueCb->key.ueId, 
+               "Hash List Delete Failed for DL ueCb");
+#endif
+      }
+
+      if ( asyncCfm->entity == ENTPJ )
+      {
+         PJ_ALLOC_BUF_SHRABL(udxSap->pst,cfgCfm,
+             sizeof (UdxCfgCfmInfo), ret);
+         if(ret != ROK)
+         {
+            RLOG0(L_FATAL, "Memory Allocation failed.");
+            RETVALUE(RFAILED);
+         }
+
+         for ( idx = 0; idx < asyncCfm->numEnt; idx++)
+         {
+            cfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status;
+            cfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason;
+            cfgCfm->cfmEnt[idx].rbId   = asyncCfm->cfmEnt[idx].rbId;
+            cfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType;
+         }
+         cfgCfm->ueId    = asyncCfm->ueId;
+         cfgCfm->cellId  = asyncCfm->cellId;
+         cfgCfm->transId = asyncCfm->transId;
+         cfgCfm->numEnt  = asyncCfm->numEnt;
+
+         /* delete all confirms present there */
+         for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++)
+         {
+            if(libInfo->asyncCfm[idx] != NULLP)
+            {
+               PJ_FREE(gCb,ueCb->libInfo.asyncCfm[idx], sizeof(PjAsyncCfm)); 
+               ueCb->libInfo.asyncCfm[idx] = NULLP; 
+            }
+         }
+
+         PJ_FREE(gCb,ueCb, sizeof(PjDlUeCb));
+         PjDlUdxCfgCfm(&(udxSap->pst), udxSap->suId, cfgCfm);
+      }
+      else if ( asyncCfm->entity == ENTPJ )
+      {
+         /* Memory leak fix ccpu00135359 */
+         PJ_ALLOC_BUF_SHRABL(udxSap->pst,pjCfgCfm,
+             sizeof (UdxCfgCfmInfo), ret);
+         if(ret != ROK)
+         {
+            RLOG0(L_FATAL, "Memory Allocation failed.");
+            RETVALUE(RFAILED);
+         }
+         for ( idx = 0; idx < asyncCfm->numEnt; idx++)
+         {
+            pjCfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status;
+            pjCfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason;
+            pjCfgCfm->cfmEnt[idx].rbId          = asyncCfm->cfmEnt[idx].rbId;
+            pjCfgCfm->cfmEnt[idx].rbType        = asyncCfm->cfmEnt[idx].rbType;
+         }
+         pjCfgCfm->ueId    = asyncCfm->ueId;
+         pjCfgCfm->cellId  = asyncCfm->cellId;
+         pjCfgCfm->transId = asyncCfm->transId;
+         pjCfgCfm->numEnt  = asyncCfm->numEnt;
+
+         /* delete all confirms present there */
+         for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++)
+         {
+            if(libInfo->asyncCfm[idx] != NULLP)
+            {
+               PJ_FREE(gCb,ueCb->libInfo.asyncCfm[idx], sizeof(PjAsyncCfm)); 
+               ueCb->libInfo.asyncCfm[idx] = NULLP; 
+            }
+         }
+
+         PJ_FREE(gCb,ueCb, sizeof(PjDlUeCb));
+         PjDlUdxCfgCfm(&(udxSap->pst), udxSap->suId, pjCfgCfm);
+      }
+   }
+
+   RETVALUE(ret);
+} /* pjHdlUeDelWaitTmrExp */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function to sent the REESTABLISHMENT COMPPLETE 
+ *        to the RRC.
+ *
+ * @b Description:
+ *
+ *        This function 
+ *        1. Sends a ReEstablishment Confirm for normal reestablishment.
+ *        2. Sends a SDU status confirm for handover reestablishment.
+ *
+ *  @param[in] ueCb   UE Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlDlSndSduStaCfm
+(
+PjCb         *gCb,
+PjDlUeCb       *ueCb           /* UE Control Block */ 
+)
+#else
+PUBLIC S16 pjUtlDlSndSduStaCfm(gCb, ueCb) 
+PjCb         *gCb;
+PjDlUeCb       *ueCb;           /* UE Control Block */ 
+#endif
+{
+   UdxSduStaCfmInfo  *cfmInfo; 
+   PjUdxDlSapCb     *udxSap;
+   S16              ret = ROK;
+
+   TRC2(pjUtlDlSndSduStaCfm); 
+
+   RLOG2(L_DEBUG, "pjUtlSndSduStaCfm(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
+
+   /* Perform processing for filling up cfm structures */
+   /* Memory leak fix ccpu00135359 */
+   udxSap    = &(gCb->u.dlCb->udxDlSap[0]);
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfmInfo,
+      sizeof (UdxSduStaCfmInfo), ret);
+   if( ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+   PJ_FILL_DL_SDU_CFM_INFO(gCb,cfmInfo, ueCb);
+
+   PjDlUdxSduStaCfm(&gCb->u.dlCb->udxDlSap[0].pst, 
+                     gCb->u.dlCb->udxDlSap[0].suId, 
+                     cfmInfo); 
+
+   RETVALUE(ROK);
+
+} /* pjUtlSndSduStaCfm */
+
+/**
+ *
+ * @brief Handler to clean up all the PDCP Control Blocks.
+ *       
+ *
+ * @b Description
+ *        This function is invoked by LMM to shutdown the
+ *        layer. This cleans up recBuf and txBuf of all the
+ *        PDCP RBs in all the UEs.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+
+#ifdef ANSI
+PUBLIC S16 pjUtlDlShutdown
+(
+PjCb  *gCb
+)
+#else
+PUBLIC S16 pjUtlDlShutdown()
+PjCb   *gCb;
+#endif
+{
+   S16         ret;              /* Return Value */
+   PjDlUeCb      *ueCb;            /* UE Control Block */
+   PjDlUeCb      *prevUeCb;        /* Previos UE Control Block */
+   PjDlRbCb        *rbCb;            /* RB Control Block */
+   PjDlRbCb        **rbCbLst;        /* RB Control Block List */
+   PjSec       secInfo;          /* Security info of UE */
+   U8          idx;              /* Index for RBs */
+#ifdef LTE_L2_MEAS_COMMENT
+   PjL2MeasEvtCb  *measEvtCb = NULLP;
+#endif
+   TRC3(pjUtlDlShutdown) 
+
+   RLOG0(L_DEBUG, "pjUtlShutdown()");
+
+   ret      = ROK;
+   ueCb     = NULLP;
+   prevUeCb = NULLP;
+   rbCb     = NULLP;
+   rbCbLst  = NULLP;
+   idx      = 0;
+
+   /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
+   while (cmHashListGetNext(&(gCb->u.dlCb->ueLstCp), (PTR) prevUeCb, (PTR *)&ueCb) == ROK)
+   {
+      if ( ueCb != NULLP )
+      {
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+         if (ueCb->libInfo.obdTmr.tmrEvnt == PJ_EVT_OBD_TMR)
+         {
+            pjStopTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_TMR);
+         }
+#endif
+         rbCbLst = ueCb->srbCb;
+         for (idx = 0; idx < PJ_MAX_SRB_PER_UE; idx++)
+         {
+             rbCb = rbCbLst[idx];
+             if (rbCb != NULLP)
+             {
+               /* Free the Buffers of RbCb */
+               pjUtlDlFreeRb(gCb,rbCb);
+             }
+         }
+         rbCbLst = ueCb->drbCb;
+         for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++)
+         {
+             rbCb = rbCbLst[idx];
+             if (rbCb != NULLP)
+             {
+                pjUtlDlFreeRb(gCb,rbCb);
+             }
+         }
+         /* Close all the context info for offboarding */
+         secInfo = ueCb->secInfo;
+#ifdef INTEL_QAT_DP
+         pjUtlDlIntClose(gCb,ueCb->secInfo.cpIntSessCxtId);
+         pjUtlDlCipherClose(gCb,ueCb->secInfo.cpCiphSessCxtId);
+         pjUtlDlCipherClose(gCb,ueCb->secInfo.upCiphSessCxtId);
+#else   
+         pjUtlDlCipherClose(gCb,secInfo.cpCxtId);
+         pjUtlDlCipherClose(gCb,secInfo.upCxtId);
+         pjUtlDlIntClose(gCb,secInfo.intCxtId);
+#endif
+
+         /* Delete hoInfo if present */
+         if (ueCb->hoInfo != NULLP)
+         {
+            PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo,
+                           (PJ_MAX_DRB_PER_UE * sizeof(PjDlHoCfmInfo)));
+            PJ_FREE(gCb,ueCb->hoInfo, sizeof(PjDlHoInfo));                 
+         }
+      }
+      prevUeCb = ueCb;
+   }
+#ifdef LTE_L2_MEAS_COMMENT
+   for(idx = 0; idx < PJ_MAX_L2MEAS_EVT; idx++)
+   {
+      if(gCb->u.dlCb->pjL2Cb.pjMeasEvtCb[idx] != NULLP)
+      {
+         measEvtCb = gCb->u.dlCb->pjL2Cb.pjMeasEvtCb[idx];
+         pjStopTmr((PTR)measEvtCb, PJ_EVT_L2_TMR);
+         gCb->u.dlCb->pjL2Cb.pjNumMeas--;
+         PJ_FREE(gCb,measEvtCb, sizeof(PjL2MeasEvtCb));
+         gCb->u.dlCb->pjL2Cb.pjMeasEvtCb[idx] = NULLP;
+      }
+   }
+#endif
+   ret = pjDbmDlDeInit(gCb);
+#if (ERRCLASS & ERRCLS_DEBUG)
+   if (ret != ROK)
+   {
+      RLOG0(L_FATAL, "PDCP DL DeInitialization Failed.");
+   }
+#endif /* ERRCLASS & ERRCLS_DEBUG */
+
+
+   /* commented this to use in deregister timer and kwusap */
+   /* gCb->init.cfgDone &= ~PJ_LMM_GENCFG_DONE; */
+   RETVALUE(ret);
+}
+
+/**
+ * 
+ * @brief 
+ *
+ *        Handler to free a PDCP Control Block.
+ *
+ * @b Description:
+ * 
+ *        This function frees the txBuf and rxBuf in a PDCP control block.
+ *        and closes the compression channel opened. It stops the timers 
+ *        of this control block if they are running.
+ *
+ *  @param[in]  pst        Post structure 
+ *  @param[in]  secCxt     Context for Integrity protection/verification 
+ *  @param[in]  ctxId      Integrity Context Id
+ *
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+
+#ifdef ANSI
+PUBLIC Void pjUtlDlFreeRb
+(
+PjCb     *gCb,
+PjDlRbCb *pjRbCb
+)
+#else
+PUBLIC Void pjUtlDlFreeRb(pjRbCb)
+PjCb     *gCb;
+PjDlRbCb *pjRbCb;
+#endif
+{
+   TRC3(pjUtlDlFreeRb)
+   RLOG0(L_DEBUG, "pjUtlFreeRb()");
+
+
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+   if (pjRbCb->dlCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR)
+   {
+       pjStopTmr(gCb,(PTR)pjRbCb, PJ_EVT_DL_OBD_TMR);
+   }
+#endif
+   
+   pjUtlCmpClose(gCb,pjRbCb->cmpCxtId);
+   /*pj004.201 Adding of Missing Trace in LTE RLC PDCP*/
+   RETVOID;
+}
+
+/* pj005.201 added function to send data forward indication message */
+/**
+ * 
+ * @brief 
+ *
+ *        Handler to send Data Fwd Indication
+ *
+ * @b Description:
+ *      This function sends Data Fwd Indication message to PDCP user 
+ *
+ *  @param[in]  pjRbCb     PDCP RbCb
+ *  @param[in]  datFwdInd  Data forward indication
+ *
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUtlDlSndDatFwdInd
+(
+PjCb             *gCb,
+PjDlRbCb           *pjRbCb,
+PjuDatFwdIndInfo *datFwdInd
+)
+#else
+PUBLIC S16 pjUtlDlSndDatFwdInd(pjRbCb, datFwdInd) 
+PjCb             *gCb;
+PjDlRbCb           *pjRbCb;
+PjuDatFwdIndInfo *datFwdInd;
+#endif
+{
+   CmLtePdcpId  *pdcpId;
+   PjPjuSapCb   *pjuSap;
+
+   TRC3(pjUtlDlSndDatFwdInd) 
+   
+   RLOG0(L_DEBUG, "pjUtlSndDatFwdInd()");
+
+   pjuSap   = &(gCb->u.dlCb->pjuSap[PJ_DRB_SAP]);
+   CmLtePdcpId pdcpIdTmp;
+   pdcpId = &pdcpIdTmp;
+
+   if(pdcpId != NULLP)
+   {
+      pdcpId->ueId   =  pjRbCb->ueCb->key.ueId;
+      pdcpId->cellId =  pjRbCb->ueCb->key.cellId;
+      pdcpId->rbId   =  pjRbCb->rbId;
+      pdcpId->rbType =  pjRbCb->rbType;
+      
+      gCb->pjGenSts.numPktsFrwd += datFwdInd->numSdus;
+      /* If trace flag is enabled send the trace indication */
+      if(gCb->init.trc == TRUE)
+      {                       
+         /* Populate the trace params */
+         pjLmmSendTrc(gCb,EVTPJUDATFWDIND, NULLP);
+      }
+      PjUiPjuDatFwdInd(&(pjuSap->pst), pjuSap->suId, pdcpId, datFwdInd);
+   }
+
+  RETVALUE(ROK);
+
+}/* end of pjUtlSndDatFwdInd */
+
+/* pj005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+/**
+ *
+ * @brief Function to initialise measurement
+ *
+ * @b Description
+ *
+ * @param[in]  gCb     PDCP Instance Control Block
+ *
+ *  @return  Void
+ *
+ */
+S16 pjUtlL2MeasDlInit(PjCb *gCb)
+{
+   U16   cntr;
+
+   gCb->u.dlCb->pjL2Cb.pjNumMeas=0;
+   for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++)
+   {
+      cmMemset((U8 *)&(gCb->u.dlCb->pjL2Cb.pjL2EvtCb[cntr]), 0, sizeof(PjL2MeasEvtCb));
+   }
+   gCb->u.dlCb->pjL2Cb.pjL2EvtCb[0].measCb.measType = LPJ_L2MEAS_DL_DISC;
+
+   RETVALUE(ROK);
+}
+\f
+/**
+ *
+ * @brief Handler for sending L2 Measurement report 
+ *
+ * @b Description
+ *
+ *  @param[in] gCb          PDCP Instance Control Block. 
+ *  @param[in] measEvtCb    Measurement Event Control Block.
+ *
+ *
+ *  @return  S16
+ *      -# ROK
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUtlSndDlL2MeasCfm
+(
+PjCb            *gCb,
+PjL2MeasEvtCb   *measEvtCb
+)
+#else
+PUBLIC S16 pjUtlSndDlL2MeasCfm(measEvtCb)
+PjCb            *gCb;
+PjL2MeasEvtCb   *measEvtCb;
+#endif
+{
+   PjL2MeasCb     *measCb;
+   PjL2MeasCfmEvt measCfmEvt;
+   U8             qciIdx;
+
+   TRC3(pjUtlSndDlL2MeasCfm)
+
+   measCb = &measEvtCb->measCb;
+   cmMemset((U8*)&measCfmEvt, 0, sizeof(PjL2MeasCfmEvt));
+   
+   measCfmEvt.measType = measCb->measType;
+   measCfmEvt.status.status = LCM_PRIM_OK;
+   measCfmEvt.status.reason = LCM_REASON_NOT_APPL;
+   for(qciIdx = 0; qciIdx < (LPJ_MAX_QCI-1); qciIdx++)
+   {
+      measCfmEvt.measCfm[measCfmEvt.numQciCfm].qci = measCb->qci[qciIdx];
+      if(measCfmEvt.measCfm[measCfmEvt.numQciCfm].qci > 0)
+      {
+         if((measCb->measType & LPJ_L2MEAS_DL_DISC) &&
+               (measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts > 0))
+         {
+            /* dlDisc = num of Pkts Discarded * 10^6 / total no of pkts. */
+            measCfmEvt.measCfm[measCfmEvt.numQciCfm].dlDisc = 
+               measCb->measData[measCb->qci[qciIdx]].dlDisc.val  * (1000000) /
+               measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts;
+            /* Reset the counters */
+            measCb->measData[measCb->qci[qciIdx]].dlDisc.val = 0; 
+            measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts =0;
+         }
+         measCfmEvt.numQciCfm++;
+      }
+   }
+
+   /* Send Measurement confirmation to layer manager */
+   PjMiLpjL2MeasCfm(&gCb->pjGenCfg.lmPst,&measCfmEvt);
+
+   RETVALUE(ROK);
+}
+\f
+
+/**
+ * @brief  Validates the measurement request parameters. 
+ *
+ * @details
+ *
+ *     Function :pjUtlValidateL2Meas 
+ *
+ *  @param[in]  PjL2MeasReqEvt measReqEvt
+ *  @param[out] PjL2MeasCfmEvt measCfmEvt
+ **/
+/**
+ *
+ * @brief Handler for resetting the DL measurement counters 
+ *
+ *     Function :pjUtlResetDlL2MeasCntr 
+ *
+ * @b Description
+ *
+ * @param[in] measCb    Measurement Control Block.
+ *
+ *
+ * @return  Void
+ */
+#ifdef ANSI
+
+PUBLIC Void pjUtlResetDlL2MeasCntr
+(
+PjCb         *gCb,
+PjL2MeasCb   *measCb,
+U8           measType
+)
+#else
+PUBLIC Void pjUtlResetDlL2MeasCntr(gCb, measCb, measType)
+PjCb         *gCb;
+PjL2MeasCb   *measCb;
+U8           measType;
+#endif
+{
+   /* for now the only meas should be DL discard in this case */
+   if (measCb->measType & LPJ_L2MEAS_DL_DISC)
+   {
+      U32 i;
+      for(i = 0; i < (LPJ_MAX_QCI - 1); i++)
+      {
+         U8 qciVal = measCb->qci[i];
+
+         measCb->measData[qciVal].dlDisc.val = 0;
+         measCb->measData[qciVal].dlDisc.numPkts  = 0;
+         gCb->u.dlCb->pjL2Cb.measOn[qciVal] &= ~LPJ_L2MEAS_DL_DISC;
+      }
+
+      measCb->numQci = 0;
+   }
+}
+
+/**
+ *
+ * @brief Handler for storing address of MeasData in rbCb at right index
+ *
+ *
+ * @b Description
+ *        This function is called when LM sends measReq message to RLC.
+ *
+ *  @param[in] 
+ *  @param[out] 
+ *  @param[in] 
+ *
+ *
+ *  @return  S16
+ *      -# ROK
+ */
+#ifdef ANSI
+PUBLIC Void pjUtlPlcMeasDatInDlL2Sts
+(
+PjL2Cntr       *measData, 
+PjL2MeasRbCb   *rbL2Cb,
+U8             measType
+)
+#else
+PUBLIC Void pjUtlPlcMeasDatInDlL2Sts(measData, rbL2Cb, measType)
+PjL2Cntr       *measData; 
+PjL2MeasRbCb   *rbL2Cb;
+U8             measType;
+#endif
+{
+   TRC3(pjUtlPlcMeasDatInDlL2Sts)
+   
+   /* We should check the number of measType in the request. This can be done 
+    * by looking at each bit in the measType. Also store the measData in the 
+    * correct index of l2Sts in RbCb.
+    * */
+
+    if(measType & LPJ_L2MEAS_DL_DISC)
+    {
+         rbL2Cb->l2Sts[PJ_L2MEAS_DL_DISC] = measData;
+    }
+
+}/* End of pjUtlPlcMeasDatInDlL2Sts */
+#endif /* LTE_L2_MEAS */
+
+void dumpPDCPDlRbInformation(PjDlRbCb* dlRbCb, U16 ueId)
+{
+   PjDlCb* dlCb = &dlRbCb->dlCb;
+   RLOG_ARG1(L_INFO,DBG_UEID,ueId, "PDCP DL RB numEntries = %lu",
+                    dlCb->txBuf.numEntries);
+#ifndef ALIGN_64BIT
+   RTLIN_DUMP_DEBUG("UE [%u] PDCP DL RB numEntries = %lu",
+                  ueId, dlCb->txBuf.numEntries);
+#else
+   RTLIN_DUMP_DEBUG("UE [%u] PDCP DL RB numEntries = %u",
+                  ueId, dlCb->txBuf.numEntries);
+#endif
+}
+
+void DumpPDCPDlDebugInformation(void)
+{
+#ifndef RGL_SPECIFIC_CHANGES
+#ifdef TENB_T2K3K_SPECIFIC_CHANGES
+   void *iccHdl = NULLP;
+   U32 poolZeroFreeCnt;
+   U32 poolOneFreeCnt;
+   U32 poolTwoFreeCnt;
+   U32 poolThreeFreeCnt;
+#endif   
+
+   PjCb* dlInst = pjCb[1]; /* TODO: check whether DL is 0 or 1 */
+   PjDlgCb* dlgCb = dlInst->u.dlCb;
+
+   PjDlUeCb *ueCb = NULLP; 
+   RLOG0(L_INFO,"PDCP DL Information");
+   RLOG0(L_INFO,"===================");
+   RTLIN_DUMP_DEBUG("PDCP DL Information\n");
+   RTLIN_DUMP_DEBUG("===================\n");
+   /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
+   while (ROK == cmHashListGetNext(&dlgCb->ueLstCp, 
+                                   (PTR) ueCb, 
+                                   (PTR *)&ueCb))
+   {
+      U32 i;
+      for(i = 0; i < PJ_MAX_SRB_PER_UE; i++)
+      {
+         PjDlRbCb* rbCb = ueCb->srbCb[i];
+         if(rbCb != NULLP)
+         {
+            dumpPDCPDlRbInformation(rbCb, ueCb->key.ueId);
+         }
+      }
+      for(i = 0; i < PJ_MAX_DRB_PER_UE; i++)
+      {
+         PjDlRbCb* rbCb = ueCb->drbCb[i];
+         if(rbCb != NULLP)
+         {
+            dumpPDCPDlRbInformation(rbCb, ueCb->key.ueId);
+         }
+      }
+   }/* end while */
+   /*printing ICC memory statistics*/
+#ifdef TENB_T2K3K_SPECIFIC_CHANGES
+   iccHdl = ssGetIccHdl(dlInst->init.region);
+   if(NULLP != iccHdl)
+   {
+      poolZeroFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_ZERO_SIZE);
+      poolOneFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_ONE_SIZE);
+      poolTwoFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_TWO_SIZE);
+      poolThreeFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_THREE_SIZE);
+      RLOG1(L_ALWAYS,"ICC pool zero free count = %lu", poolZeroFreeCnt);
+      RLOG1(L_ALWAYS,"ICC pool one free count = %lu", poolOneFreeCnt);
+      RLOG1(L_ALWAYS,"ICC pool two free count = %lu", poolTwoFreeCnt);
+      RLOG1(L_ALWAYS,"ICC pool three free count = %lu", poolThreeFreeCnt);
+      RTLIN_DUMP_DEBUG("ICC pool zero free count = %lu\n", poolZeroFreeCnt);
+      RTLIN_DUMP_DEBUG("ICC pool one free count = %lu\n", poolOneFreeCnt);
+      RTLIN_DUMP_DEBUG("ICC pool two free count = %lu\n", poolTwoFreeCnt);
+      RTLIN_DUMP_DEBUG("ICC pool three free count = %lu\n", poolThreeFreeCnt);
+   }
+      /*ccpu00136858 */      
+   RLOG1(L_ALWAYS,"SPACC cipher Q num of entry = %lu ", pjMsCiphQ.count);
+   RLOG1(L_ALWAYS,"SPACC decipher Q num of entry = %lu ", pjMsDeCiphQ.count);
+   RTLIN_DUMP_DEBUG("SPACC cipher Q num of entry = %lu \n", pjMsCiphQ.count);
+   RTLIN_DUMP_DEBUG("SPACC decipher Q num of entry = %lu \n", pjMsDeCiphQ.count);
+#endif
+#endif
+}
+
+PUBLIC Void pjUtlEmptyDlPktList(PjCb *gCb, PjDlRbCb *pjRbCb)
+{
+   PjDlPkt *ulPkt;
+   CmLListCp *ulPktLst = &pjRbCb->dlCb.dlPktQ;
+   while(ulPktLst->first)
+   {
+      ulPkt = (PjDlPkt *)(ulPktLst->first->node);
+      cmLListDelFrm(ulPktLst, ulPktLst->first);
+      PJ_FREE_BUF(ulPkt->pdu);
+#ifdef FLAT_BUFFER_OPT
+      PJ_FREE_FLAT_BUF(gCb, &(ulPkt->fb))
+#endif
+      PJ_FREE(gCb, ulPkt, sizeof(PjDlPkt));
+   }
+   RETVOID;
+}
+
+void ResetPDCPStats(void)
+{
+   cmMemset((U8*)&gPdcpStats, 0, sizeof(PDCPStats));
+}
+
+#ifndef ALIGN_64BIT
+void PrintPDCPStats(void)
+{
+#ifdef TENB_T2K3K_SPECIFIC_CHANGES
+   /* UDAY */
+#ifdef XEON_SPECIFIC_CHANGES
+   RLOG3(L_INFO,"PDCP Stats: SDUs Dropped = (%ld),SDUs Queued for SPAcc Cipher = (%ld),"
+            "Decipher = (%ld)",
+           gPdcpStats.numPdcpSdusDiscarded, pjMsCiphQ.count, pjMsDeCiphQ.count);
+#else
+   RLOG3(L_INFO,"PDCP Stats: SDUs Dropped = (%ld),SDUs Queued for SPAcc Cipher = (%ld),"
+            "Decipher = (%ld)",
+           gPdcpStats.numPdcpSdusDiscarded, pjMsDlSpaccQCnt, pjMsUlSpaccQCnt);
+#endif
+#ifdef XEON_SPECIFIC_CHANGES
+   if((gPdcpStats.numPdcpSdusDiscarded > 0) || (pjMsCiphQ.count > 0) || (pjMsDeCiphQ.count > 0) )
+   {   
+      RTLIN_DUMP_DEBUG("PDCP Stats: SDUs Dropped = (%d),"
+            "SDUs Queued for SPAcc Cipher = (%d), Decipher = (%d)  \n",
+             gPdcpStats.numPdcpSdusDiscarded, pjMsCiphQ.count, pjMsDeCiphQ.count); /* UDAY */
+   }    
+#else
+   RTLIN_DUMP_DEBUG("PDCP Stats: SDUs Dropped = (%ld),"
+         "SDUs Queued for SPAcc Cipher = (%ld), Decipher = (%ld) Rb Overload DROP = (%ld) dbgPdcpQSizeThreshHoldDropCnt is (%ld) MmThredHldDrp (%ld) spaccQDropCnt (%ld) dlSpaccPktDrop %ld\n",
+           gPdcpStats.numPdcpSdusDiscarded, pjMsDlSpaccQCnt, pjMsUlSpaccQCnt,dbgPdcpMemCount,dbgPdcpQSizeThreshHoldDropCnt,pdcpdrop, dbgSpaccThreshHoldDropCnt,spaccDropCount); /* UDAY */
+   dbgPdcpMemCount =0;
+   dbgPdcpQSizeThreshHoldDropCnt=0;
+   pdcpdrop = 0;
+
+   spaccDropCount = 0;
+   //pdcpDropMemTh=0;
+#endif
+#endif
+}
+#else
+void PrintPDCPStats(void)
+{
+   printf ("\n============================== PDCP STATS ===========================\n");
+   RTLIN_DUMP_DEBUG("SDUs Dropped = (%u) No of Reodering Tmr Exp (%u)",
+         gPdcpStats.numPdcpSdusDiscarded, gPdcpStats.numPdcpCellReorderTmrExp);
+}
+#endif
+
+#ifdef ANSI
+PRIVATE S16 pjUtlDlHdlSecInitCfm
+(
+PjCb        *gCb,              /* Pointer to PJ DL Control Block */
+PjDlUeCb      *ueCb,           /* Pointer to UeCb */ 
+U16         txIdx,             /* Transaction Index for UeCb */
+PjAsyncCfm       *asyncCfm,
+UdxSecCfgCfmInfo *secCfgCfm,   /* Security config confirm */
+UdxReEstCfmInfo  *reEstCfm     /* Reest config confirm */
+)
+#else
+PRIVATE S16 pjUtlDlHdlSecInitCfm(gCb,ueCb,txIdx,secCfgCfm,reEstCfm)
+(                              
+PjCb        *gCb;              /* Pointer to PJ DL Control Block */
+PjDlUeCb      *ueCb;           /* Pointer to UeCb */ 
+U16         txIdx;             /* Transaction Index for UeCb */
+PjAsyncCfm       *asyncCfm;
+UdxSecCfgCfmInfo *secCfgCfm;   /* Security config confirm */
+UdxReEstCfmInfo  *reEstCfm;    /* Reest config confirm */
+)
+#endif   
+{
+   PjUdxDlSapCb    *udxSap;
+   S16             ret = ROK;
+   
+   TRC3(pjUtlDlHdlSecInitCfm)
+
+   if(asyncCfm->libInitBitMask == 0)
+   {
+      PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx);
+      if(ueCb->libInfo.state == PJ_STATE_NORMAL)
+      {
+         /* Send security config confirm */
+         /* Memory leak fix ccpu00135359 */
+         udxSap    = &(gCb->u.dlCb->udxDlSap[0]);
+         PJ_ALLOC_BUF_SHRABL(udxSap->pst,secCfgCfm,
+                  sizeof (UdxSecCfgCfmInfo), ret);
+         if(ret != ROK)
+         {
+            RLOG0(L_FATAL, "Memory Allocation failed.");
+            RETVALUE(RFAILED);
+         }
+         PJ_FILL_SEC_CFM_INFO(secCfgCfm, asyncCfm);
+
+         PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+         PjDlUdxSecCfgCfm(&gCb->u.dlCb->udxDlSap[0].pst, 
+               gCb->u.dlCb->udxDlSap[0].suId, 
+               (UdxSecCfgCfmInfo *) secCfgCfm);
+      }
+      else if(ueCb->libInfo.state == PJ_STATE_REEST)
+      {
+         /* Send ReEstCfm */
+         /* Memory leak fix ccpu00135359 */
+         udxSap    = &(gCb->u.dlCb->udxDlSap[0]);
+         PJ_ALLOC_BUF_SHRABL(udxSap->pst,reEstCfm,
+                  sizeof (UdxReEstCfmInfo), ret);
+         if(ret != ROK)
+         {
+            RLOG0(L_FATAL, "Memory Allocation failed.");
+            RETVALUE(RFAILED);
+         }
+         PJ_FILL_REEST_CFM_INFO(reEstCfm, asyncCfm, LCM_PRIM_OK);
+
+         /* Some house keeping work */
+         PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+         PjDlUdxReEstCfm(&gCb->u.dlCb->udxDlSap[0].pst, 
+               gCb->u.dlCb->udxDlSap[0].suId, reEstCfm);
+
+         pjUtlReEstDl(gCb, ueCb);
+      }
+   }
+   RETVALUE(ROK);
+}
+
+
+#ifdef ANSI
+PRIVATE S16 pjUtlDlHdlCmpInitCfm
+(
+PjCb           *gCb,            /* Pointer to PJ DL Control Block */
+PjDlUeCb       *ueCb,           /* Pointer to UeCb */ 
+U16            txIdx,           /* Transaction Index for UeCb */
+PjAsyncCfm     *asyncCfm,       /* Async Confirm */
+UdxCfgCfmInfo  *cfgCfm         /* UDX Config Confirm */
+)
+#else
+PRIVATE S16 pjUtlDlHdlCmpInitCfm(gCb,ueCb,txIdx,asyncCfm,cfgCfm)
+(                              
+PjCb           *gCb;            /* Pointer to PJ DL Control Block */
+PjDlUeCb       *ueCb;           /* Pointer to UeCb */ 
+U16            txIdx;           /* Transaction Index for UeCb */
+PjAsyncCfm     *asyncCfm;       /* Async Confirm */
+UdxCfgCfmInfo  *cfgCfm;         /* UDX Config Confirm */
+)
+#endif   
+{
+   PjUdxDlSapCb    *udxSap;
+   U32             idx;
+   S16             ret = ROK;
+   TRC3(pjUtlDlHdlCmpInitCfm)
+
+      asyncCfm->libInitBitMask ^= (PJ_LIB_COMP_BIT_MASK);
+
+   if((asyncCfm->libInitBitMask == 0) &&
+         !(asyncCfm->cfmType & PJ_CFG_REEST_ASYNC_CFM))
+   {
+
+      /* Send config confirm */
+      /* Memory leak fix ccpu00135359 */
+      udxSap    = &(gCb->u.dlCb->udxDlSap[0]);
+      PJ_ALLOC_BUF_SHRABL(udxSap->pst,cfgCfm,
+               sizeof (UdxCfgCfmInfo), ret);
+      if(ret != ROK)
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         RETVALUE(RFAILED);
+      }
+      cfgCfm->transId = asyncCfm->transId;
+      cfgCfm->ueId    = asyncCfm->ueId;
+      cfgCfm->cellId  = asyncCfm->cellId;
+      cfgCfm->numEnt  = asyncCfm->numEnt; 
+      for ( idx = 0; idx < asyncCfm->numEnt; idx++ )
+      {
+         cfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status;  
+         cfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason;  
+         cfgCfm->cfmEnt[idx].rbId   = asyncCfm->cfmEnt[idx].rbId;
+         cfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType;
+      }
+
+      /* Some house keeping work */
+      PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx);
+      PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+      /* Send confirmtion to the User */
+      PjDlUdxCfgCfm(&(gCb->u.dlCb->udxDlSap[0].pst), 
+            gCb->u.dlCb->udxDlSap[0].suId, 
+            (UdxCfgCfmInfo *)cfgCfm);
+   }
+   
+   RETVALUE(ROK); 
+}
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_dlm.c b/src/5gnrpdcp/pj_dlm.c
new file mode 100755 (executable)
index 0000000..d2ad481
--- /dev/null
@@ -0,0 +1,2831 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/**********************************************************************
+
+     Name:     LTE-PDCP Layer 
+  
+     Type:     C file
+  
+     Desc:     Source code for PDCP Downlink module.
+               This file contains following functions
+
+                  --pjDlmProcessSdus
+                  --pjDlmBldPdu
+                  --pjDlmReEstSrb
+                  --pjDlmReEstDrbUm
+                  --pjDlmReEstDrbAm
+                  --pjDlmProcessCfm
+                  --pjDlmHndlStaRep
+                  --pjDlmDiscSdu
+                  --pjDlmDeliverPdu
+                  --pjDlmReEstHoDrbAm
+                  --pjDlmHndlDatFwdReq
+                  --pjDlmProcSrb
+                  --pjDlmProcDrb
+
+     File:     pj_dlm.c
+
+**********************************************************************/
+
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_FILE_ID=241;
+static int RLOG_MODULE_ID=1024;
+/** @file pj_dlm.c
+@brief PDCP Downlink module
+*/
+
+/* header (.h) include files */
+#include "envopt.h"             /* environment options */
+#include "envdep.h"             /* environment dependent */
+#include "envind.h"             /* environment independent */
+
+#include "gen.h"                /* general */
+#include "ssi.h"                /* system services interface */
+#include "cm5.h"                /* Timer Functions */
+#include "cm_lte.h"             /* common LTE header file */
+#include "cm_hash.h"            /* common hash module  file */
+#include "cm_llist.h"           /* common list header file */
+#include "cpj.h"                /* RRC layer */
+#include "pju.h"                /* PDCP service user */
+#include "lpj.h"                /* LPJ defines */
+#include "pj_env.h"             /* RLC environment options */
+#include "pj.h"                 /* RLC layer */
+#include "pj_dl.h"
+#include "pj_err.h"
+#include "pj_ptsec.h"
+#ifndef TENB_T2K3K_SPECIFIC_CHANGES 
+void prc_trace_format_string(U32 group_mask, U16 level, const char *format, ...);
+#endif
+
+
+/* header/extern include files (.x) */
+#include "gen.x"                /* general */
+#include "ssi.x"                /* system services interface */
+#include "cm_lib.x"             /* common library */
+#include "cm5.x"                /* Timer Functions */
+#include "cm_hash.x"            /* common hash module */
+#include "cm_lte.x"             /* common LTE file */
+#include "cm_llist.x"           /* common list header file */
+#include "cpj.x"                /* RRC layer */
+#include "pju.x"                /* PDCP service user */
+#include "lpj.x"                /* LPJ defines */
+#include "pj.x"                 /* RLC layer */
+#include "pj_udx.h"
+#include "pj_udx.x"
+#include "pj_dl.x"
+#include "pj_ul.x"
+
+EXTERN U32 pjTotDlPckCntPerCell;
+#ifdef TENB_AS_SECURITY 
+EXTERN U8 isSecBatchMode;
+#endif
+
+
+#ifdef TENB_T2K3K_SPECIFIC_CHANGES
+EXTERN Ticks SGetT2KTtiCount(Void);
+#endif
+/* kw005.201 Moved definition of PJ_ASYNC_WIN to kw.h file */
+/** @addtogroup dldata */
+/*@{*/
+EXTERN S16 pjUtlChekTxEnqReq ARGS(( PjCb *gCb, PjDlRbCb *pjRbCb, PjTxEnt *txEnt));
+
+PRIVATE S16 pjDlmBldPdu(PjCb *gCb,PjDlRbCb *pjRbCb,PjTxEnt *txEnt);
+PRIVATE Void pjDlmDelTxEntUptoFmc ARGS ((PjCb *gCb, PjDlRbCb *pjRbCb, U32 fmc, PjuDatCfmInfo *datCfm));
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to free all sdus present in datCfmQ till the First Missing
+ *        Segment. 
+ *
+ *  @param[in] pjRbCb   PDCP control block.
+ *  @param[in] fmc      First Missing Segment count
+ *  @param[in] datCfm   datCfm 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PRIVATE Void pjDlmDelTxEntUptoFmc
+(
+PjCb            *gCb,
+PjDlRbCb        *pjRbCb,
+U32             count,
+PjuDatCfmInfo   *datCfm
+)
+#else
+PRIVATE Void pjDlmDelTxEntUptoFmc(gCb, pjRbCb, count, datCfm)
+PjCb            *gCb;
+PjDlRbCb        *pjRbCb;
+U32             count;
+PjuDatCfmInfo   *datCfm;
+#endif
+{
+   PjTxEnt   *txEnt;
+
+
+   cmLListFirst(&pjRbCb->dlCb.txBuf.datCfmQ);
+   while (cmLListCrnt(&pjRbCb->dlCb.txBuf.datCfmQ))
+   {
+     txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.datCfmQ));
+     if (txEnt != NULLP)
+     {
+        if (txEnt->count < count)
+        { 
+           if (pjRbCb->dlCb.cfmReqd && datCfm!= NULLP)
+           {
+              /* As of now, DATCFM is sent only for the 1st 25 PDUs. Once we      */
+              /* enable cfmReqd, we need to add code to send for all PDUs in loop */
+              if(datCfm->numSdus < PJU_MAX_SDU_CFM) 
+              {
+                 datCfm->cfmSta[datCfm->numSdus].sduId  = txEnt->sduId;
+                 datCfm->cfmSta[datCfm->numSdus].status = PJ_CFM_OK;
+                 datCfm->numSdus++;
+              }
+           }
+           pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count);
+        }
+        else
+        {
+           /* fmc reached break out of the loop */
+           break;
+        }
+     } 
+     cmLListNext(&pjRbCb->dlCb.txBuf.datCfmQ);
+   }
+
+   RETVOID;
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to process the SDU received from upper layer, form a PDU
+ *        and send the PDU to the lower layer.
+ *
+ * @b Description: 
+ *
+ *        1. This function places the SDU in the transmission buffer and performs
+ *        Compression for DRB SDUs and Integrity Protection for SRB SDUs.  @n
+ *        2. After compression/integrity protection, it performs ciphering and then 
+ *        constructs the PDU and sends it to the lower layer. @n
+ *        3. The first DL message of SRBs is not ciphered and is just integrity 
+ *        protected.  @n 
+ *        4. This function checks the UE CB control block to check the flag for the 
+ *        first DL message and performs only integrity protection and unsets 
+ *        the flag.       @n 
+ *            
+ *  @param[in] pjRbCb   PDCP control block.
+ *  @param[in] sdu      SDU to be processed.
+ *  @param[in] sduId    SDU ID. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+
+U32 pjTxSdu;
+
+#ifdef ANSI
+PUBLIC S16 pjDlmProcessSdus
+(
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb,                   /* !< PDCP Control Block */
+Buffer     *sdu,                      /* !< SDU to be processed */
+U32        sduId,                      /* !< PDCP SDU ID */
+U32        count                      /* !< count to be assigned */
+)
+#else 
+PUBLIC S16 pjDlmProcessSdus(gCb, pjRbCb, sdu, sduId, count)
+PjCb       *gCb;
+PjDlRbCb   *pjRbCb;                   /* !< PDCP Control Block */
+Buffer     *sdu;                      /* !< SDU to be processed */
+U32        sduId;                     /* !< PDCP SDU ID */
+U32        count;                     /* !< count to be assigned */
+#endif
+{
+   S16      ret;                  /* Return Value */
+   PjTxEnt  *txEnt;               /* Transmission Entity for sdu*/
+#ifdef L2_PDCP_OPTMZ   
+   U8       hashKey;          /* Computed HashKey */
+   PjBuf       *buf; 
+#endif   
+
+   TRC2(pjDlmProcessSdus)
+
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_DLM | PJ_DBGMASK_BRIEF | PJ_DBGMASK_DL),
+         (gCb->init.prntBuf, "pjDlmProcessSdus(pjRbCb(%d), sdu, sduId(%ld), \
+                    txHfn) \n)", pjRbCb->rbId, sduId));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_DLM | PJ_DBGMASK_BRIEF | PJ_DBGMASK_DL),
+         (gCb->init.prntBuf, "pjDlmProcessSdus(pjRbCb(%d), sdu, sduId(%d), \
+                     txHfn) \n)", pjRbCb->rbId, sduId));
+#endif
+
+
+   ret = ROK;
+   
+   /* Allocate the transmission entity */
+   PJ_ALLOC(gCb,txEnt, sizeof(PjTxEnt));
+
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if (txEnt == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_FREE_BUF(sdu);
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_RES */
+
+   /* Update COUNT to the current count in dlCb*/
+   pjRbCb->dlCb.count = count;
+   /* Fill TxEnt values */
+   PJ_DLM_GET_SN(pjRbCb,count,txEnt->sn);
+   //txEnt->count = count;
+   //txEnt->txHfn = txHfn;
+   txEnt->count = count;
+   txEnt->state = PJ_SDU_RECEIVED;
+   txEnt->sduId = sduId;
+   /* The received buffer is stored in the SDU and the output from 
+    * Compression/Ciphering is stored in the PDU.
+    */
+   txEnt->sdu   = sdu;
+   txEnt->pdu   = NULLP;
+
+   /* Process the SDU based on rbType */
+   if (pjRbCb->rbType == PJ_SRB)
+   {
+      /* Insert TxEnt into the transmission buffer */
+      pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt);
+      ret = pjDlmProcSrb(gCb, pjRbCb, txEnt);
+   }
+   else
+   {
+#ifndef RGL_SPECIFIC_CHANGES      
+#ifndef TENB_ACC
+#ifndef LTE_PAL_ENB
+      EXTERN U32 dlrate_pju;
+   MsgLen len;
+   SFndLenMsg(sdu, (MsgLen *) &len);
+   dlrate_pju += len;
+#endif 
+#endif
+#endif
+#ifndef L2_PDCP_OPTMZ
+      pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt);
+#else
+      /* Fix for NULL ciphering. For null ciphering add PDUs to sduSubmitQ*/
+      if(pjRbCb->ueCb->secInfo.secAct && pjRbCb->ueCb->secInfo.cipherInfo.algoType != 0)
+      {
+         txEnt->datCfmEnt.node = NULLP;
+         txEnt->reEstPktEnt.node = NULLP;
+         txEnt->sduSubmitEnt.node = (PTR)NULLP;
+
+         buf=&(pjRbCb->dlCb.txBuf);
+         hashKey = (U8)PJ_HASH_FN(buf, txEnt->count); /*KW_FIX*/
+
+         txEnt->lstEnt.node = (PTR)txEnt;
+         cmLListAdd2Tail(&buf->datQ[hashKey], &txEnt->lstEnt);
+         buf->numEntries ++;
+         /* Dont add PDUs to datCfmQ in case of UM mode*/
+         if (pjRbCb->mode == PJ_DRB_AM ) 
+         {
+            txEnt->datCfmEnt.node = (PTR)txEnt;
+            cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.datCfmQ, &txEnt->datCfmEnt);
+         }
+         txEnt->state  = PJ_PDU_SUBMITTED;
+      }
+      else
+      {
+         pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt);
+      }
+#endif   
+      ret = pjDlmProcDrb(gCb, pjRbCb, txEnt);
+   }
+
+   RETVALUE(ret);
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to Re-establish a SRB.
+ *
+ * @b Description: 
+ *
+ *        1. This function is called when re-establishment request is
+ *        received for a SRB.   @n
+ *        2. The stored PDUs and SDUs are freed and the variables are reset. @n
+ *            
+ *  @param[in] pjRbCb   PDCP control block.
+ *
+ */
+
+#ifdef ANSI
+PUBLIC Void pjDlmRbDataResume
+(
+PjCb   *gCb,
+PjDlRbCb *pjRbCb
+)
+#else
+PUBLIC Void pjDlmRbDataResume(gCb, pjRbCb)
+PjCb   *gCb;
+PjDlRbCb *pjRbCb;
+#endif
+{
+   S16      ret;
+   PjTxEnt *txEnt;
+   TRC3(pjDlmRbDataResume)
+
+   RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmRbDataResume(pjRbCb ()) ");
+                       
+   cmLListFirst(&pjRbCb->dlCb.txBuf.reEstPktQ);
+   while (cmLListCrnt(&pjRbCb->dlCb.txBuf.reEstPktQ))
+   {
+      txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.reEstPktQ));
+#if (ERRCLASS & ERRCLS_DEBUG)  /* KW_FIX */
+         if(txEnt == NULLP)
+         {
+            RLOG_ARG0(L_ERROR,DBG_RBID,pjRbCb->rbId, 
+                  "pjDlmRbDataResume:Transmission Entity is NULL ");
+   /*ccpu00136858 : Void function returning RFAILED */      
+            RETVOID;
+         }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+/* Free the existing PDU and cpy the SDU to PDU */
+
+#ifdef FLAT_BUFFER_OPT
+#ifndef XEON_SPECIFIC_CHANGES
+         {
+            /* Check whether the spacc q has space to hold
+               this packet.. else dropping */
+            if(FALSE == (pjMsCheckSpaccQueue(FALSE)))
+            {
+               {
+                  extern U32 spaccDropCount;
+                  spaccDropCount++;
+               }
+               PJ_FREE_FLAT_BUF(pjCb[1],&(txEnt->fb));
+               gPdcpStats.numPdcpSdusDiscarded++;
+               PJ_UPD_L2_DLDISC_STS(pjCb[1], pjRbCb);
+
+               if(txEnt->pdu != NULL)
+                 printf("PDU is not null while deletion");
+
+               if(txEnt->sdu != NULL)
+                 printf("SDU is not null while deletion");
+               pjDbmDelTxEnt(pjCb[1], &(pjRbCb->dlCb.txBuf), txEnt->count);
+               //txEnt->reEstPktEnt.node = NULLP;
+               //cmLListDelFrm(&pjRbCb->dlCb.txBuf.reEstPktQ, &txEnt->reEstPktEnt);
+
+               cmLListFirst(&pjRbCb->dlCb.txBuf.reEstPktQ);
+               continue;
+            }
+         }
+#endif
+#endif
+#ifdef FLAT_BUFFER_OPT
+         if(txEnt->sdu == NULLP)
+         {
+            PJ_FREE_BUF(txEnt->pdu);
+         }
+         else
+#endif
+         if ( txEnt->pdu != txEnt->sdu )
+         {
+            PJ_FREE_BUF(txEnt->pdu);
+         }
+         else
+         {
+            txEnt->pdu = NULLP;
+         }
+#ifdef L2_PDCP_OPTMZ
+         txEnt->state = PJ_PDU_SUBMITTED;
+#else
+         txEnt->state = PJ_SDU_RECEIVED;
+#endif         
+         /* Fix for ccpu00135798 */
+         txEnt->reEstPktEnt.node = NULLP;
+         cmLListDelFrm(&pjRbCb->dlCb.txBuf.reEstPktQ, &txEnt->reEstPktEnt);
+#ifndef L2_PDCP_OPTMZ         
+         txEnt->sduSubmitEnt.node = (PTR)txEnt;
+         cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.sduSubmitQ, &txEnt->sduSubmitEnt);
+#else
+         if( pjRbCb->mode == PJ_DRB_AM)
+         {
+         txEnt->datCfmEnt.node = (PTR)txEnt;
+         cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.datCfmQ, &txEnt->datCfmEnt);
+         }
+#endif   
+
+         ret = pjDlmProcDrb(gCb, pjRbCb, txEnt);
+         if ( ret != ROK )
+         {
+             RLOG_ARG0(L_ERROR,DBG_RBID,pjRbCb->rbId, 
+                   "pjDlmRbDataResume: pjDlmProcDrb Failed ");
+         }
+      cmLListFirst(&pjRbCb->dlCb.txBuf.reEstPktQ);
+   }
+
+   pjDlmProcessDlPktQ(gCb,pjRbCb);
+   
+   RETVOID;
+}
+
+#ifdef FLAT_BUFFER_OPT
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to process the SDU received from upper layer, form a PDU
+ *        and send the PDU to the lower layer.
+ *
+ * @b Description: 
+ *
+ *        1. This function places the SDU in the transmission buffer and performs
+ *        Compression for DRB SDUs and Integrity Protection for SRB SDUs.  @n
+ *        2. After compression/integrity protection, it performs ciphering and then 
+ *        constructs the PDU and sends it to the lower layer. @n
+ *        3. The first DL message of SRBs is not ciphered and is just integrity 
+ *        protected.  @n 
+ *        4. This function checks the UE CB control block to check the flag for the 
+ *        first DL message and performs only integrity protection and unsets 
+ *        the flag.       @n 
+ *            
+ *  @param[in] pjRbCb   PDCP control block.
+ *  @param[in] sdu      SDU to be processed.
+ *  @param[in] sduId    SDU ID. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjDlmProcessSdusFB
+(
+PjCb   *gCb,                        /* !< Global control Block*/
+PjDlRbCb *pjRbCb,                   /* !< PDCP Control Block */
+FlatBuffer *sdu,                    /* !< SDU to be processed */
+U32    sduId,                       /* !< PDCP SDU ID */
+U32        count                    /* !< TX_HFN to be assigned */
+)
+#else 
+PUBLIC S16 pjDlmProcessSdusFB(gCb, pjRbCb, sdu, sduId, count)
+PjCb   *gCb;                        /* !< Global control Block*/
+PjDlRbCb *pjRbCb;                   /* !< PDCP Control Block */
+FlatBuffer *sdu;                    /* !< SDU to be processed */
+U32    sduId;                       /* !< PDCP SDU ID */
+U32        count;                   /* !< TX_HFN to be assigned */
+#endif
+{
+   S16      ret;                  /* Return Value */
+   PjTxEnt  *txEnt;               /* Transmission Entity for sdu*/
+#ifdef L2_PDCP_OPTMZ   
+   U8       hashKey;          /* Computed HashKey */
+   PjBuf       *buf; 
+#endif   
+
+
+   TRC2(pjDlmProcessSdusFB)
+      
+#ifndef ALIGN_64BIT
+   RLOG_ARG2(L_DEBUG,DBG_RBID,pjRbCb->rbId, 
+         "pjDlmProcessSdusFB(pjRbCb(), sdu, sduId(%ld), count(%ld) )",
+                         sduId, count);
+#else
+   RLOG_ARG2(L_DEBUG,DBG_RBID,pjRbCb->rbId, 
+         "pjDlmProcessSdusFB(pjRbCb(), sdu, sduId(%d), count(%d) )",
+                         sduId, count);
+#endif
+
+
+   ret = ROK;
+   
+   /* Allocate the transmission entity */
+   PJ_ALLOC(gCb,txEnt, sizeof(PjTxEnt));
+
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if (txEnt == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_FREE_FLAT_BUF(gCb,sdu);
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_RES */
+
+   /* Update COUNT to the current count in dlCb*/
+
+   PJ_DLM_UPD_VAR(pjRbCb,txEnt->count);
+   PJ_DLM_GET_SN(pjRbCb,txEnt->count,txEnt->sn);
+   pjRbCb->dlCb.count = txEnt->count;
+   /* Fill TxEnt values */
+   txEnt->state = PJ_SDU_RECEIVED;
+   txEnt->sduId = sduId;
+   /* The received buffer is stored in the SDU and the output from 
+    * Compression/Ciphering is stored in the PDU.
+    */
+   txEnt->fb   = *sdu;
+   txEnt->pdu   = NULLP;
+   txEnt->sdu   = NULLP;
+   /* Insert TxEnt into the transmission buffer */
+   /* kw005.201 added support for L2 Measurement */
+#ifndef L2_PDCP_OPTMZ
+      pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt);
+#else
+      /* Fix for NULL ciphering. For null ciphering add PDUs to sduSubmitQ*/
+      if(pjRbCb->ueCb->secInfo.secAct && pjRbCb->ueCb->secInfo.cipherInfo.algoType != 0)
+      {
+         txEnt->datCfmEnt.node = NULLP;
+         txEnt->reEstPktEnt.node = NULLP;
+         txEnt->sduSubmitEnt.node = (PTR)NULLP;
+
+         buf=&(pjRbCb->dlCb.txBuf);
+         hashKey = (U8)PJ_HASH_FN(buf, txEnt->count); /*KW_FIX*/
+
+         txEnt->lstEnt.node = (PTR)txEnt;
+         cmLListAdd2Tail(&buf->datQ[hashKey], &txEnt->lstEnt);
+         buf->numEntries ++;
+
+         /* Dont add PDUs to datCfmQ in case of UM mode*/
+         if (pjRbCb->mode == PJ_DRB_AM ) 
+         {
+            txEnt->datCfmEnt.node = (PTR)txEnt;
+            cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.datCfmQ, &txEnt->datCfmEnt);
+         }
+
+         txEnt->state  = PJ_PDU_SUBMITTED;
+      }
+      else
+      {
+         pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt);
+      }
+#endif   
+
+   /* Process the SDU based on rbType */
+   {
+#ifndef RGL_SPECIFIC_CHANGES
+#ifdef MSPD
+      {
+         extern U32 dlrate_pju;
+         dlrate_pju += sdu->len;
+      }
+#endif
+#endif
+      ret = pjDlmProcDrb(gCb, pjRbCb, txEnt);
+   }
+
+   RETVALUE(ret);
+}
+#endif
+
+/**
+*
+ * @brief 
+ *
+ *        Handler to construct a data PDU/Control PDU.
+ *
+ * @b Description: 
+ *
+ *        1. This function constructs the PDU header based on the SN length
+ *        configured.    @n
+ *        2. The header is inserted at the start of the PDU and
+ *        the constructed PDU is returned to the calling function. @n
+ *            
+ *  @param[in] pjRbCb   PDCP control block. 
+ *  @param[in] txEnt    Transmission Entity.
+ *                 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PRIVATE S16 pjDlmBldPdu
+(
+PjCb    *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+)
+#else
+PRIVATE S16 pjDlmBldPdu(gCb,pjRbCb,txEnt)
+PjCb    *gCb;
+PjDlRbCb  *pjRbCb;
+PjTxEnt *txEnt;
+#endif
+{
+   U32        hdr;                /* Header field */
+   S16        ret;                /* Return Value */
+   U32        numBytes;           /* Number of bytes to be added to the PDU */
+
+   TRC3(pjDlmBldPdu)
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_DLM | PJ_DBGMASK_BRIEF | PJ_DBGMASK_DL),
+                (gCb->init.prntBuf, "pjDlmBldPdu(pjRbCb, txEnt (%ld)) \n", txEnt->sduId));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_DLM | PJ_DBGMASK_BRIEF | PJ_DBGMASK_DL),
+                (gCb->init.prntBuf, "pjDlmBldPdu(pjRbCb, txEnt (%d)) \n", txEnt->sduId));
+#endif
+  
+   hdr       = txEnt->sn;
+   ret       = ROK;
+   numBytes  = 2; /* for SRB it is 1 byte and even for 7 bit SN  on DRB it is 1 byte */
+
+   //hdr = 0x234;
+
+   /* Build a Data PDU */
+   if ( pjRbCb->rbType != PJ_SRB )
+   {
+      
+      /* The two byte header has the SN and MSB as '1' */
+      if (pjRbCb->snLen == PJ_12_BIT_SN) 
+      {
+         hdr |= PJ_DRB_12BIT_SN_HDR;
+         numBytes = 2;
+      }
+      else if (pjRbCb->snLen == PJ_18_BIT_SN)
+      {
+         hdr |= PJ_DRB_18BIT_SN_HDR;
+         numBytes = 3;
+      }
+   }
+
+   /* Add the hdr(based on numBytes) at the start of the PDU */
+   PJ_ADD_PRE_MSG( txEnt->pdu, hdr, numBytes, ret);
+
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if (ret != ROK)
+   {
+      RLOG_ARG1(L_ERROR, DBG_RBID, pjRbCb->rbId, 
+            "SAddPreMsg failed SN [%u]",
+            txEnt->sn );
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_RES */
+   RETVALUE(ret);
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to Re-establish a SRB.
+ *
+ * @b Description: 
+ *
+ *        1. This function is called when re-establishment request is
+ *        received for a SRB.   @n
+ *        2. The stored PDUs and SDUs are freed and the variables are reset. @n
+ *            
+ *  @param[in] pjRbCb   PDCP control block.
+ *
+ */
+
+#ifdef ANSI
+PUBLIC Void pjDlmReEstSrb
+(
+PjCb   *gCb,
+PjDlRbCb *pjRbCb
+)
+#else
+PUBLIC Void pjDlmReEstSrb(gCb, pjRbCb)
+PjCb   *gCb;
+PjDlRbCb *pjRbCb;
+#endif
+{
+
+   TRC3(pjDlmResetSrb)
+
+   RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmResetSrb(pjRbCb ()) ");
+  
+
+   /* Stop the off-board and discard timer if running */
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+   if (pjRbCb->dlCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR)
+   {
+       pjStopTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR);
+   }
+#endif
+   /* Clean up all the SDUs present */ 
+   pjDbmTxDelAll(gCb, &(pjRbCb->dlCb.txBuf));
+
+   /* Reset the variables in rbCb */
+   PJ_RESET_ALL_VAR(pjRbCb);
+   /*kw004.201 Adding of Missing Trace in LTE RLC PDCP*/
+   RETVOID;
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to Re-establish a UM DRB.
+ *
+ * @b Description: 
+ *
+ *        1. This function is called when re-establishment request is
+ *           received for a UM DRB.   @n
+ *        2. The stored PDUs are freed and the variables are reset.  @n
+ *        3. The PDUs which were associated with a SN and were not sent 
+ *           to the lower layer are now sent with the new ciphering 
+ *           algorithm and keys. @n
+ *            
+ *  @param[in] pjRbCb   PDCP control block. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjDlmReEstDrbUm
+(
+PjCb   *gCb,
+PjDlRbCb *pjRbCb
+)
+#else
+PUBLIC S16 pjDlmReEstDrbUm(gCb,pjRbCb)
+PjCb   *gCb;
+PjDlRbCb *pjRbCb;
+#endif
+{
+   S16            ret;                     /* Return Value */ 
+   PjTxEnt        *txEnt;                  /* Transmission Entity */
+   PjBuf          tmpTxBuf;                /* Tx Buffer */ 
+   TRC3(pjDlmReEstDrbUm)
+
+   RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmReEstDrbUm(pjRbCb ()) ");
+   ret      = ROK; /* KW_FIX */
+   txEnt    =  NULLP;
+
+   /* Reset all the variable */
+   PJ_RESET_ALL_VAR(pjRbCb);
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+   /* Stop the off board timer if running */
+   if (pjRbCb->dlCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR)
+   {
+       pjStopTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR);
+   } 
+#endif
+
+   if(pjRbCb->dlCb.txBuf.numEntries == 0)
+   {
+      RETVALUE(ROK);
+   }
+
+   /* Create the new buffer list  and store the old pointer in datQ */
+   PJ_CREATE_NEW_LIST(gCb,pjRbCb, tmpTxBuf, ret);
+#if (ERRCLASS & ERRCLS_ADD_RES) 
+   if (ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed");
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_RES */
+
+   /* Process all the existing PDUs as received from above layer */
+   cmLListFirst(&tmpTxBuf.sduSubmitQ);
+   while (cmLListCrnt(&tmpTxBuf.sduSubmitQ))
+   {
+      U8   hashKey = 0;
+      txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&tmpTxBuf.sduSubmitQ));
+      /* Assign the new SN, TX_HFN and insert in the new transmission
+       * buffer.
+       */
+      if ( txEnt != NULLP )
+      {
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+         if ( txEnt->pdu != txEnt->sdu )
+         {
+            PJ_FREE_BUF(txEnt->pdu);
+         }
+         else
+         {
+            txEnt->pdu = NULLP;
+         }
+#endif
+         hashKey = (U8)PJ_HASH_FN((&tmpTxBuf), txEnt->count);
+         PJ_DLM_UPD_VAR(pjRbCb,txEnt->count);     
+         PJ_DLM_GET_SN(pjRbCb,txEnt->count,txEnt->sn);
+         pjRbCb->dlCb.count = txEnt->count; 
+         txEnt->state = PJ_SDU_RECEIVED;
+         txEnt->pdu = NULLP;
+
+         cmLListDelFrm(&tmpTxBuf.datQ[hashKey], &txEnt->lstEnt);
+         cmLListDelFrm(&tmpTxBuf.sduSubmitQ, &txEnt->sduSubmitEnt);
+
+         tmpTxBuf.numEntries --;
+
+         pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt);
+
+         txEnt->reEstPktEnt.node = (PTR)txEnt;
+         cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.reEstPktQ, &txEnt->reEstPktEnt);
+
+         txEnt->sduSubmitEnt.node=NULLP;
+         cmLListDelFrm(&pjRbCb->dlCb.txBuf.sduSubmitQ, &txEnt->sduSubmitEnt);
+      }
+      cmLListFirst(&tmpTxBuf.sduSubmitQ);
+   }
+   /* Free up the old transmission buffer */
+   pjDbmTxDeInit(gCb,&tmpTxBuf);
+   RETVALUE(ret);    
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to Re-establish a AM DRB.
+ *
+ * @b Description: 
+ *
+ *        1. This function is called when re-establishment request is
+ *        received for a AM DRB.     @n
+ *        2. The stored PDUs are freed.   @n
+ *        3. The PDUs which were not submitted to the lower
+ *        layer and for which a confirm has not been received
+ *        are now sent with the new ciphering algorithm and keys. @n
+ *            
+ *  @param[in] pjRbCb   PDCP control block. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjDlmReEstDrbAm
+(
+PjCb   *gCb,
+PjDlRbCb *pjRbCb
+)
+#else
+PUBLIC S16 pjDlmReEstDrbAm(gCb,pjRbCb)
+PjCb   *gCb;
+PjDlRbCb *pjRbCb;
+#endif
+{
+   PjTxEnt        *txEnt;
+
+   TRC3(pjDlmReEstDrbAm)
+
+   RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmReEstDrbAm(pjRbCb ()) ");
+  
+   if (pjRbCb->dlCb.txBuf.numEntries == 0)
+   {
+      RETVALUE(ROK);
+   }
+   cmLListFirst(&pjRbCb->dlCb.txBuf.datCfmQ);
+   while (cmLListCrnt(&pjRbCb->dlCb.txBuf.datCfmQ))
+   {
+      txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.datCfmQ));
+#if (ERRCLASS & ERRCLS_DEBUG)  /* KW_FIX */
+         if(txEnt == NULLP)
+         {
+            RLOG_ARG0(L_ERROR,DBG_RBID,pjRbCb->rbId, 
+                  "pjDlmReEstDrbAm:Transmission Entity is NULL ");
+            RETVALUE(RFAILED);
+         }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+      if (txEnt != NULLP)
+      {
+          txEnt->reEstPktEnt.node = (PTR)txEnt;
+          cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.reEstPktQ, &txEnt->reEstPktEnt);
+          pjTotDlPckCntPerCell--;          
+      }
+      txEnt->datCfmEnt.node = NULLP;
+      cmLListDelFrm(&pjRbCb->dlCb.txBuf.datCfmQ, &txEnt->datCfmEnt);
+      cmLListFirst(&pjRbCb->dlCb.txBuf.datCfmQ);
+   }
+
+   cmLListFirst(&pjRbCb->dlCb.txBuf.sduSubmitQ);
+   while (cmLListCrnt(&pjRbCb->dlCb.txBuf.sduSubmitQ))
+   {
+      txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.sduSubmitQ));
+      if (txEnt != NULLP)      /*KW_FIX : ccpu00136902*/
+      {
+         txEnt->reEstPktEnt.node = (PTR)txEnt;
+         cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.reEstPktQ, &txEnt->reEstPktEnt);
+         txEnt->sduSubmitEnt.node=NULLP;
+         cmLListDelFrm(&pjRbCb->dlCb.txBuf.sduSubmitQ, &txEnt->sduSubmitEnt);
+         cmLListFirst(&pjRbCb->dlCb.txBuf.sduSubmitQ);
+      }
+      else
+      {
+         RLOG_ARG0(L_ERROR,DBG_RBID,pjRbCb->rbId, "This should not be hit ");
+         break;
+      }
+   }
+
+   RETVALUE(ROK);
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to send data confirmation to RRC.
+ *
+ * @b Description: 
+ *
+ *        1. This function is called when a status indication or a confirm is 
+ *        received from the lower layer.  @n
+ *        2. The confirm type can be a success or failure. @n 
+ *        3. The corresponding SDUs and PDUs are cleaned up and
+ *        if cfmReqd is configured, a confirm is sent to the upper layer. @n
+ *            
+ *  @param[in] pjRbCb    PDCP control block. 
+ *  @param[in] staInd  Status Indication Information.
+ *  @param[in] cfmType Confirm Type can be SUCCESS or FAILURE.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+U32 pjRxCfm;
+
+#ifdef ANSI
+PUBLIC S16 pjDlmProcessCfm
+(
+PjCb          *gCb,
+PjDlRbCb        *pjRbCb,
+PjDatCfm      *pjDatCfm,
+U8            cfmType
+)
+#else
+PUBLIC S16 pjDlmProcessCfm(gCb,pjRbCb,pjDatCfm,cfmType)
+PjCb          *gCb;
+PjDlRbCb        *pjRbCb;
+PjDatCfm      *pjDatCfm;
+U8            cfmType;
+#endif
+{
+   PjuDatCfmInfo  *datCfm;        /* Data Cfm to be sent to upper layer */
+   U32            cnt;            /* Counter for number of SDUs in datCfm*/
+   U16            datCfmCnt;      /* Counter for number of SDUs in datCfm*/ /*KW_FIX*/
+   PjPjuSapCb     *pjuSap;        /* Upper Sap of PDCP User */
+   CmLtePdcpId    *pdcpId;        /* PDCP ID */
+   PjTxEnt        *txEnt;          /* Transmission entity */
+
+   TRC3(pjDlmProcessCfm)
+
+   gCb->pjPerfSts.pjSduRcvCnt += pjDatCfm->numSdu;
+
+   pdcpId   = NULLP;
+   cnt      = 0;
+   pjuSap   = NULLP;
+   datCfm   = NULLP;
+   txEnt    = NULLP;
+
+   /* If cfmReqd flag is sent a confirmation is sent to the above layer.
+    * For each SDU, get the sduId and status and fill in the datCfm
+    * structure and discard the txEnt. Also update cfmExp count.
+    */
+   if ( (pjRbCb->dlCb.cfmReqd) || (PJ_CFM_NOK == cfmType))
+   {
+      PjuDatCfmInfo datCfmTmp;
+      CmLtePdcpId pdcpIdTmp;
+      datCfm = &datCfmTmp;
+      pdcpId = &pdcpIdTmp;
+      pdcpId->rbId   = pjRbCb->rbId;
+      pdcpId->rbType = pjRbCb->rbType;
+      pdcpId->ueId   = pjRbCb->ueCb->key.ueId;
+      pdcpId->cellId = pjRbCb->ueCb->key.cellId;
+
+      if (pjRbCb->rbType == PJ_SRB)
+         pjuSap = &(gCb->u.dlCb->pjuSap[PJ_SRB_SAP]);
+      else
+         pjuSap = &(gCb->u.dlCb->pjuSap[PJ_DRB_SAP]);
+
+      datCfmCnt = 0;
+      for ( cnt = 0; cnt < pjDatCfm->numSdu; cnt++)
+      {
+         txEnt = (PjTxEnt *)pjDbmGetTxEnt(gCb,&(pjRbCb->dlCb.txBuf), 
+                                       pjDatCfm->sduId[cnt]);
+         if ( txEnt != NULLP )
+         {
+            datCfm->cfmSta[datCfmCnt].sduId  = txEnt->sduId;
+            /* RLC_DL_MAX_RETX fix */
+            if (PJ_CFM_OK != cfmType)
+            {
+               datCfm->cfmSta[datCfmCnt].status = PJU_RLC_TRANS_FAIL;
+            }
+            else
+            {
+               datCfm->cfmSta[datCfmCnt].status = cfmType;
+            }
+
+            datCfm->cfmSta[datCfmCnt].status = cfmType;
+            datCfmCnt ++;
+            pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count);
+         }
+      }
+      datCfm->numSdus = datCfmCnt;
+      if(datCfm->numSdus)
+      {
+         /* If trace flag is enabled send the trace indication */
+         if(gCb->init.trc == TRUE)
+         {
+            /* Populate the trace params */
+            pjLmmSendTrc(gCb, EVTPJUDATCFM, NULLP);
+         }
+
+         PjUiPjuDatCfm(&pjuSap->pst, pjuSap->suId, pdcpId, datCfm);
+      }
+   }
+   /* If cfmReqd is not set, discard the txEnts and update the cfmExp count */
+   else
+   {
+      for ( cnt = 0; cnt < pjDatCfm->numSdu; cnt++)
+      {
+         pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), pjDatCfm->sduId[cnt]);
+      }
+   
+   }
+
+   RETVALUE(ROK);
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to send process the status report.
+ *
+ * @b Description: 
+ *
+ *        1. This function is called when a status report is received from the
+ *        peer.    @n
+ *        2. This function process the status report and sends a confirmation
+ *        to the above layer and removes the PDUs and SDUs for which positive 
+ *        acknowledgement is received.  @n
+ *            
+ *  @param[in] pjRbCb      PDCP control block. 
+ *  @param[in] staPdu      Status report.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjDlmHndlStaRep
+(
+PjCb     *gCb,
+PjDlRbCb   *pjRbCb,
+PjSn     fmc,
+Buffer   *staPdu
+)
+#else
+PUBLIC S16 pjDlmHndlStaRep(gCb,pjRbCb,fmc,staPdu)
+PjCb     *gCb;
+PjDlRbCb   *pjRbCb;
+PjSn     fmc;
+Buffer   *staPdu;
+#endif
+{
+   PjuDatCfmInfo *datCfm;       /* Dat Cfm to be sent to the upper layer */
+   PjuDatCfmInfo datCfmTmp;     /* Tmp variable allocated to assign local memory to the datCfm pointer */
+   CmLtePdcpId pdcpIdTmp;       /* Tmp variable allocated to assign local memory to the pdcpId pointer */
+   S16           ret;           /* Return Value */
+   PjPjuSapCb    *pjuSap;       /* PJU SAP Control Block */
+   CmLtePdcpId   *pdcpId;       /* PDCP ID */
+   U32           bitPos;        /* Bit position in the Status PDU */
+   U8            cnt;           /* Counter for the bits in a byte */
+   U8            sduSta;        /* SDU Status of reception at the Peer */
+   PjTxEnt       *txEnt;        /* Transmission entity */
+   U8            byte;          /* One Byte of a Status Pdu */
+   MsgLen        bMapLen;       /* StaPdu Length in bytes */
+   PjSn          count;            /* count of the PDU */
+
+   TRC3(pjDlmHndlStaRep)
+
+   RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmHndlStaRep(pjRbCb (), fmc (%lu), staPdu) ",fmc);
+
+   datCfm  = NULLP;
+   ret     = ROK;
+   pjuSap  = NULLP;
+   pdcpId  = NULLP;
+
+   
+   /* Allocate for datCfm structure is cfmReqd is set */
+   if ( pjRbCb->dlCb.cfmReqd )
+   {
+    datCfm = &datCfmTmp;
+   }
+
+   /* Fills the confirm information for all the PDUs whose COUNT < COUNT(FMC) 
+    * and sets cfmExp to fmc
+    */
+   pjDlmDelTxEntUptoFmc(gCb, pjRbCb, fmc, datCfm);
+
+
+   cnt     = 0;
+   bitPos  = 1;
+   byte    = 0;
+   bMapLen = 0;
+   SFndLenMsg(staPdu, &bMapLen);
+
+   /* Read one byte at a time from Status PDU */
+   while ( bMapLen != 0 )
+   {
+      ret = SRemPreMsg(&byte,staPdu);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      if (ret != ROK)
+      {
+         RLOG0(L_ERROR, "SRemPreMsg Failed for staPdu");
+         PJ_FREE_BUF(staPdu);
+         RETVALUE(RFAILED);
+      }
+#endif /* ERRCLASS & ERRCLS_RES */
+
+      /* Check if each bit in a byte is set or not.
+       * If cfmReqd is set fill in the cfm info.
+       * Discard the txEnt if the bit is set to 1.
+       */
+      for ( cnt = 0; cnt < PJ_BYTE_LEN; cnt++, bitPos++ )
+      {
+         sduSta  = (byte << cnt) & PJ_FIRST_BIT;
+         if (sduSta)
+         {
+            count      = (fmc + bitPos) % PJ_TX_BUF_LEN;
+            txEnt   = (PjTxEnt *)pjDbmGetTxEnt(gCb, &(pjRbCb->dlCb.txBuf), count);
+            if ( txEnt != NULLP )
+            {
+               if ((pjRbCb->dlCb.cfmReqd)&& (datCfm->numSdus < PJU_MAX_SDU_CFM))
+               {
+                   
+                  datCfm->cfmSta[datCfm->numSdus].sduId  = txEnt->sduId;
+                  datCfm->cfmSta[datCfm->numSdus].status = sduSta;
+                  datCfm->numSdus++;;
+               }
+               pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count); 
+            }
+         }
+      }
+      bMapLen--;
+   }
+   /* Send a confirmation to the upper layer */
+   if ((pjRbCb->dlCb.cfmReqd) && (datCfm->numSdus > 0))
+   {
+     pdcpId = &pdcpIdTmp;
+
+     pdcpId->rbId   = pjRbCb->rbId;
+     pdcpId->rbType = pjRbCb->rbType;
+     pdcpId->ueId   = pjRbCb->ueCb->key.ueId;
+     pdcpId->cellId = pjRbCb->ueCb->key.cellId;
+
+     pjuSap   =  &gCb->u.dlCb->pjuSap[PJ_DRB_SAP];
+     /* If trace flag is enabled send the trace indication */
+     if(gCb->init.trc == TRUE)
+     {
+       /* Populate the trace params */
+       pjLmmSendTrc(gCb, EVTPJUDATCFM, NULLP);
+     }
+     PjUiPjuDatCfm(&pjuSap->pst, pjuSap->suId, pdcpId, datCfm);
+   }
+
+   PJ_FREE_BUF(staPdu);
+
+   RETVALUE(ret); 
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to forward the downlink data to the upper layer.
+ *
+ * @b Description: 
+ *
+ *        1. This function is used to send the downlink data to the upper layer
+ *        during handover.  @n
+ *        2. The unacknowledged data SDUs are sent to the upper
+ *        layer.    @n
+ *            
+ *  @param[in] pjRbCb      PDCP control block. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjDlmReEstHoDrbAm
+(
+PjCb   *gCb,
+PjDlRbCb *pjRbCb
+)
+#else
+PUBLIC S16 pjDlmReEstHoDrbAm(gCb,pjRbCb)
+PjCb    *gCb;
+PjDlRbCb  *pjRbCb;
+#endif
+{
+   TRC3(pjDlmReEstHoDrbAm)
+   
+   RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmReEstHoDrbAm(pjRbCb ()) ");
+
+
+   pjRbCb->pktAdmitCnt = 0;
+   pjRbCb->ueCb->hoInfo->hoCfmInfo[pjRbCb->rbId].pres = TRUE;
+   pjRbCb->ueCb->hoInfo->hoCfmInfo[pjRbCb->rbId].rbId = pjRbCb->rbId;
+   pjRbCb->ueCb->hoInfo->hoCfmInfo[pjRbCb->rbId].dir  = PJ_DIR_DL;
+   pjRbCb->ueCb->hoInfo->hoCfmInfo[pjRbCb->rbId].count = pjRbCb->dlCb.count + 1;
+
+   RETVALUE(ROK);
+}
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to forward the downlink data to the upper layer.
+ *
+ * @b Description: 
+ *
+ *        1. This function is used to send the downlink data to the upper layer
+ *        during handover.  @n
+ *        2. The unacknowledged data SDUs are sent to the upper
+ *        layer.    @n
+ *            
+ *  @param[in] pjRbCb      PDCP control block. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjDlmStartDataFrwdPerRb
+(
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb
+)
+#else
+PUBLIC S16 pjDlmStartDataFrwdPerRb(gCb,pjRbCb)
+PjCb       *gCb;
+PjDlRbCb   *pjRbCb;
+#endif
+{
+
+   U32              numSdu =0;
+   U16              count;   /*KW_FIX*/
+   U32              numSduCnt =0,numSduTx = 0;
+   PjTxEnt          *txEnt = NULLP;       
+   PjuDatFwdIndInfo *datFwdInd = NULLP;  
+   PjPjuSapCb   *pjuSap;
+   PjDlPkt    *pkt = NULLP;
+
+   TRC3(pjDlmStartDataFrwdPerRb)
+   
+   RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmStartDataFrwdPerRb(pjRbCb ()) ");
+
+   pjuSap   = &(gCb->u.dlCb->pjuSap[PJ_DRB_SAP]);
+   /* Update hoCfmInfo, used to fill SduStaCfm */
+   if(pjRbCb->dlCb.txNext == 0)
+   {
+    //  PJ_ALLOC(gCb,datFwdInd, sizeof(PjuDatFwdIndInfo));
+   if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd, 
+            sizeof (PjuDatFwdIndInfo)) != ROK)
+   {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      if (datFwdInd == NULLP)
+      {
+         /*ccpu00136858 */      
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+      }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+         RETVALUE(RFAILED);
+   }
+      datFwdInd->dir = PJ_DIR_DL;
+      datFwdInd->numSdus = 0;
+      datFwdInd->isLastDatFwdInd = TRUE;
+
+      /* sending DatFwdInd even if numSdu is zero */
+      pjUtlDlSndDatFwdInd(gCb,pjRbCb, datFwdInd);
+      RETVALUE(ROK);
+   }
+
+   /* Find the total count of the txEnts present */
+   numSdu = pjRbCb->dlCb.txBuf.numEntries + pjRbCb->dlCb.dlPktQ.count;
+   numSduCnt = numSdu;
+
+   /* This was added from Hotfix branch when Data Fwding was not supported */
+
+   cmLListFirst(&pjRbCb->dlCb.txBuf.datCfmQ);
+   cmLListFirst(&pjRbCb->dlCb.txBuf.sduSubmitQ);
+   cmLListFirst(&pjRbCb->dlCb.dlPktQ);
+
+
+while(numSduCnt >0)
+{
+   count = 0;
+   /* For BRDCM PJ_FWD_MAX_SDU_CNT = 16, for MSPD PJ_FWD_MAX_SDU_CNT=1 */
+
+   if(numSduCnt > PJ_FWD_MAX_SDU_CNT)
+   {
+      numSduTx  = PJ_FWD_MAX_SDU_CNT;
+      numSduCnt = numSduCnt - PJ_FWD_MAX_SDU_CNT;
+   }
+   else
+   {
+      numSduTx = numSduCnt;
+      numSduCnt = 0;
+   }
+
+   if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd, 
+            sizeof (PjuDatFwdIndInfo)) != ROK)
+   {
+      /*ccpu00136858 */      
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd->datFwdInfo, 
+            (sizeof(PjuDatFwdInfo) * numSduTx)) != ROK)
+   {
+      /* Free memory for DatFwdInfo */
+      PJ_PST_FREE(pjuSap->pst.region, pjuSap->pst.pool,datFwdInd->datFwdInfo,  
+            numSdu * sizeof(PjuDatFwdIndInfo));
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   while (numSduTx>0)
+   {
+
+      if(NULLP != cmLListCrnt(&pjRbCb->dlCb.txBuf.datCfmQ))
+      {
+         txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.datCfmQ));
+         datFwdInd->datFwdInfo[count].sduId = txEnt->sduId;
+         datFwdInd->datFwdInfo[count].sn    = txEnt->sn;
+#ifdef SS_RBUF
+         datFwdInd->datFwdInfo[count].sdu = txEnt->sdu;
+#else
+#ifdef FLAT_BUFFER_OPT
+         if(txEnt->sdu == NULLP)
+         {
+            pjUtlCopyFbToBuf(gCb, &(txEnt->fb), &(datFwdInd->datFwdInfo[count].sdu));
+         }
+         else
+#endif
+         {
+            SCpyMsgMsg(txEnt->sdu, 0, 0, &datFwdInd->datFwdInfo[count].sdu);
+         }
+#endif
+         cmLListNext(&pjRbCb->dlCb.txBuf.datCfmQ);
+         numSduTx--;
+         count++;
+         continue;
+      }
+
+
+      if(NULLP != cmLListCrnt(&pjRbCb->dlCb.txBuf.sduSubmitQ))
+      {
+         txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.sduSubmitQ));
+         datFwdInd->datFwdInfo[count].sduId = txEnt->sduId;
+         datFwdInd->datFwdInfo[count].sn    = txEnt->sn;
+#ifdef SS_RBUF
+         datFwdInd->datFwdInfo[count].sdu = txEnt->sdu;
+#else
+#ifdef FLAT_BUFFER_OPT
+         if(txEnt->sdu == NULLP)
+         {
+            pjUtlCopyFbToBuf(gCb, &(txEnt->fb), &(datFwdInd->datFwdInfo[count].sdu));
+         }
+         else
+#endif
+         {
+            SCpyMsgMsg(txEnt->sdu, 0, 0, &datFwdInd->datFwdInfo[count].sdu);
+         }
+#endif
+         cmLListNext(&pjRbCb->dlCb.txBuf.sduSubmitQ);
+         numSduTx--;
+         count++;
+         continue;
+      }
+
+
+      if(NULLP != cmLListCrnt(&pjRbCb->dlCb.dlPktQ))
+      {
+         pkt = (PjDlPkt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.dlPktQ));
+         datFwdInd->datFwdInfo[count].sduId = pkt->sduId;
+         datFwdInd->datFwdInfo[count].sn    = pkt->sn;
+#ifdef SS_RBUF
+         datFwdInd->datFwdInfo[count].sdu = pkt->pdu;
+#else
+#ifdef FLAT_BUFFER_OPT
+         if(pkt->pdu == NULLP)
+         {
+            pjUtlCopyFbToBuf(gCb, &(pkt->fb), &(datFwdInd->datFwdInfo[count].sdu));
+         }
+         else
+#endif
+         {
+            SCpyMsgMsg(pkt->pdu, 0, 0, &datFwdInd->datFwdInfo[count].sdu);
+         }
+#endif
+
+         cmLListNext(&pjRbCb->dlCb.dlPktQ);
+         numSduTx--;
+         count++;
+      }
+
+   }
+   datFwdInd->dir = PJ_DIR_DL;
+   datFwdInd->numSdus = count;
+   datFwdInd->isLastDatFwdInd = FALSE;
+   pjUtlDlSndDatFwdInd(gCb,pjRbCb, datFwdInd);
+}
+
+   pjuSap   = &(gCb->u.dlCb->pjuSap[PJ_DRB_SAP]);
+   if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd, 
+          sizeof (PjuDatFwdIndInfo)) != ROK)
+   {
+      /*ccpu00136858 */      
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+   datFwdInd->dir = PJ_DIR_DL;
+   datFwdInd->numSdus = 0;
+   datFwdInd->isLastDatFwdInd = TRUE;
+
+   /* sending DatFwdInd even if numSdu is zero */
+   pjUtlDlSndDatFwdInd(gCb,pjRbCb, datFwdInd);
+   RETVALUE(ROK);
+
+}
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to process the forwarded data received from upper layer.
+ *
+ * @b Description: 
+ *
+ *        1. This function is used to process the SDUs received from the upper
+ *        layer as part of handover.   @n
+ *        2. This function calls pjDlmProcessSdus function with the correct 
+ *        SN and HFN values.     @n
+ *            
+ *  @param[in] gCb         PDCP Instance control block. 
+ *  @param[in] pjRbCb      Rb control block. 
+ *  @param[in] datFwdReq   Data Forward Info.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjDlmHndlDatFwdReq
+(
+PjCb               *gCb,
+PjDlRbCb           *pjRbCb,
+PjuDatFwdReqInfo   *datFwdReq
+)
+#else
+PUBLIC S16 pjDlmHndlDatFwdReq(gCb,pjRbCb,datFwdReq)
+PjCb               *gCb;
+PjDlRbCb           *pjRbCb;
+PjuDatFwdReqInfo   *datFwdReq;
+#endif
+{
+
+   U32      sduCount;            /* Number of received SDUs */
+   U32      numSdus;             /* Counter for SDUs */
+   //U32      txHfn;               /* TX_HFN of a SDU */
+   PjTxEnt  *txEnt;              /* Transmission Entity */ 
+#ifdef L2_PDCP_OPTMZ   
+   U8       hashKey;          /* Computed HashKey */
+   PjBuf       *buf; 
+#endif   
+
+   TRC3(pjDlmHdlDatFwdReq)
+
+   RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmHndlDatFwdReq(pjRbCb (),datFwdReq(%d)) ", 
+                             datFwdReq->numSdus);
+
+   sduCount = datFwdReq->numSdus;
+   //txHfn    = pjRbCb->dlCb.txHfn;
+   numSdus  = 0;
+   
+   /* FIXME is this required , TC 11.10 */
+   /* FIXME NOT a proper fix also */
+   if(pjRbCb->dlCb.txNext == 0)
+   {
+      //pjRbCb->dlCb.nxtTxSn =  datFwdReq->datFwdInfo[sduCount - 1].sn;
+      pjRbCb->dlCb.count   =  datFwdReq->datFwdInfo[sduCount - 1].sn;
+   }
+   gCb->pjGenSts.numPktsRcvd += sduCount;
+   /* Process each of the SDUs with received SN and sduId */ 
+   for ( numSdus = 0; numSdus < sduCount; numSdus++ )
+   {
+      /* 
+         The variables nxtTxSn and COUNT are assumed to be 
+         already updated in dlCb to continue with the 
+         transmission ( in the target eNodeB ).
+      */
+      PJ_ALLOC(gCb,txEnt, sizeof(PjTxEnt)); 
+
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      if (txEnt == NULLP)
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         PJ_FREE_BUF(datFwdReq->datFwdInfo[numSdus].sdu);
+         RETVALUE(RFAILED);
+      }
+#endif /* ERRCLASS & ERRCLS_RES */
+
+
+      /* Fill TxEnt values */
+      txEnt->sn = datFwdReq->datFwdInfo[numSdus].sn;
+      txEnt->sduId = datFwdReq->datFwdInfo[numSdus].sduId;
+      txEnt->state = PJ_SDU_RECEIVED;
+      txEnt->sdu   = datFwdReq->datFwdInfo[numSdus].sdu;
+      txEnt->pdu   = NULLP;
+
+#ifndef L2_PDCP_OPTMZ
+      pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt);
+#else
+      /* Fix for NULL ciphering. For null ciphering add PDUs to sduSubmitQ*/
+      if(pjRbCb->ueCb->secInfo.secAct && pjRbCb->ueCb->secInfo.cipherInfo.algoType != 0)
+      {
+         txEnt->datCfmEnt.node = NULLP;
+         txEnt->reEstPktEnt.node = NULLP;
+         txEnt->sduSubmitEnt.node = (PTR)NULLP;
+
+         buf=&(pjRbCb->dlCb.txBuf);
+         hashKey = (U8)PJ_HASH_FN(buf, txEnt->count); /*KW_FIX*/
+
+         txEnt->lstEnt.node = (PTR)txEnt;
+         cmLListAdd2Tail(&buf->datQ[hashKey], &txEnt->lstEnt);
+         buf->numEntries ++;
+
+         /* Dont add PDUs to datCfmQ in case of UM mode*/
+         if (pjRbCb->mode == PJ_DRB_AM ) 
+         {
+            txEnt->datCfmEnt.node = (PTR)txEnt;
+            cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.datCfmQ, &txEnt->datCfmEnt);
+         }
+
+         txEnt->state  = PJ_PDU_SUBMITTED;
+      }
+      else
+      {
+         pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt);
+      }
+#endif   
+      pjDlmProcDrb(gCb,pjRbCb,txEnt);
+
+   }
+
+   RETVALUE(ROK);
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to construct a PDU and send it to the lower layer.
+ *
+ * @b Description: 
+ *
+ *        1. This function is used to deliver a PDU to the lower layer.@n
+ *        2. It calls pjDlmBldPdu function and sends the PDU to 
+ *        the lower layer using pjDlmSendDatReq function. @n
+ *        3. The txBuf is freed up if the cfmReqd is not configured or 
+ *        if the rbType is UM.@n
+ *            
+ *  @param[in] pjRbCb   PDCP control block.
+ *  @param[in] txEnt    Transmission Entity.
+ *  @param[in] mBuf     The PDU to be transmitted.
+ *  @param[in] pduType  Type of the PDU.
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjDlmDeliverPdu
+(
+PjCb       *gCb,
+PjDlRbCb     *pjRbCb,
+PjTxEnt    *txEnt
+)
+#else
+PUBLIC S16 pjDlmDeliverPdu(gCb,pjRbCb,txEnt)
+PjCb       *gCb;
+PjDlRbCb     *pjRbCb;
+PjTxEnt    *txEnt;
+#endif
+{
+   S16            ret;            /* Return Value */
+   S16            ret1;            /* Return Value */
+   PjTxEnt    *txFirstEntity;
+
+
+   TRC3(pjDlmDeliverPdu)
+
+
+   ret    = ROK;
+
+
+   /* Constructs a PDU */
+   if ( txEnt->state != PJ_PDU_CONSTRUCTED )
+   {
+      ret = pjDlmBldPdu(gCb, pjRbCb, txEnt);
+   }
+
+   if ( ret != ROK )
+   {
+      RLOG_ARG2(L_ERROR, DBG_RBID, pjRbCb->rbId, "PDCP DL Build PDU Failed SN [%u] , Count [%lu]",  
+         txEnt->sn, txEnt->count);
+      PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count);
+      if ( pjRbCb->dlCb.cfmReqd)
+      {
+         PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_PDU_CONSTRUCT_FAILED);
+      }
+      RETVALUE(RFAILED);
+   }
+   txEnt->state = PJ_PDU_CONSTRUCTED;
+
+   /* Deliver the PDU to the lower layer only if it is nxtToSub.
+    * Also deliver the consecutive PDUs if they are constructed.
+    * If not just store the PDU.
+    */
+   cmLListFirst(&pjRbCb->dlCb.txBuf.sduSubmitQ);
+
+   while (cmLListCrnt(&pjRbCb->dlCb.txBuf.sduSubmitQ))
+   {
+      txFirstEntity = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.sduSubmitQ));
+      if (txFirstEntity->state == PJ_PDU_CONSTRUCTED )
+      {
+     ret1 =
+         pjDlmSendDatReq(gCb, pjRbCb, txFirstEntity->count, 
+               txFirstEntity->pdu);
+         gCb->pjGenSts.txPdus++;
+         txFirstEntity->pdu   = NULLP;
+         txFirstEntity->state = PJ_PDU_SUBMITTED;
+
+         txFirstEntity->sduSubmitEnt.node = (PTR)NULLP;
+         cmLListDelFrm(&pjRbCb->dlCb.txBuf.sduSubmitQ, &txFirstEntity->sduSubmitEnt);
+
+         if ((pjRbCb->mode == PJ_DRB_UM ) 
+               || (!(pjRbCb->dlCb.cfmReqd) && pjRbCb->rbType == PJ_SRB)
+              || (ret1 != ROK))
+         {
+              pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txFirstEntity->count);
+         }
+         else
+         {
+            /* Add to the DatCfm Q */
+            txFirstEntity->datCfmEnt.node = (PTR)txEnt;
+            cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.datCfmQ, &txFirstEntity->datCfmEnt);
+            pjTotDlPckCntPerCell++;
+         }
+         cmLListFirst(&pjRbCb->dlCb.txBuf.sduSubmitQ);
+      }
+      else
+      {
+         break;
+      }
+   }
+   
+   RETVALUE(ret);
+}
+/**
+*
+ * @brief  
+ * 
+ *        Handler to construct a process a SRB SDU.
+ * 
+ * @b Description: 
+ * 
+ *        1. This function performs integrity protection if it is
+ *        configured.    @n
+ *        2. The first DL message of SRBs is not ciphered and is just integrity 
+ *        protected.  @n 
+ *        3. This function checks the UE CB control block to check the flag for the 
+ *        first DL message and performs only integrity protection and unsets 
+ *        the flag.       @n 
+ *        4. Ciphering is performed if applicable.
+ *        5. The PDU is constructed and then delivered to the lower
+ *        layer. @n
+ *            
+ *  @param[in] pjRbCb   PDCP control block. 
+ *  @param[in] txEnt    Transmission Entity.
+ *                 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+
+#ifdef ANSI
+PUBLIC S16 pjDlmProcSrb
+(
+PjCb    *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+)
+#else
+PUBLIC S16 pjDlmProcSrb(gCb, pjRbCb, txEnt)
+PjCb    *gCb;
+PjDlRbCb  *pjRbCb;
+PjTxEnt *txEnt;
+#endif
+{
+   S16             ret;           /* Return Value */
+   U32             macI;          /* MAC-I value to be padded to the PDU */
+   Buffer          *pdu;          /* Pointer for the PDU in txEnt */
+
+   TRC3(pjDlmProcSrb)
+#ifndef ALIGN_64BIT
+   RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmProcSrb(pjRbCb (), txEnt(%ld)) ", 
+                              txEnt->count);
+#else
+   RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmProcSrb(pjRbCb (), txEnt(%d)) ",
+                              txEnt->count);
+#endif
+
+
+   pdu    = txEnt->sdu;
+   macI   = 0;
+   ret    = ROK;
+
+   /* Perform security operation only if configured */
+   if ( pjRbCb->ueCb->secInfo.secAct && pjRbCb->ueCb->secInfo.intInfo.algoType != 0)
+   {
+      /* Perform integrity/ciphering */
+      ret = pjDlmHdlIntProt(gCb, pjRbCb, txEnt);
+      if ( ret != ROK )
+      {
+         RLOG_ARG2(L_ERROR, DBG_RBID, pjRbCb->rbId, "Integrity Prot failed SN [%u] TXNEXT [%lu]", txEnt->sn, txEnt->count);
+      }
+   }
+   else
+   {
+      /* If security is not configured, pad the PDU with 4 bytes 
+       * and deliver to the lower layer
+       */
+      PJ_PACK_MACI(pdu, macI);
+      ret = pjDlmHdlCiph(gCb, pjRbCb, txEnt);
+/*      ret = pjDlmDeliverPdu(gCb, pjRbCb, txEnt);*/
+   }
+
+   RETVALUE(ret);
+}
+
+/**
+ *
+ * @brief 
+ * 
+
+ *        Handler to construct a process a DRB SDU.
+ * 
+ * @b Description: 
+ * 
+ *        1. This function performs header compression if it is
+ *        configured.    @n
+ *        2. If security is configured, ciphering is performed. @n
+ *        3. The PDU is constructed and then delivered to the lower
+ *        layer. @n
+ *            
+ *  @param[in] pjRbCb   PDCP control block. 
+ *  @param[in] txEnt    Transmission Entity.
+ *                 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjDlmProcDrb
+(
+PjCb     *gCb,
+PjDlRbCb   *pjRbCb,
+PjTxEnt  *txEnt
+)
+#else
+PUBLIC S16 pjDlmProcDrb(gCb,pjRbCb,txEnt)
+PjCb     *gCb;
+PjDlRbCb   *pjRbCb;
+PjTxEnt  *txEnt;
+#endif
+{
+   TRC3(pjDlmProcDrb)
+#ifndef ALIGN_64BIT
+   RLOG_ARG1(L_UNUSED,DBG_RBID,pjRbCb->rbId, 
+         "pjDlmProcDrb(pjRbCb (), txEnt(%ld)) ", txEnt->count);
+#else
+   RLOG_ARG1(L_UNUSED,DBG_RBID,pjRbCb->rbId, 
+         "pjDlmProcDrb(pjRbCb (), txEnt(%d)) ", txEnt->count);
+#endif
+
+   RETVALUE(pjDlmHdlCmp(gCb, pjRbCb, txEnt));
+}
+
+/**
+ *
+ * @brief 
+ * 
+ *        Handler to process the Integrity Protection Request
+ * 
+ * @b Description: 
+ * 
+ *        1. This function performs integrity protection
+ *        of a SDU by prepending the header.    @n
+ *        2. If ciphering is applicable, it is performed after removing
+ *        the header. @n
+ *        3. The PDU is constructed and then delivered to the lower
+ *        layer. @n
+ *            
+ *  @param[in] pjRbCb   PDCP control block. 
+ *  @param[in] txEnt    Transmission Entity.
+ *                 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjDlmHdlIntProt
+(
+PjCb    *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+)
+#else
+PUBLIC S16 pjDlmHdlIntProt(gCb,pjRbCb,txEnt)
+PjCb    *gCb;
+PjDlRbCb  *pjRbCb;
+PjTxEnt *txEnt;
+#endif
+{
+   S16             ret;           /* Return Value */
+   U32              hdr;           /* Header Value */
+#ifndef TENB_AS_SECURITY
+   U32             macI = 0;      /* MAC-I value to be padded to the PDU */
+#endif
+   Buffer          *pdu = NULLP;          /* Pointer for the PDU in txEnt */
+   PjSecInp        secInp;        /* Security Input for Ciphering and Int Prot */
+
+   TRC3(pjDlmHdlIntProt)
+#ifndef ALIGN_64BIT
+   RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, 
+         "pjDlmHdlIntProt(pjRbCb (), txEnt (%ld)) ",   txEnt->count);
+#else
+   RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, 
+         "pjDlmHdlIntProt(pjRbCb (), txEnt (%d)) ",  txEnt->count);
+#endif
+
+   pdu    = txEnt->sdu;
+
+   ret    = ROK;
+   hdr    = 0;
+
+   /* If firstDL msg after secCfg, unset the ueCb flag ans set
+    * rbCb flag and set the SN
+    */
+   if (pjRbCb->ueCb->secInfo.selSecAct == TRUE &&
+            pjRbCb->ueCb->secInfo.firstMsg == TRUE )
+   {
+      pjRbCb->firstDlMsg = TRUE;
+      pjRbCb->firstSn    = txEnt->sn;
+      pjRbCb->ueCb->secInfo.firstMsg = FALSE;
+   }
+   secInp.dir  = PJ_SEC_DIR_DL;
+   secInp.rbId = pjRbCb->rbId;
+   secInp.count= txEnt->count;
+
+   /* Add the header and then send it for Integrity Protection */
+   hdr = txEnt->sn;
+   PJ_ADD_PRE_MSG(pdu, hdr, 2, ret);
+#ifndef TENB_T2K3K_SPECIFIC_CHANGES
+   txEnt->sdu = pdu;
+#endif
+
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if ( ret != ROK )
+   {
+      RLOG1(L_ERROR, "SAddPreMsg failed  Tx Count[%lu]", txEnt->count);
+      PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count);
+      if ( pjRbCb->dlCb.cfmReqd)
+      {
+         PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_REM_MSG_FAILED);
+      }
+      RETVALUE(RFAILED);
+   }
+#endif
+
+   txEnt->state = PJ_WAIT_FOR_INTPROT;
+   ret = pjUtlIntProtReq(gCb, pjRbCb, secInp, &pdu);
+
+
+   if ( ret != ROK )
+   {
+      RLOG1(L_ERROR, "Integrity Protection Req failed Tx Count[%lu]", txEnt->count);
+      PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count);
+      if ( pjRbCb->dlCb.cfmReqd)
+      {
+         PJ_SND_CFM(gCb,pjRbCb, txEnt, PJU_INTPROT_FAILED);
+      }
+      gCb->pjGenSts.numIntgPrtFails++; 
+      RETVALUE(RFAILED);
+   }
+#ifdef INTEL_QAT_DP
+   if (pjRbCb->ueCb->secInfo.intInfo.algoType == 0)
+#endif
+   {
+#ifndef PJ_SEC_ASYNC
+   /* Append the macI at the end */
+#ifdef TENB_AS_SECURITY
+   /*PJ_PACK_MACI(pdu, macI);*/
+#else
+   PJ_PACK_MACI(pdu, macI);
+#endif
+   txEnt->pdu = pdu;
+#ifndef TENB_ACC
+#ifndef TENB_T2K3K_SPECIFIC_CHANGES 
+#ifdef SS_RBUF
+//   prc_trace_format_string(0x40,3,"[%ld] ",macI);
+#endif
+#endif
+#endif
+
+   /* Remove the header and then only send for ciphering */
+   ret = SRemPreMsg((Data *)&hdr, txEnt->pdu);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if ( ret != ROK )
+   {
+      RLOG1(L_ERROR, "SRemPreMsg failed  Tx Count [%lu]", txEnt->count);
+      PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count);
+      if ( pjRbCb->dlCb.cfmReqd)
+      {
+         PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_REM_MSG_FAILED);
+      }
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_RES */
+    ret = SRemPreMsg((Data *)&hdr, txEnt->pdu);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if ( ret != ROK )
+   {
+      RLOG1(L_ERROR, "SRemPreMsg failed  Tx Count [%lu]", txEnt->count);
+      PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count);
+      if ( pjRbCb->dlCb.cfmReqd)
+      {
+         PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_REM_MSG_FAILED);
+      }
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_RES */
+
+   /* If rbCb flag is set => firstDL msg. So skip ciphering */
+   if ( pjRbCb->firstDlMsg == TRUE  && pjRbCb->firstSn == txEnt->sn)
+   {
+      pjRbCb->firstDlMsg = FALSE;
+#ifndef SS_RBUF
+      PJ_FREE_BUF(txEnt->sdu);
+#endif 
+      txEnt->sdu = NULLP;
+      ret = pjDlmDeliverPdu(gCb, pjRbCb, txEnt);
+   }
+   else
+   {
+      ret = pjDlmHdlCiph(gCb, pjRbCb, txEnt);
+   }
+#endif
+   }
+   RETVALUE(ret);
+}
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to process NULL Ciphering. 
+ *
+ * @b Description: 
+ *        This function handles the PDU for NULL ciphering.
+ *            
+ *  @param[in] gCb      Global control block.
+ *  @param[in] pjRbCb   RB control block.
+ *  @param[in] txEnt    Transmission Entity.
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjDlmHdlNullCiph
+(
+PjCb       *gCb,
+PjDlRbCb     *pjRbCb,
+PjTxEnt    *txEnt
+)
+#else
+PUBLIC S16 pjDlmHdlNullCiph(gCb,pjRbCb,txEnt)
+PjCb       *gCb;
+PjDlRbCb     *pjRbCb;
+PjTxEnt    *txEnt;
+#endif
+{
+   S16            ret;            /* Return Value */
+
+   TRC3(pjDlmHdlNullCiph);
+
+   ret=ROK;
+
+   /* If Ciphering is enabled, txEnt->pdu will point to a mBuf */
+#ifdef FLAT_BUFFER_OPT
+   if(txEnt->sdu == NULLP)
+   {
+      ret = pjUtlCopyFbToBuf(gCb, &(txEnt->fb), &(txEnt->pdu));
+      if (ret != ROK)
+      {
+         RLOG1(L_ERROR, "Cpoying to Flat Buf Failed Tx Count [%lu]", txEnt->count);
+         PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count);
+         if ( pjRbCb->dlCb.cfmReqd)
+         {
+            PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_CPY_MSG_FAILED);
+         }
+         RETVALUE(RFAILED);
+      }
+   }
+#endif
+
+   if (txEnt->pdu == NULLP )
+   {
+      if ( pjRbCb->mode == PJ_DRB_AM
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+            || pjRbCb->mode == PJ_DRB_UM
+#endif
+         )
+      {
+         PJ_CPY_MSG(gCb,txEnt->sdu, &(txEnt->pdu), ret);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         if (ret != ROK)
+         {
+            RLOG1(L_ERROR, "SAddMsgRef Failed Tx Count [%lu]", txEnt->count);
+
+            PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count);
+            if ( pjRbCb->dlCb.cfmReqd)
+            {
+               PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_CPY_MSG_FAILED);
+            }
+            RETVALUE(RFAILED);
+         }
+#endif
+      }
+      else
+      {
+         txEnt->pdu = txEnt->sdu;
+         txEnt->sdu = NULLP;
+      }
+   }
+
+   RETVALUE(ret);
+}
+
+/**
+ *
+ * @brief  
+ * 
+ *        Handler to process the Compression Request.
+ * 
+ * @b Description: 
+ * 
+ *        1. This function performs header compression if configured. @n
+ *        2. If ciphering is applicable, it is performed. @n
+ *        3. The PDU is constructed and then delivered to the lower
+ *        layer. @n
+ *            
+ *  @param[in] pjRbCb   PDCP control block. 
+ *  @param[in] txEnt    Transmission Entity.
+ *                 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+
+#ifdef ANSI
+PUBLIC S16 pjDlmHdlCmp
+(
+PjCb    *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+)
+#else
+PUBLIC S16 pjDlmHdlCmp(gCb,pjRbCb,txEnt)
+PjCb    *gCb;
+PjDlRbCb  *pjRbCb;
+PjTxEnt *txEnt;
+#endif
+{
+   S16            ret;         /* Return Value */
+   Buffer         *opSdu;      /* Pointer for Output of Compression */
+   U32             macI;          /* MAC-I value to be padded to the PDU */
+   TRC3(pjDlmHdlCmp)
+#ifndef ALIGN_64BIT
+   RLOG_ARG1(L_UNUSED,DBG_RBID,pjRbCb->rbId, "pjDlmHdlCmp(pjRbCb (), txEnt (%ld)) ", 
+            txEnt->count);
+#else
+   RLOG_ARG1(L_UNUSED,DBG_RBID,pjRbCb->rbId, "pjDlmHdlCmp(pjRbCb (), txEnt (%d)) ",
+            txEnt->count);
+#endif
+
+   ret     = ROK;
+   opSdu   = NULLP;
+
+   /* Perform compression if ocnfigured */
+   if ( pjRbCb->rohc.hdrCmpUsed )
+   {
+      txEnt->pdu = txEnt->sdu;
+      txEnt->state = PJ_WAIT_FOR_CMP;
+      ret =   pjUtlCmpReq(gCb, pjRbCb, txEnt->pdu, &opSdu, txEnt->count);
+      if ( ret != ROK )
+      {
+
+         RLOG1(L_ERROR, "Compression Req Failed Tx Count [%lu]", txEnt->count);
+         PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count);
+         if ( pjRbCb->dlCb.cfmReqd)
+         {
+            PJ_SND_CFM(gCb,pjRbCb, txEnt, PJU_COMP_FAILED);
+         }
+         gCb->pjGenSts.numCmpFails++;
+         RETVALUE(RFAILED);
+      }
+#ifdef PJ_CMP_ASYNC
+      RETVALUE(ret);
+#else
+      txEnt->pdu = opSdu;
+#endif
+   }
+   if(pjRbCb->ueCb->secInfo.intProtEnbForDrb)
+   {
+      macI   = 0;
+      PJ_PACK_MACI(txEnt->sdu, macI);
+   }
+   /* Perform ciphering if security is configured */
+   ret = pjDlmHdlCiph(gCb, pjRbCb, txEnt);
+   RETVALUE(ret);
+}
+
+#ifdef LTE_PAL_ENB
+/**
+ *  @brief This fn cheks whether the RING buffer is used and therefore DL pkts
+ *         need to be enqueued before forwarding it for ciphering.
+ *         Note: It acts as a dummy fn so far in case of Mindspeed pltfm
+ *
+ *  @details
+ *      Function : pjUtlChekTxEnqReq
+ *
+ *          Processing Steps:
+ *
+ *
+ * @return  S16
+ *        -# Success : ROK
+ *        -# Failure : RFAILED
+*/
+#ifdef ANSI
+PUBLIC S16 pjUtlChekTxEnqReq
+(
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb,
+PjTxEnt    *txEnt
+)
+#else
+PUBLIC S16 pjUtlChekTxEnqReq(gCb,pjRbCb, txEnt)
+PjCb       *gCb;
+PjDlRbCb   *pjRbCb;
+PjTxEnt    *txEnt;
+#endif
+{
+  RETVALUE(ROK);
+}
+#endif
+/**
+ * 
+ * @brief  
+ * 
+ *        Handler to process the Ciphering Request.
+ * 
+ * @b Description: 
+ * 
+ *        1. This function performs ciphering.  @n
+ *        2. If asynchronous flag is defined, the function returns . @n
+ *        3. Else the function updates the PDU field in txEnt and returns. @n 
+ *            
+ *  @param[in] pjRbCb   PDCP control block. 
+ *  @param[in] txEnt    Transmission Entity.
+ *                 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjDlmHdlCiph
+(
+PjCb    *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+)
+#else
+PUBLIC S16 pjDlmHdlCiph(gCb,pjRbCb,txEnt)
+PjCb    *gCb;
+PjDlRbCb  *pjRbCb;
+PjTxEnt *txEnt;
+#endif
+{
+   S16            ret;         /* Return Value */
+   Buffer         *ciphSdu;    /* Pointer for Output of Ciphering */
+   PjSec *secInfo;
+
+   TRC3(pjDlmHdlCiph)
+#ifndef SS_RBUF
+#ifndef TENB_ACC
+   pjUtlChekTxEnqReq(gCb, pjRbCb, txEnt);
+#endif   
+#if CIPH_BATCH_PROC
+   RETVALUE(ROK);
+#endif
+#endif
+#ifndef ALIGN_64BIT
+   RLOG_ARG1(L_UNUSED,DBG_RBID,pjRbCb->rbId, "pjDlmHdlCiph(pjRbCb (), txEnt (%ld)) ", 
+            txEnt->count);
+#else
+   RLOG_ARG1(L_UNUSED,DBG_RBID,pjRbCb->rbId, "pjDlmHdlCiph(pjRbCb (), txEnt (%d)) ",
+            txEnt->count);
+#endif
+   ret     = ROK;
+   ciphSdu = NULLP;
+#ifndef L2_PDCP_OPTMZ
+txEnt->state  = PJ_WAIT_FOR_CIPHER;
+#endif
+
+
+   secInfo = &(pjRbCb->ueCb->secInfo);
+
+   if ( secInfo->secAct && secInfo->cipherInfo.algoType != 0)   /* If its not NULL Ciphering and Security is enabled */
+   {
+      if ( txEnt->pdu == NULLP )
+      {
+         txEnt->pdu = txEnt->sdu;
+      }
+      /* Note: FB is only for DRB data in DL direction. SRB data after  */
+      /* integrity protection will use the NON-FB version of code.      */
+      /* The below "if" check is to identify whether it is for SRB data */
+      /* or DRB data.                                                   */
+#ifdef CIPH_BATCH_PROC
+#ifndef TENB_ACC
+   pjUtlChekTxEnqReq(gCb, pjRbCb, txEnt);
+#endif  
+   RETVALUE(ROK);
+#endif
+
+#ifdef FLAT_BUFFER_OPT
+      if (txEnt->sdu == NULLP)
+      {
+          ret = pjUtlCipherReqFB(gCb, pjRbCb, txEnt->count, &(txEnt->fb), &ciphSdu);         
+      }
+      else
+#endif
+      {
+         ret = pjUtlCipherReq(gCb, pjRbCb, txEnt->count, txEnt->pdu, &ciphSdu);
+      }
+
+      /*There can be failures in creating the input for SPACC*/
+      if ( ret != ROK )
+      {
+         RLOG1(L_ERROR, "Ciphering Req failed Tx Count [%lu]", txEnt->count);
+         PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count);
+         if ( pjRbCb->dlCb.cfmReqd)
+         {
+            PJ_SND_CFM(gCb,pjRbCb, txEnt, PJU_CIPHER_FAILED);
+         }
+         gCb->pjGenSts.numCiphFails++;
+         RETVALUE(RFAILED);
+      }
+#ifdef INTEL_SW_SEC
+       if(ciphSdu)
+       {
+           //printf("Ciphered PDU\n");
+           //SPrntMsg(ciphSdu,0,0);
+           if(txEnt->pdu)
+           {
+              PJ_FREE_BUF(txEnt->pdu);
+           }
+           txEnt->pdu = ciphSdu;
+       }
+       else
+       {
+           PJLOGERROR(gCb, ERRCLS_ADD_RES, EPJXXX, (ErrVal)sduId,
+                   "pjSendToSwCipherFB:Ciphering failed for txEnt\n");
+           pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count);
+           RETVALUE(RFAILED);
+       }
+#endif
+
+#ifdef TENB_AS_SECURITY
+      if(isSecBatchMode)
+      {
+         txEnt->state = PJ_PDU_SUBMITTED;
+#ifdef L2_PDCP_OPTMZ      
+  /* Delete Tx entity in case of UM mode*/
+   if (pjRbCb->mode == PJ_DRB_UM ) 
+   {
+      pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count);
+   }
+#endif    
+         RETVALUE(ret);
+      }
+      else
+#endif
+      {
+         txEnt->pdu = ciphSdu;
+      }
+
+   }
+   else
+   {
+#ifdef L2_PDCP_OPTMZ      
+   txEnt->state  = PJ_WAIT_FOR_CIPHER;
+#endif
+
+#ifdef SS_RBUF
+      txEnt->pdu = NULLP;
+#endif
+      ret = pjDlmHdlNullCiph(gCb, pjRbCb, txEnt);
+   }
+
+   txEnt->state = PJ_PDU_SUBMITTED;
+   ret = pjDlmDeliverPdu(gCb, pjRbCb, txEnt);
+  
+  
+   RETVALUE(ROK);
+}
+
+#ifdef FLAT_BUFFER_OPT
+/**
+ * 
+ * @brief  
+ * 
+ *        Handler to process the Ciphering Request.
+ * 
+ * @b Description: 
+ * 
+ *        1. This function performs ciphering.  @n
+ *        2. If asynchronous flag is defined, the function returns . @n
+ *        3. Else the function updates the PDU field in txEnt and returns. @n 
+ *            
+ *  @param[in] pjRbCb   PDCP control block. 
+ *  @param[in] txEnt    Transmission Entity.
+ *                 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjDlmHdlCiphFB
+(
+PjCb    *gCb,
+PjDlRbCb  *pjRbCb,
+PjTxEnt *txEnt
+)
+#else
+PUBLIC S16 pjDlmHdlCiphFB(gCb,pjRbCb,txEnt)
+PjCb    *gCb;
+PjDlRbCb  *pjRbCb;
+PjTxEnt *txEnt;
+#endif
+{
+   S16            ret;         /* Return Value */
+   Buffer         *ciphSdu;    /* Pointer for Output of Ciphering */
+
+   TRC3(pjDlmHdlCiphFB)
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_DLM | PJ_DBGMASK_BRIEF | PJ_DBGMASK_DL),
+           (gCb->init.prntBuf, "pjDlmHdlCiphFB(pjRbCb (%d), txEnt (%ld)) \n", 
+           pjRbCb->rbId, txEnt->count));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_DLM | PJ_DBGMASK_BRIEF | PJ_DBGMASK_DL),
+           (gCb->init.prntBuf, "pjDlmHdlCiphFB(pjRbCb (%d), txEnt (%d)) \n",
+           pjRbCb->rbId, txEnt->count));
+#endif
+   ret     = ROK;
+   ciphSdu = NULLP;
+
+   txEnt->state  = PJ_WAIT_FOR_CIPHER;
+   ret = pjUtlCipherReqFB(gCb, pjRbCb, txEnt->count, &(txEnt->fb), &ciphSdu);
+
+   /*There can be failures in creating the input for SPACC*/
+   if ( ret != ROK )
+   {
+      RLOG1(L_ERROR, "Ciphering Req failed Tx Count [%lu]", txEnt->count);
+      PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count);
+      if ( pjRbCb->dlCb.cfmReqd)
+      {
+         PJ_SND_CFM(gCb,pjRbCb, txEnt, PJU_CIPHER_FAILED);
+      }
+      gCb->pjGenSts.numCiphFails++;
+      RETVALUE(RFAILED);
+   }
+
+   
+   txEnt->state = PJ_PDU_SUBMITTED;
+
+
+   RETVALUE(ROK);
+}
+#endif
+
+
+/**
+ *
+ * @brief
+ *
+ *  @param[in] pjRbCb   PDCP control block.
+    @param[in] PjRxEnt  *rxEnt
+ *
+ *  @return  Void
+ */
+
+#ifdef ANSI
+PUBLIC Void pjDlmEnqueueDlPkt
+(
+PjCb               *gCb, 
+PjDlRbCb           *pjRbCb,          /* !< PDCP Control Block */
+U8                 datType,
+PjuDatFwdReqInfo   *datFwd,          /* !< SN value of PDU */
+PjuSduId           sduId,
+Buffer             *pdu              /* !< PDU message buffer */
+)
+#else
+PUBLIC Void pjDlmEnqueueDlPkt(gCb,pjRbCb,datType,datFwd,suId,pdu)
+PjCb               *gCb; 
+PjDlRbCb           *pjRbCb;          /* !< PDCP Control Block */
+U8                 datType;
+PjuDatFwdReqInfo   *datFwd;               /* !< SN value of PDU */
+PjuSduId           sduId;
+Buffer             *pdu;             /* !< PDU message buffer */
+#endif
+{
+   PjDlPkt    *pkt;
+   U32          numSdu;
+
+   TRC2(pjDlmEnqueueDlPkt)
+
+   if (datType == PJ_DATA_FWD_PKT)
+   {
+      for (numSdu=0; numSdu < datFwd->numSdus; numSdu++)
+      {
+          PJ_ALLOC(gCb, pkt, sizeof(PjDlPkt));
+          if (pkt != NULLP)
+          {
+             pkt->type     = datType;
+             pkt->sn       = datFwd->datFwdInfo[numSdu].sn; 
+             pkt->sduId    = datFwd->datFwdInfo[numSdu].sduId;
+             pkt->pdu      = datFwd->datFwdInfo[numSdu].sdu;
+             pkt->lnk.node = (PTR)pkt;
+             cmLListAdd2Tail (&pjRbCb->dlCb.dlPktQ, &pkt->lnk);
+          }
+      }
+   }
+   else
+   {
+      PJ_ALLOC(gCb, pkt, sizeof(PjDlPkt));
+      if (pkt != NULLP)
+      {
+         pkt->type = datType;
+         pkt->pdu = pdu;
+         pkt->sduId = sduId;
+         pkt->lnk.node = (PTR)pkt;
+         cmLListAdd2Tail (&pjRbCb->dlCb.dlPktQ, &pkt->lnk);
+      }
+      else
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         PJ_FREE_BUF(pdu);
+      }
+   }
+
+   RETVOID;
+}/* end of pjDlmEnqueueHoPkt */
+
+#ifdef FLAT_BUFFER_OPT
+/**
+ *
+ * @brief
+ *
+ *  @param[in] pjRbCb   PDCP control block.
+    @param[in] PjRxEnt  *rxEnt
+ *
+ *  @return  Void
+ */
+#ifdef ANSI
+PUBLIC Void pjDlmEnqueueDlPktFB
+(
+PjCb               *gCb, 
+PjDlRbCb           *pjRbCb,          /* !< PDCP Control Block */
+U8                 datType,
+PjuDatFwdReqInfo   *datFwd,          /* !< SN value of PDU */
+PjuSduId           sduId,
+FlatBuffer         *pdu             /* !< Flat Buffer PDU */ 
+)
+#else
+PUBLIC Void pjDlmEnqueueDlPktFB(gCb,pjRbCb,datType,datFwd,suId,pdu)
+PjCb               *gCb; 
+PjDlRbCb           *pjRbCb;          /* !< PDCP Control Block */
+U8                 datType;
+PjuDatFwdReqInfo   *datFwd;               /* !< SN value of PDU */
+PjuSduId           sduId;
+FlatBuffer         *pdu;             /* !< Flat Buffer PDU */ 
+#endif
+{
+   PjDlPkt    *pkt;
+
+   TRC2(pjDlmEnqueueDlPktFB)
+
+   if (datType == PJ_DATA_FWD_PKT)
+   {
+      /* printf("pjDlmEnqueueDlPktFB: datType = PJ_DATA_FWD_PKT. TODO !!!!! "); */
+   }
+   else
+   {
+      PJ_ALLOC(gCb, pkt, sizeof(PjDlPkt));
+      if (pkt != NULLP)
+      {
+         pkt->type = datType;
+         pkt->fb.startAddr = pdu->startAddr;
+         pkt->fb.ptr = pdu->ptr;
+         pkt->fb.len = pdu->len;
+         pkt->pdu = NULLP;
+         pkt->sduId = sduId;
+         pkt->lnk.node = (PTR)pkt;
+         cmLListAdd2Tail (&pjRbCb->dlCb.dlPktQ, &pkt->lnk);
+         /*printf("pjDlmEnqueueDlPktFB: Enqueue DL Flat Buffer Packets. Sdu Id is %d ",
+ pkt->sduId);*/
+      }
+      else
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         PJ_FREE_FLAT_BUF(gCb, pdu);
+      }
+   }
+
+   RETVOID;
+}/* end of pjDlmEnqueueDlPktFB */
+#endif
+
+/**
+ *
+ * @brief It processes the packets queued up in DLPktQ
+ *
+ * @Description
+ *      This DlPktQ queues the Normal and forwarded message during
+ *      reestablishment/handover. 
+ *
+ *  @param[in] pjCb     PDCP Instance control block.
+ *  @param[in] pjRbCb   Rb Control block 
+ *
+ *  @return  Void
+ */
+#ifdef ANSI
+PUBLIC Void pjDlmProcessDlPktQ
+(
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb           /* !< PDCP Control Block */
+)
+#else
+PUBLIC Void pjDlmProcessDlPktQ(gCb, pjRbCb)
+PjCb       *gCb;
+PjDlRbCb   *pjRbCb;          /* !< PDCP Control Block */
+#endif
+{
+   PjDlPkt *pkt;
+   CmLList *node;
+   S16     ret;   /*KW_FIX*/
+
+   TRC2(pjDlmProcessDlPktQ)
+
+   /* first send the status report if any enqueued */
+
+   if (pjRbCb->dlCb.staRep != NULL)
+   {
+      pjDlmSendDatReq(gCb, pjRbCb, 0xffffffff, pjRbCb->dlCb.staRep);
+      pjRbCb->dlCb.staRep = NULL;
+   }
+
+   CM_LLIST_FIRST_NODE(&(pjRbCb->dlCb.dlPktQ), node);
+   while (node != NULLP)
+   {
+      pkt = (PjDlPkt *) node->node;
+      if (pkt->type == PJ_DATA_FWD_PKT)
+      {
+         PjuDatFwdReqInfo datFwdReq;
+         PjuDatFwdInfo     datFwd;
+         datFwdReq.numSdus = 1;
+         datFwd.sn =  pkt->sn;
+         datFwd.sdu = pkt->pdu;
+         datFwd.sduId = pkt->sduId;
+         datFwdReq.datFwdInfo = &datFwd;
+         pjDlmHndlDatFwdReq(gCb, pjRbCb, &datFwdReq);
+      }
+      else
+      {
+
+
+#ifdef FLAT_BUFFER_OPT
+#ifndef XEON_SPECIFIC_CHANGES
+         {
+             /* Check whether the spacc q has space to hold
+             this packet.. else dropping */
+             if(FALSE == (pjMsCheckSpaccQueue(FALSE)))
+             {
+                PJ_FREE_FLAT_BUF(pjCb[1],&(pkt->fb));
+                gPdcpStats.numPdcpSdusDiscarded++;
+                PJ_UPD_L2_DLDISC_STS(pjCb[1], pjRbCb);
+
+                cmLListDelFrm(&(pjRbCb->dlCb.dlPktQ), node);
+                PJ_FREE(gCb, pkt, sizeof (PjDlPkt));
+                node = NULLP;
+                CM_LLIST_FIRST_NODE(&(pjRbCb->dlCb.dlPktQ), node);
+                continue;
+             }
+         }
+#endif
+         if((pkt->fb.len !=0) && (pkt->fb.ptr != NULLP))
+         {
+            ret = pjDlmProcessSdusFB(gCb, pjRbCb, &(pkt->fb), pkt->sduId, pjRbCb->dlCb.txNext);
+         }
+         else
+#endif
+         {
+            ret = pjDlmProcessSdus(gCb, pjRbCb, pkt->pdu, pkt->sduId, pjRbCb->dlCb.txNext);
+         }
+         if ( ret != ROK )
+         {
+#if (ERRCLASS & ERRCLS_INT_PAR)
+             RLOG_ARG1(L_ERROR, DBG_RBID, pjRbCb->rbId, "Processing of SDU [%lu] failed", pkt->sduId);
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+         }
+      }
+
+      cmLListDelFrm(&(pjRbCb->dlCb.dlPktQ), node);
+      PJ_FREE(gCb, pkt, sizeof (PjDlPkt));
+      node = NULLP;
+      CM_LLIST_FIRST_NODE(&(pjRbCb->dlCb.dlPktQ), node);
+  }
+
+   RETVOID;
+}/* end of pjDlmProcessDlPktQ */
+
+
+
+
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+/**
+ *
+ * @brief Handler for  downlink off-board timer expiry.
+ *       
+ *
+ * @b Description
+ *        This function is called when the off-board timer expires.
+ *        This function discards the txEnt of dlCb.obdCount if it is 
+ *        is not submitted and sends the constructed PDUs to the lower
+ *        layer and start the timer for the next valid txEnt.
+ *
+ *  @param[in] pjRbCb    PDCP control block.
+ *
+ * 
+ *  @return  S16
+ *      -# ROK 
+ */
+#ifdef ANSI
+PUBLIC S16 pjDlmObdTmrExp
+(
+PjCb   *gCb,
+PjDlRbCb *pjRbCb
+)
+#else
+PUBLIC S16 pjDlmObdTmrExp(gCb, pjRbCb)
+PjCb    *gCb;
+PjDlRbCb  *pjRbCb;
+#endif
+{
+   U32           count;
+   U32           curCount;
+   PjTxEnt       *txEnt;
+   PjuDatCfmInfo *datCfm;
+   S16           ret;
+
+   TRC3(pjDlmObdTmrExp)
+   
+   RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmObdTmrExp(pjRbCb()) ");
+
+   count      = pjRbCb->dlCb.obdCount;
+   curCount   = pjRbCb->dlCb.count;
+   txEnt      = pjDbmGetTxEnt(gCb, &(pjRbCb->dlCb.txBuf), count);
+   datCfm     = NULLP;
+   ret        = ROK;
+
+   if ( txEnt && txEnt->state != PJ_PDU_SUBMITTED )
+   {
+#ifndef ALIGN_64BIT
+      RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, 
+            "pjDlmObdTmrExp(pjRbCb()) : discarding txEnt withcount(%ld)",
+                         txEnt->count);
+#else
+      RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, 
+            "pjDlmObdTmrExp(pjRbCb()) : discarding txEnt withcount(%d)",
+                         txEnt->count);
+#endif
+      PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count);
+      PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_OBD_TIMEOUT);
+      gCb->pjGenSts.numSdusDiscObdTmrExp++;
+      count++;
+      while ( count <= curCount )
+      {
+         txEnt = pjDbmGetTxEnt(gCb, &(pjRbCb->dlCb.txBuf), count);
+         if ( txEnt != NULLP )
+         {
+            if ( txEnt->state == PJ_PDU_CONSTRUCTED )
+            {
+               ret = pjDlmDeliverPdu(gCb, pjRbCb, txEnt);
+               count = pjRbCb->dlCb.nxtToSub;
+            }
+            break;
+         }
+         else
+         {
+            PJ_UPD_DL_VAR(gCb, pjRbCb, count);
+         }
+         count++;
+      }
+   }
+   else
+   {
+      count = pjRbCb->dlCb.nxtToSub;
+   }
+   if ( pjDbmGetTxEnt(gCb, &(pjRbCb->dlCb.txBuf), count) != NULLP )
+   {
+      pjRbCb->dlCb.obdCount = count;
+      pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR);
+   }
+
+   RETVALUE(ret);
+}
+
+#endif
+
+/*@}*/
+/********************************************************************30**
+ *          End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_env.h b/src/5gnrpdcp/pj_env.h
new file mode 100755 (executable)
index 0000000..8f8f146
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:     LTE PDCP file 
+    
+        Type:     H include file
+  
+        Desc:     This file contain the hash definations for PDCP 
+        File:     pj_env.h
+
+*********************************************************************21*/
+/** @file pj_env.h
+@brief PDCP Hash definitions
+*/
+
+#ifndef __PJENVT2KH__
+#define __PJENVT2KH__
+
+#define PJ_MAX_PDCP_INSTANCES            2 
+#define PJ_FWD_MAX_SDU_CNT            1 
+
+#define PJ_ALLOC_BUF(gCb,_buf)                                 \
+{                                                          \
+   if (SGetMsg(gCb->init.region, gCb->init.pool, (Buffer **)&_buf) != ROK) \
+   {                                                       \
+      (_buf) = NULLP;                                      \
+   }                                                       \
+}
+
+#define PJ_CPY_MSG(_cb,_x, _y, _ret)                           \
+   _ret =(SAddMsgRef((_x), PJ_GET_MEM_REGION(_cb), PJ_GET_MEM_POOL(_cb), (_y)))                                                                                         
+
+#define PJ_SND_CFM(_cb,_pjRbCb, _txEnt, _cause)                \
+{                                                          \
+   PjuDatCfmInfo *_datCfm;                                 \
+   CmLtePdcpId *_pdcpId;                                   \
+   PjPjuSapCb  *_pjuSap;                                   \
+   if (_pjRbCb->rbType == PJ_SRB)                          \
+      _pjuSap   = &(_cb->u.dlCb->pjuSap[PJ_SRB_SAP]);                  \
+   else                                                    \
+      _pjuSap   = &(_cb->u.dlCb->pjuSap[PJ_DRB_SAP]);                  \
+                                                           \
+   PJ_ALLOC(_cb, _datCfm, sizeof(PjuDatCfmInfo));              \
+   PJ_ALLOC(_cb,_pdcpId, sizeof(CmLtePdcpId));                \
+   if ( _datCfm != NULLP && _pdcpId != NULLP )             \
+   {                                                       \
+      _datCfm->cfmSta[_datCfm->numSdus].sduId = _txEnt->sduId;\
+      _datCfm->cfmSta[_datCfm->numSdus].status = _cause;   \
+      _datCfm->numSdus++;                                  \
+      _pdcpId->rbId   = _pjRbCb->rbId;                     \
+      _pdcpId->rbType = _pjRbCb->rbType;                   \
+      _pdcpId->ueId   = _pjRbCb->ueCb->key.ueId;           \
+      _pdcpId->cellId = _pjRbCb->ueCb->key.cellId;         \
+      PjUiPjuDatCfm(&(_pjuSap->pst), _pjuSap->suId, _pdcpId, _datCfm);\
+   }                                                       \
+   pjDbmDelTxEnt(_cb, &(pjRbCb->dlCb.txBuf), _txEnt->count);   \
+}
+
+#define PJ_ADD_PRE_MSG(_pdu, _hdr, _numBytes, _ret)        \
+{                                                          \
+   Data _liByte;                                           \
+   U16  _bytes;                                            \
+   _bytes = 0;                                             \
+   while (_numBytes > _bytes )                             \
+   {                                                       \
+      _liByte = (U8) (_hdr >> (8*_bytes));                 \
+      _ret = SAddPreMsg((Data )_liByte, _pdu);             \
+      if ( _ret != ROK )                                   \
+      {                                                    \
+         break;                                            \
+      }                                                    \
+      _bytes++;                                            \
+   }                                                       \
+}
+#endif /* __PJENVT2KH__ */
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_err.h b/src/5gnrpdcp/pj_err.h
new file mode 100755 (executable)
index 0000000..34f8ecd
--- /dev/null
@@ -0,0 +1,338 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:     LTE PDCP file 
+    
+        Type:     C include file
+  
+        Desc:     This file contain the hash definations for PDCP
+        File:     pj_err.h
+  
+*********************************************************************21*/
+/** @file pj_err.h
+@brief PDCP Hash definitions
+*/
+
+#ifndef __PJ_ERR_H__
+#define __PJ_ERR_H__
+
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+#define PJLOGERROR(_cb, errCls, errCode, errVal, errDesc) \
+        SLogError(_cb->init.ent, _cb->init.inst, _cb->init.procId, \
+                   __FILE__, __LINE__, errCls, errCode, errVal, errDesc)
+
+#define PJ_GET_AND_VALIDATE_CPJSAP(_cb, _cpjSap, _errCode, _fn, _ret) \
+{ \
+   _ret = RFAILED; \
+   if((_cpjSap != NULLP) && (_cpjSap->state == PJ_SAP_BND)) \
+   { \
+      _ret = ROK; \
+   } \
+   if(_ret != ROK) \
+   { \
+      PJLOGERROR(_cb, ERRCLS_INT_PAR, EPJXXX, (ErrVal) spId,\
+            "PjUiCpjBndReq: CPJ SAP State is Invalid during Bind Req");\
+      PJ_SEND_SAPID_ALARM(_cb, spId, LPJ_EVENT_CPJ_BND_REQ, LCM_CAUSE_INV_STATE);\
+      ret = RFAILED; \
+   } \
+}
+#define PJ_GET_AND_VALIDATE_PJUSAP(_cb, _pjuSap, _errCode, _fn, _ret) \
+{ \
+   _ret = RFAILED; \
+   if((_pjuSap != NULLP) && (_pjuSap->state == PJ_SAP_BND)) \
+   { \
+      _ret = ROK; \
+   } \
+   if(_ret != ROK) \
+   { \
+      PJLOGERROR(_cb, ERRCLS_INT_PAR, EPJXXX, (ErrVal) spId,\
+            "PjUiPjuBndReq: PJU SAP State is Invalid during Bind Req");\
+      PJ_SEND_SAPID_ALARM(_cb, spId, LPJ_EVENT_PJU_BND_REQ, LCM_CAUSE_INV_STATE);\
+      _ret = RFAILED; \
+   } \
+}
+
+#else
+#define PJLOGERROR(_cb, errCls, errCode, errVal, errDesc)
+
+#endif
+
+/* Error Codes */
+#define   ERRPJ        0
+#define   EPJXXX       0
+
+
+#define   EPJ001      (ERRPJ +    1)    /*     gp_amm.c: 293 */
+#define   EPJ002      (ERRPJ +    2)    /*     gp_amm.c: 405 */
+#define   EPJ003      (ERRPJ +    3)    /*     gp_amm.c: 419 */
+#define   EPJ004      (ERRPJ +    4)    /*     gp_amm.c: 880 */
+#define   EPJ005      (ERRPJ +    5)    /*     gp_amm.c:1351 */
+#define   EPJ006      (ERRPJ +    6)    /*     gp_amm.c:1367 */
+#define   EPJ007      (ERRPJ +    7)    /*     gp_amm.c:1561 */
+#define   EPJ008      (ERRPJ +    8)    /*     gp_amm.c:1649 */
+#define   EPJ009      (ERRPJ +    9)    /*     gp_amm.c:2423 */
+#define   EPJ010      (ERRPJ +   10)    /*     gp_amm.c:2445 */
+#define   EPJ011      (ERRPJ +   11)    /*     gp_amm.c:2555 */
+#define   EPJ012      (ERRPJ +   12)    /*     gp_amm.c:3047 */
+#define   EPJ013      (ERRPJ +   13)    /*     gp_amm.c:3069 */
+#define   EPJ014      (ERRPJ +   14)    /*     gp_amm.c:3077 */
+#define   EPJ015      (ERRPJ +   15)    /*     gp_amm.c:3147 */
+#define   EPJ016      (ERRPJ +   16)    /*     gp_amm.c:3179 */
+#define   EPJ017      (ERRPJ +   17)    /*     gp_amm.c:3187 */
+#define   EPJ018      (ERRPJ +   18)    /*     gp_amm.c:4489 */
+
+#define   EPJ019      (ERRPJ +   19)    /*     gp_cfg.c: 268 */
+#define   EPJ020      (ERRPJ +   20)    /*     gp_cfg.c: 311 */
+#define   EPJ021      (ERRPJ +   21)    /*     gp_cfg.c: 368 */
+#define   EPJ022      (ERRPJ +   22)    /*     gp_cfg.c: 380 */
+
+#define   EPJ023      (ERRPJ +   23)    /*     gp_dbm.c: 633 */
+#define   EPJ024      (ERRPJ +   24)    /*     gp_dbm.c: 958 */
+#define   EPJ025      (ERRPJ +   25)    /*     gp_dbm.c:1182 */
+#define   EPJ026      (ERRPJ +   26)    /*     gp_dbm.c:1190 */
+#define   EPJ027      (ERRPJ +   27)    /*     gp_dbm.c:1198 */
+#define   EPJ028      (ERRPJ +   28)    /*     gp_dbm.c:1263 */
+
+#define   EPJ029      (ERRPJ +   29)    /*   gp_ex_ms.c: 317 */
+#define   EPJ030      (ERRPJ +   30)    /*   gp_ex_ms.c: 389 */
+#define   EPJ031      (ERRPJ +   31)    /*   gp_ex_ms.c: 431 */
+#define   EPJ032      (ERRPJ +   32)    /*   gp_ex_ms.c: 481 */
+#define   EPJ033      (ERRPJ +   33)    /*   gp_ex_ms.c: 493 */
+#define   EPJ034      (ERRPJ +   34)    /*   gp_ex_ms.c: 638 */
+#define   EPJ035      (ERRPJ +   35)    /*   gp_ex_ms.c: 730 */
+#define   EPJ036      (ERRPJ +   36)    /*   gp_ex_ms.c: 772 */
+#define   EPJ037      (ERRPJ +   37)    /*   gp_ex_ms.c: 802 */
+#define   EPJ038      (ERRPJ +   38)    /*   gp_ex_ms.c: 849 */
+#define   EPJ039      (ERRPJ +   39)    /*   gp_ex_ms.c: 861 */
+
+#define   EPJ040      (ERRPJ +   40)    /*     gp_lim.c: 221 */
+#define   EPJ041      (ERRPJ +   41)    /*     gp_lim.c: 231 */
+
+#define   EPJ042      (ERRPJ +   42)    /*     gp_lmm.c: 225 */
+#define   EPJ043      (ERRPJ +   43)    /*     gp_lmm.c: 280 */
+#define   EPJ044      (ERRPJ +   44)    /*     gp_lmm.c: 418 */
+#define   EPJ045      (ERRPJ +   45)    /*     gp_lmm.c: 886 */
+#define   EPJ046      (ERRPJ +   46)    /*     gp_lmm.c: 952 */
+#define   EPJ047      (ERRPJ +   47)    /*     gp_lmm.c:1016 */
+#define   EPJ048      (ERRPJ +   48)    /*     gp_lmm.c:1340 */
+
+#define   EPJ049      (ERRPJ +   49)    /*  gp_pj_cfg.c: 505 */
+#define   EPJ050      (ERRPJ +   50)    /*  gp_pj_cfg.c:1276 */
+
+#define   EPJ051      (ERRPJ +   51)    /* gp_pj_cfg.c.tmp: 505 */
+#define   EPJ052      (ERRPJ +   52)    /* gp_pj_cfg.c.tmp:1276 */
+
+#define   EPJ053      (ERRPJ +   53)    /*  gp_pj_dlm.c: 243 */
+#define   EPJ054      (ERRPJ +   54)    /*  gp_pj_dlm.c: 381 */
+#define   EPJ055      (ERRPJ +   55)    /*  gp_pj_dlm.c: 518 */
+#define   EPJ056      (ERRPJ +   56)    /*  gp_pj_dlm.c: 564 */
+#define   EPJ057      (ERRPJ +   57)    /*  gp_pj_dlm.c: 644 */
+#define   EPJ058      (ERRPJ +   58)    /*  gp_pj_dlm.c: 724 */
+#define   EPJ059      (ERRPJ +   59)    /*  gp_pj_dlm.c: 864 */
+#define   EPJ060      (ERRPJ +   60)    /*  gp_pj_dlm.c: 883 */
+#define   EPJ061      (ERRPJ +   61)    /*  gp_pj_dlm.c: 921 */
+#define   EPJ062      (ERRPJ +   62)    /*  gp_pj_dlm.c:1036 */
+#define   EPJ063      (ERRPJ +   63)    /*  gp_pj_dlm.c:1049 */
+#define   EPJ064      (ERRPJ +   64)    /*  gp_pj_dlm.c:1176 */
+#define   EPJ065      (ERRPJ +   65)    /*  gp_pj_dlm.c:1226 */
+#define   EPJ066      (ERRPJ +   66)    /*  gp_pj_dlm.c:1299 */
+#define   EPJ067      (ERRPJ +   67)    /*  gp_pj_dlm.c:1324 */
+#define   EPJ068      (ERRPJ +   68)    /*  gp_pj_dlm.c:1466 */
+#define   EPJ069      (ERRPJ +   69)    /*  gp_pj_dlm.c:1534 */
+#define   EPJ070      (ERRPJ +   70)    /*  gp_pj_dlm.c:1621 */
+#define   EPJ071      (ERRPJ +   71)    /*  gp_pj_dlm.c:1637 */
+#define   EPJ072      (ERRPJ +   72)    /*  gp_pj_dlm.c:1657 */
+#define   EPJ073      (ERRPJ +   73)    /*  gp_pj_dlm.c:1680 */
+#define   EPJ074      (ERRPJ +   74)    /*  gp_pj_dlm.c:1750 */
+#define   EPJ075      (ERRPJ +   75)    /*  gp_pj_dlm.c:1772 */
+#define   EPJ076      (ERRPJ +   76)    /*  gp_pj_dlm.c:1847 */
+#define   EPJ077      (ERRPJ +   77)    /*  gp_pj_dlm.c:1961 */
+
+#define   EPJ078      (ERRPJ +   78)    /*  gp_pj_lmm.c: 319 */
+#define   EPJ079      (ERRPJ +   79)    /*  gp_pj_lmm.c: 806 */
+#define   EPJ080      (ERRPJ +   80)    /*  gp_pj_lmm.c: 870 */
+
+#define   EPJ081      (ERRPJ +   81)    /*  gp_pj_uim.c: 268 */
+#define   EPJ082      (ERRPJ +   82)    /*  gp_pj_uim.c: 347 */
+#define   EPJ083      (ERRPJ +   83)    /*  gp_pj_uim.c: 444 */
+#define   EPJ084      (ERRPJ +   84)    /*  gp_pj_uim.c: 758 */
+#define   EPJ085      (ERRPJ +   85)    /*  gp_pj_uim.c: 844 */
+#define   EPJ086      (ERRPJ +   86)    /*  gp_pj_uim.c: 937 */
+#define   EPJ087      (ERRPJ +   87)    /*  gp_pj_uim.c:1008 */
+#define   EPJ088      (ERRPJ +   88)    /*  gp_pj_uim.c:1158 */
+#define   EPJ089      (ERRPJ +   89)    /*  gp_pj_uim.c:1221 */
+#define   EPJ090      (ERRPJ +   90)    /*  gp_pj_uim.c:1305 */
+#define   EPJ091      (ERRPJ +   91)    /*  gp_pj_uim.c:1412 */
+#define   EPJ092      (ERRPJ +   92)    /*  gp_pj_uim.c:1454 */
+#define   EPJ093      (ERRPJ +   93)    /*  gp_pj_uim.c:1566 */
+
+#define   EPJ094      (ERRPJ +   94)    /* gp_pj_uim.c.tmp: 268 */
+#define   EPJ095      (ERRPJ +   95)    /* gp_pj_uim.c.tmp: 347 */
+#define   EPJ096      (ERRPJ +   96)    /* gp_pj_uim.c.tmp: 444 */
+#define   EPJ097      (ERRPJ +   97)    /* gp_pj_uim.c.tmp: 758 */
+#define   EPJ098      (ERRPJ +   98)    /* gp_pj_uim.c.tmp: 844 */
+#define   EPJ099      (ERRPJ +   99)    /* gp_pj_uim.c.tmp: 937 */
+#define   EPJ100      (ERRPJ +  100)    /* gp_pj_uim.c.tmp:1008 */
+#define   EPJ101      (ERRPJ +  101)    /* gp_pj_uim.c.tmp:1158 */
+#define   EPJ102      (ERRPJ +  102)    /* gp_pj_uim.c.tmp:1221 */
+#define   EPJ103      (ERRPJ +  103)    /* gp_pj_uim.c.tmp:1305 */
+#define   EPJ104      (ERRPJ +  104)    /* gp_pj_uim.c.tmp:1412 */
+#define   EPJ105      (ERRPJ +  105)    /* gp_pj_uim.c.tmp:1454 */
+#define   EPJ106      (ERRPJ +  106)    /* gp_pj_uim.c.tmp:1566 */
+
+#define   EPJ107      (ERRPJ +  107)    /*  gp_pj_ulm.c: 482 */
+#define   EPJ108      (ERRPJ +  108)    /*  gp_pj_ulm.c: 812 */
+#define   EPJ109      (ERRPJ +  109)    /*  gp_pj_ulm.c: 828 */
+#define   EPJ110      (ERRPJ +  110)    /*  gp_pj_ulm.c: 943 */
+#define   EPJ111      (ERRPJ +  111)    /*  gp_pj_ulm.c: 972 */
+#define   EPJ112      (ERRPJ +  112)    /*  gp_pj_ulm.c:1047 */
+#define   EPJ113      (ERRPJ +  113)    /*  gp_pj_ulm.c:1064 */
+#define   EPJ114      (ERRPJ +  114)    /*  gp_pj_ulm.c:2070 */
+#define   EPJ115      (ERRPJ +  115)    /*  gp_pj_ulm.c:2077 */
+
+#define   EPJ116      (ERRPJ +  116)    /*  gp_pj_utl.c: 213 */
+#define   EPJ117      (ERRPJ +  117)    /*  gp_pj_utl.c: 221 */
+#define   EPJ118      (ERRPJ +  118)    /*  gp_pj_utl.c: 291 */
+#define   EPJ119      (ERRPJ +  119)    /*  gp_pj_utl.c: 356 */
+#define   EPJ120      (ERRPJ +  120)    /*  gp_pj_utl.c: 421 */
+#define   EPJ121      (ERRPJ +  121)    /*  gp_pj_utl.c: 510 */
+#define   EPJ122      (ERRPJ +  122)    /*  gp_pj_utl.c: 525 */
+#define   EPJ123      (ERRPJ +  123)    /*  gp_pj_utl.c: 532 */
+#define   EPJ124      (ERRPJ +  124)    /*  gp_pj_utl.c: 554 */
+#define   EPJ125      (ERRPJ +  125)    /*  gp_pj_utl.c: 640 */
+#define   EPJ126      (ERRPJ +  126)    /*  gp_pj_utl.c: 652 */
+#define   EPJ127      (ERRPJ +  127)    /*  gp_pj_utl.c: 676 */
+#define   EPJ128      (ERRPJ +  128)    /*  gp_pj_utl.c: 782 */
+#define   EPJ129      (ERRPJ +  129)    /*  gp_pj_utl.c: 794 */
+#define   EPJ130      (ERRPJ +  130)    /*  gp_pj_utl.c: 805 */
+#define   EPJ131      (ERRPJ +  131)    /*  gp_pj_utl.c: 826 */
+#define   EPJ132      (ERRPJ +  132)    /*  gp_pj_utl.c: 905 */
+#define   EPJ133      (ERRPJ +  133)    /*  gp_pj_utl.c: 919 */
+#define   EPJ134      (ERRPJ +  134)    /*  gp_pj_utl.c: 926 */
+#define   EPJ135      (ERRPJ +  135)    /*  gp_pj_utl.c:1027 */
+#define   EPJ136      (ERRPJ +  136)    /*  gp_pj_utl.c:1042 */
+#define   EPJ137      (ERRPJ +  137)    /*  gp_pj_utl.c:1070 */
+#define   EPJ138      (ERRPJ +  138)    /*  gp_pj_utl.c:1205 */
+#define   EPJ139      (ERRPJ +  139)    /*  gp_pj_utl.c:1222 */
+#define   EPJ140      (ERRPJ +  140)    /*  gp_pj_utl.c:1232 */
+#define   EPJ141      (ERRPJ +  141)    /*  gp_pj_utl.c:2460 */
+#define   EPJ142      (ERRPJ +  142)    /*  gp_pj_utl.c:2470 */
+#define   EPJ143      (ERRPJ +  143)    /*  gp_pj_utl.c:2642 */
+#define   EPJ144      (ERRPJ +  144)    /*  gp_pj_utl.c:2874 */
+#define   EPJ145      (ERRPJ +  145)    /*  gp_pj_utl.c:2963 */
+#define   EPJ146      (ERRPJ +  146)    /*  gp_pj_utl.c:3153 */
+#define   EPJ147      (ERRPJ +  147)    /*  gp_pj_utl.c:3171 */
+#define   EPJ148      (ERRPJ +  148)    /*  gp_pj_utl.c:3219 */
+#define   EPJ149      (ERRPJ +  149)    /*  gp_pj_utl.c:3322 */
+#define   EPJ150      (ERRPJ +  150)    /*  gp_pj_utl.c:3353 */
+#define   EPJ151      (ERRPJ +  151)    /*  gp_pj_utl.c:3412 */
+#define   EPJ152      (ERRPJ +  152)    /*  gp_pj_utl.c:3449 */
+#define   EPJ153      (ERRPJ +  153)    /*  gp_pj_utl.c:3540 */
+
+#define   EPJ154      (ERRPJ +  154)    /* gp_pj_utl.c.tmp: 213 */
+#define   EPJ155      (ERRPJ +  155)    /* gp_pj_utl.c.tmp: 221 */
+#define   EPJ156      (ERRPJ +  156)    /* gp_pj_utl.c.tmp: 291 */
+#define   EPJ157      (ERRPJ +  157)    /* gp_pj_utl.c.tmp: 356 */
+#define   EPJ158      (ERRPJ +  158)    /* gp_pj_utl.c.tmp: 421 */
+#define   EPJ159      (ERRPJ +  159)    /* gp_pj_utl.c.tmp: 510 */
+#define   EPJ160      (ERRPJ +  160)    /* gp_pj_utl.c.tmp: 525 */
+#define   EPJ161      (ERRPJ +  161)    /* gp_pj_utl.c.tmp: 532 */
+#define   EPJ162      (ERRPJ +  162)    /* gp_pj_utl.c.tmp: 554 */
+#define   EPJ163      (ERRPJ +  163)    /* gp_pj_utl.c.tmp: 640 */
+#define   EPJ164      (ERRPJ +  164)    /* gp_pj_utl.c.tmp: 652 */
+#define   EPJ165      (ERRPJ +  165)    /* gp_pj_utl.c.tmp: 676 */
+#define   EPJ166      (ERRPJ +  166)    /* gp_pj_utl.c.tmp: 782 */
+#define   EPJ167      (ERRPJ +  167)    /* gp_pj_utl.c.tmp: 794 */
+#define   EPJ168      (ERRPJ +  168)    /* gp_pj_utl.c.tmp: 805 */
+#define   EPJ169      (ERRPJ +  169)    /* gp_pj_utl.c.tmp: 826 */
+#define   EPJ170      (ERRPJ +  170)    /* gp_pj_utl.c.tmp: 905 */
+#define   EPJ171      (ERRPJ +  171)    /* gp_pj_utl.c.tmp: 919 */
+#define   EPJ172      (ERRPJ +  172)    /* gp_pj_utl.c.tmp: 926 */
+#define   EPJ173      (ERRPJ +  173)    /* gp_pj_utl.c.tmp:1027 */
+#define   EPJ174      (ERRPJ +  174)    /* gp_pj_utl.c.tmp:1042 */
+#define   EPJ175      (ERRPJ +  175)    /* gp_pj_utl.c.tmp:1070 */
+#define   EPJ176      (ERRPJ +  176)    /* gp_pj_utl.c.tmp:1205 */
+#define   EPJ177      (ERRPJ +  177)    /* gp_pj_utl.c.tmp:1222 */
+#define   EPJ178      (ERRPJ +  178)    /* gp_pj_utl.c.tmp:1232 */
+#define   EPJ179      (ERRPJ +  179)    /* gp_pj_utl.c.tmp:2460 */
+#define   EPJ180      (ERRPJ +  180)    /* gp_pj_utl.c.tmp:2470 */
+#define   EPJ181      (ERRPJ +  181)    /* gp_pj_utl.c.tmp:2642 */
+#define   EPJ182      (ERRPJ +  182)    /* gp_pj_utl.c.tmp:2874 */
+#define   EPJ183      (ERRPJ +  183)    /* gp_pj_utl.c.tmp:2963 */
+#define   EPJ184      (ERRPJ +  184)    /* gp_pj_utl.c.tmp:3153 */
+#define   EPJ185      (ERRPJ +  185)    /* gp_pj_utl.c.tmp:3171 */
+#define   EPJ186      (ERRPJ +  186)    /* gp_pj_utl.c.tmp:3219 */
+#define   EPJ187      (ERRPJ +  187)    /* gp_pj_utl.c.tmp:3322 */
+#define   EPJ188      (ERRPJ +  188)    /* gp_pj_utl.c.tmp:3353 */
+#define   EPJ189      (ERRPJ +  189)    /* gp_pj_utl.c.tmp:3412 */
+#define   EPJ190      (ERRPJ +  190)    /* gp_pj_utl.c.tmp:3449 */
+#define   EPJ191      (ERRPJ +  191)    /* gp_pj_utl.c.tmp:3540 */
+
+#define   EPJ192      (ERRPJ +  192)    /*    gp_ptui.c: 666 */
+#define   EPJ193      (ERRPJ +  193)    /*    gp_ptui.c: 709 */
+#define   EPJ194      (ERRPJ +  194)    /*    gp_ptui.c: 752 */
+#define   EPJ195      (ERRPJ +  195)    /*    gp_ptui.c: 795 */
+#define   EPJ196      (ERRPJ +  196)    /*    gp_ptui.c: 842 */
+#define   EPJ197      (ERRPJ +  197)    /*    gp_ptui.c:1081 */
+#define   EPJ198      (ERRPJ +  198)    /*    gp_ptui.c:1123 */
+#define   EPJ199      (ERRPJ +  199)    /*    gp_ptui.c:1158 */
+
+#define   EPJ200      (ERRPJ +  200)    /*     gp_tmm.c: 213 */
+#define   EPJ201      (ERRPJ +  201)    /*     gp_tmm.c: 303 */
+#define   EPJ202      (ERRPJ +  202)    /*     gp_tmm.c: 405 */
+#define   EPJ203      (ERRPJ +  203)    /*     gp_tmm.c: 519 */
+
+#define   EPJ204      (ERRPJ +  204)    /*     gp_tmr.c: 253 */
+#define   EPJ205      (ERRPJ +  205)    /*     gp_tmr.c: 358 */
+#define   EPJ206      (ERRPJ +  206)    /*     gp_tmr.c: 554 */
+
+#define   EPJ207      (ERRPJ +  207)    /*     gp_uim.c: 276 */
+#define   EPJ208      (ERRPJ +  208)    /*     gp_uim.c: 358 */
+#define   EPJ209      (ERRPJ +  209)    /*     gp_uim.c: 437 */
+#define   EPJ210      (ERRPJ +  210)    /*     gp_uim.c: 690 */
+#define   EPJ211      (ERRPJ +  211)    /*     gp_uim.c: 769 */
+#define   EPJ212      (ERRPJ +  212)    /*     gp_uim.c: 832 */
+#define   EPJ213      (ERRPJ +  213)    /*     gp_uim.c: 912 */
+
+#define   EPJ214      (ERRPJ +  214)    /*     gp_umm.c: 213 */
+#define   EPJ215      (ERRPJ +  215)    /*     gp_umm.c: 706 */
+#define   EPJ216      (ERRPJ +  216)    /*     gp_umm.c:1248 */
+
+#define   EPJ217      (ERRPJ +  217)    /*     gp_utl.c: 227 */
+#define   EPJ218      (ERRPJ +  218)    /*     gp_utl.c: 237 */
+#define   EPJ219      (ERRPJ +  219)    /*     gp_utl.c: 263 */
+#define   EPJ220      (ERRPJ +  220)    /*     gp_utl.c: 278 */
+#define   EPJ221      (ERRPJ +  221)    /*     gp_utl.c: 383 */
+#define   EPJ222      (ERRPJ +  222)    /*     gp_utl.c: 401 */
+#define   EPJ223      (ERRPJ +  223)    /*     gp_utl.c: 413 */
+#define   EPJ224      (ERRPJ +  224)    /*     gp_utl.c: 473 */
+#define   EPJ225      (ERRPJ +  225)    /*     gp_utl.c: 598 */
+#define   EPJ226      (ERRPJ +  226)    /*     gp_pj_tmr.c: 291 */
+#define   EPJ227      (ERRPJ +  227)    /*     gp_pj_tmr.c: 576 */
+#define   EPJ228      (ERRPJ +  228) 
+#define   EPJ229      (ERRPJ +  229) 
+#endif /* __KW_ERR_H__ */
+\f  
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_id.c b/src/5gnrpdcp/pj_id.c
new file mode 100755 (executable)
index 0000000..f9d6e31
--- /dev/null
@@ -0,0 +1,135 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:     LTE-PDCP Layer
+    
+        Type:     C source file
+  
+        Desc:     
+        File:     pj_id.c
+  
+*********************************************************************21*/
+
+\f  
+/* header include files (.h) */
+  
+#include "envopt.h"             /* environment options */  
+#include "envdep.h"             /* environment dependent */
+#include "envind.h"             /* environment independent */
+
+#include "gen.h"                /* general */
+#include "ssi.h"                /* system services interface */
+
+/* header/extern include files (.x) */
+
+#include "gen.x"                /* general */
+#include "ssi.x"                /* system services interface */
+
+\f  
+/* local defines */
+
+#define KWSWMV 2             /* rlc - main version */
+#define KWSWMR 1             /* rlc - main revision */
+#define KWSWBV 0             /* rlc - branch version */
+#define KWSWBR 5             /* rlc -  kw005.201 patch level */
+#define KWSWPN "1000371"     /* rlc - part number */
+
+/* local typedefs */
+
+/* local externs */
+  
+/* forward references */
+
+/* public variable declarations */
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif /* CPLUSPLUS */
+
+EXTERN S16 pjGetSId ARGS((SystemId *s));
+#ifdef __cplusplus
+}
+#endif /* CPLUSPLUS */
+
+/* copyright banner */
+
+PUBLIC CONSTANT Txt pjBan1[] =
+   {"(c) COPYRIGHT 1989-2002, Trillium Digital Systems, Inc."};
+
+PUBLIC CONSTANT Txt pjBan2[] =
+   {"                 All rights reserved."};
+
+/* system id */
+
+PRIVATE CONSTANT SystemId sId ={
+   KWSWMV,              /* rlc - main version */
+   KWSWMR,              /* rlc - main revision */
+   KWSWBV,              /* rlc - branch version */
+   KWSWBR,              /* rlc - branch revision */
+   KWSWPN               /* rlc - part number */
+};
+
+/*
+*     support functions
+*/
+
+/*
+*
+*       Fun:   get system id
+*
+*       Desc:  Get system id consisting of part number, main version and
+*              revision and branch version and branch.
+*
+*       Ret:   TRUE      - ok
+*
+*       Notes: None
+*
+*       File:  kw_id.c
+*
+*/
+
+#ifdef ANSI
+PUBLIC S16 pjGetSId
+(
+SystemId *s                 /* system id */
+)
+#else
+PUBLIC S16 pjGetSId(s)
+SystemId *s;                /* system id */
+#endif
+{
+   TRC2(pjGetSId);
+
+   s->mVer = sId.mVer;
+   s->mRev = sId.mRev;
+   s->bVer = sId.bVer;
+   s->bRev = sId.bRev;
+   s->ptNmb = sId.ptNmb;
+
+   RETVALUE(TRUE);
+
+} /* end of pjGetSId */
+
+\f  
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_lib.c b/src/5gnrpdcp/pj_lib.c
new file mode 100755 (executable)
index 0000000..322e2e6
--- /dev/null
@@ -0,0 +1,1801 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE-PDCP Layer - Upper Interface
+    
+        Type:    C file
+  
+        Desc:    C source code for the hook functions of LTE-PDCP
+
+                 This file contains the following functions:
+         
+                 --pjLibCmpInit
+                 --pjLibIntInit
+                 --pjLibCpInit
+                 --pjLibUpInit
+                 --pjLibCmpReset
+                 --pjLibCmpSdu
+                 --pjLibIntProt
+                 --pjLibIntVerify
+                 --pjLibDecipherSdu
+                 --pjLibSndFeedback
+                 --pjLibCmpClose
+                 --pjLibIntClose
+                 --pjLibCpClose
+                 --pjLibUpClose
+
+                 Portable functions for software hooks:
+
+                 --pjLibCmpInitReq
+                 --pjLibIntInitReq
+                 --pjLibCpInitReq
+                 --pjLibUpInitReq
+                 --pjLibCmpResetReq
+                 --pjLibCmpReq
+                 --pjLibIntProtReq
+                 --pjLibCipherReq
+                 --pjLibDecipherReq
+                 --pjLibIntVerReq
+                 --pjLibDeCmpReq
+                 --pjLibCmpCloseReq
+                 --pjLibIntCloseReq
+                 --pjLibCiperCloseReq
+                 --pjLibUpCloseReq 
+
+        File:    pj_lib.c
+  
+*********************************************************************21*/
+
+/** @file pj_lib.c
+@brief PDPC Hook Interface
+*/
+
+\f
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "cpj.h"                /* RRC layer */
+#include "pju.h"                /* PDCP service user */
+#include "lpj.h"                /* LPJ defines */
+#include "pj_err.h"
+#include "pj_env.h"        /* RLC environment options */
+#include "pj_lib.h"     /* LIB options */
+#include "pj.h"            /* RLC defines */
+#include "pj_dl.h"
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "cpj.x"           /* CPJ */
+#include "pju.x"           /* PJU */
+#include "lpj.x"           /* LPJ */
+
+#include "pj.x"
+#include "pj_udx.h"
+#include "pj_udx.x"
+#include "pj_dl.x"
+#include "pj_lib.x"     /* LIB */
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif /* __cplusplus */
+
+\f
+/****************************************************************************
+ *                         Portable hooks for asynchronous 
+ ***************************************************************************/
+
+#ifdef PJ_CMP_ASYNC
+#ifdef ANSI
+PUBLIC S16 cmPkLibObdCmpInitCfm
+(
+Pst * pst,
+PjCmpCxt cmpCxt,
+PTR ctxId
+)
+#else
+PUBLIC S16 cmPkLibObdCmpInitCfm(pst, cmpCxt, ctxId)
+Pst * pst;
+PjCmpCxt cmpCxt;
+PTR ctxId;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkLibObdCmpInitCfm)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB001, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPtr(ctxId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB002, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPjCmpCxt(&cmpCxt, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB003, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) OBD_EVT_CMP_INIT_CFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkLibObdCmpInitCfm
+(
+ObdCmpInitCfm func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkLibObdCmpInitCfm(func, pst, mBuf)
+ObdCmpInitCfm func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   PjCmpCxt cmpCxt;
+   PTR ctxId;
+   
+   TRC3(cmUnpkLibObdCmpInitCfm)
+
+   if (cmUnpkPjCmpCxt(&cmpCxt, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB004, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmUnpkPtr(&ctxId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB005, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, cmpCxt, ctxId));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkLibObdCmpCfm
+(
+Pst * pst,
+PTR cmpCxtId,
+PjLibTrans libTrans,
+Buffer * opSdu
+)
+#else
+PUBLIC S16 cmPkLibObdCmpCfm(pst, cmpCxtId, libTrans, opSdu)
+Pst * pst;
+PTR cmpCxtId;
+PjLibTrans libTrans;
+Buffer * opSdu;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   MsgLen msgLen = 0;
+   TRC3(cmPkLibObdCmpCfm)
+
+   if (pst->selector == OBD_SEL_LC) {
+      if ( opSdu != NULLP )
+      {
+      if (SFndLenMsg(opSdu, &msgLen) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ELIB022, (ErrVal)0, "Packing failed");
+#endif
+         PJ_FREE_BUF(opSdu);
+         RETVALUE(RFAILED);
+      }
+      if (SCpyMsgMsg(opSdu, pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ELIB023, (ErrVal)0, "Packing failed");
+#endif
+         RETVALUE(RFAILED);
+      }
+      }
+      else
+      {
+         msgLen = 0;
+         if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+            SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                  __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                  (ErrVal)ELIB036, (ErrVal)0, "Packing failed");
+#endif
+            RETVALUE(RFAILED);
+         }
+      }
+      CMCHKPK(cmPkMsgLen, msgLen, mBuf);
+
+   }
+   else
+   {
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB021, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   }
+
+   if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB025, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPtr(cmpCxtId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB026, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) OBD_EVT_CMP_CFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkLibObdCmpCfm
+(
+ObdCmpCfm func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkLibObdCmpCfm(func, pst, mBuf)
+ObdCmpCfm func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   PTR cmpCxtId;
+   PjLibTrans libTrans;
+   Buffer *opSdu;
+   
+   TRC3(cmUnpkLibObdCmpCfm)
+   
+   opSdu = NULLP;
+
+   if (cmUnpkPtr(&cmpCxtId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB027, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB028, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (pst->selector == OBD_SEL_LC) {
+      MsgLen msgLen, totalMsgLen;
+      CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf);
+      if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
+         RETVALUE(RFAILED);
+      if ( msgLen != 0 )
+      {
+         if (SSegMsg(mBuf, totalMsgLen-msgLen, &opSdu) != ROK)
+            RETVALUE(RFAILED);
+      }
+   }
+
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, cmpCxtId, libTrans, opSdu));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkLibObdDecmpCfm
+(
+Pst * pst,
+PTR cmpCxtId,
+PjLibTrans libTrans,
+Buffer * opSdu,
+Buffer * fbPkt
+)
+#else
+PUBLIC S16 cmPkLibObdDecmpCfm(pst, cmpCxtId, libTrans, opSdu, fbPkt)
+Pst * pst;
+PTR cmpCxtId;
+PjLibTrans libTrans;
+Buffer * opSdu;
+Buffer * fbPkt;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   Buffer *tBuf = NULLP;
+   MsgLen msgLen = 0;
+   TRC3(cmPkLibObdDecmpCfm)
+
+   if (fbPkt != NULLP) {
+      if (SFndLenMsg(fbPkt, &msgLen) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ELIB060, (ErrVal)0, "Packing failed");
+#endif
+         RETVALUE(RFAILED);
+      }
+      if (SCpyMsgMsg(fbPkt, pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ELIB061, (ErrVal)0, "Packing failed");
+#endif
+         RETVALUE(RFAILED);
+      }
+   }else{
+      if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+               __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+               (ErrVal)ELIB059, (ErrVal)0, "Packing failed");
+#endif
+         RETVALUE(RFAILED);
+      }
+
+      msgLen = 0;
+   }
+   CMCHKPK(cmPkMsgLen, msgLen, mBuf);
+
+   if (opSdu != NULLP) {
+      if (SFndLenMsg(opSdu, &msgLen) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ELIB060, (ErrVal)0, "Packing failed");
+#endif
+         PJ_FREE_BUF(mBuf);
+         RETVALUE(RFAILED);
+      }
+      if (SCpyMsgMsg(opSdu, pst->region, pst->pool, &tBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ELIB061, (ErrVal)0, "Packing failed");
+#endif
+         PJ_FREE_BUF(mBuf);
+         RETVALUE(RFAILED);
+      }
+      if (SCatMsg(mBuf, tBuf, M1M2) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ELIB061, (ErrVal)0, "Packing failed");
+#endif
+         PJ_FREE_BUF(mBuf);
+         PJ_FREE_BUF(tBuf);
+         RETVALUE(RFAILED);
+      }
+
+      if (tBuf != NULLP)
+         PJ_FREE_BUF(tBuf);
+   } else {
+      msgLen = 0;
+   }
+   CMCHKPK(cmPkMsgLen, msgLen, mBuf);
+
+   if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB063, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPtr(cmpCxtId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB064, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) OBD_EVT_DECMP_CFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkLibObdDecmpCfm
+(
+ObdDecmpCfm func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkLibObdDecmpCfm(func, pst, mBuf)
+ObdDecmpCfm func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   PTR cmpCxtId;
+   PjLibTrans libTrans;
+   Buffer *opSdu = NULLP;
+   Buffer *fbPkt = NULLP;
+   
+   TRC3(cmUnpkLibObdDecmpCfm)
+
+   if (cmUnpkPtr(&cmpCxtId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB065, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB066, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (pst->selector == OBD_SEL_LC) {
+      MsgLen msgLen, totalMsgLen;
+      CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf);
+      if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
+         RETVALUE(RFAILED);
+      if(msgLen != 0)
+         if (SSegMsg(mBuf, totalMsgLen-msgLen, &opSdu) != ROK)
+            RETVALUE(RFAILED);
+   }
+
+   if (pst->selector == OBD_SEL_LC) {
+      MsgLen msgLen, totalMsgLen;
+      CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf);
+      if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
+         RETVALUE(RFAILED);
+      if(msgLen != 0)
+         if (SSegMsg(mBuf, totalMsgLen-msgLen, &fbPkt) != ROK)
+            RETVALUE(RFAILED);
+   }
+
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, cmpCxtId, libTrans, opSdu, fbPkt));
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjRohc
+*
+*
+*     Desc : PjHdrCmp
+  Robust header compression Information
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjRohc
+(
+PjRohc *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjRohc(param, mBuf)
+PjRohc *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjRohc)
+
+   CMCHKPK(SPkU16, param->profId, mBuf);
+   CMCHKPK(SPkU16, param->maxCid, mBuf);
+   CMCHKPK(SPkU8, param->hdrCmpUsed, mBuf);
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjRohc
+*
+*
+*     Desc : PjHdrCmp
+  Robust header compression Information
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjRohc
+(
+PjRohc *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjRohc(param, mBuf)
+PjRohc *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjRohc)
+
+   CMCHKUNPK(SUnpkU8, &param->hdrCmpUsed, mBuf);
+   CMCHKUNPK(SUnpkU16, &param->maxCid, mBuf);
+   CMCHKUNPK(SUnpkU16, &param->profId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjCmpCxt
+*
+*
+*     Desc : PjCmpCxt
+Context for ROHC
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjCmpCxt
+(
+PjCmpCxt *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjCmpCxt(param, mBuf)
+PjCmpCxt *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjCmpCxt)
+
+   CMCHKPK(cmPkLteRbId, param->rbId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   CMCHKPK(SPkU8, param->rbType, mBuf);
+   CMCHKPK(SPkU16, param->cfgTxId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjCmpCxt
+*
+*
+*     Desc : PjCmpCxt
+Context for ROHC
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjCmpCxt
+(
+PjCmpCxt *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjCmpCxt(param, mBuf)
+PjCmpCxt *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjCmpCxt)
+
+   CMCHKUNPK(SUnpkU16, &param->cfgTxId, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->rbType, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteRbId, &param->rbId, mBuf);
+   RETVALUE(ROK);
+}
+
+#endif /* PJ_CMP_ASYNC */
+
+#ifdef PJ_SEC_ASYNC
+#ifdef ANSI
+PUBLIC S16 cmPkLibObdIntInitCfm
+(
+Pst * pst,
+PjSecCxt secCtx,
+PTR ctxId
+)
+#else
+PUBLIC S16 cmPkLibObdIntInitCfm(pst, secCtx, ctxId)
+Pst * pst;
+PjSecCxt secCtx;
+PTR ctxId;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkLibObdIntInitCfm)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB006, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPtr(ctxId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB007, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPjSecCxt(&secCtx, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB008, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) OBD_EVT_INT_INIT_CFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkLibObdIntInitCfm
+(
+ObdIntInitCfm func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkLibObdIntInitCfm(func, pst, mBuf)
+ObdIntInitCfm func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   PjSecCxt secCtx;
+   PTR ctxId;
+   
+   TRC3(cmUnpkLibObdIntInitCfm)
+
+   if (cmUnpkPjSecCxt(&secCtx, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB009, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmUnpkPtr(&ctxId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB010, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, secCtx, ctxId));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkLibObdCpInitCfm
+(
+Pst * pst,
+PjSecCxt secCxt,
+PTR ctxId
+)
+#else
+PUBLIC S16 cmPkLibObdCpInitCfm(pst, secCxt, ctxId)
+Pst * pst;
+PjSecCxt secCxt;
+PTR ctxId;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkLibObdCpInitCfm)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB011, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPtr(ctxId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB012, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPjSecCxt(&secCxt, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB013, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) OBD_EVT_CP_INIT_CFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkLibObdCpInitCfm
+(
+ObdCpInitCfm func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkLibObdCpInitCfm(func, pst, mBuf)
+ObdCpInitCfm func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   PjSecCxt secCxt;
+   PTR ctxId;
+   
+   TRC3(cmUnpkLibObdCpInitCfm)
+
+   if (cmUnpkPjSecCxt(&secCxt, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB014, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmUnpkPtr(&ctxId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB015, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, secCxt, ctxId));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkLibObdUpInitCfm
+(
+Pst * pst,
+PjSecCxt secCxt,
+PTR ctxId
+)
+#else
+PUBLIC S16 cmPkLibObdUpInitCfm(pst, secCxt, ctxId)
+Pst * pst;
+PjSecCxt secCxt;
+PTR ctxId;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkLibObdUpInitCfm)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB016, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPtr(ctxId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB017, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPjSecCxt(&secCxt, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB018, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) OBD_EVT_UP_INIT_CFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkLibObdUpInitCfm
+(
+ObdUpInitCfm func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkLibObdUpInitCfm(func, pst, mBuf)
+ObdUpInitCfm func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   PjSecCxt secCxt;
+   PTR ctxId;
+   
+   TRC3(cmUnpkLibObdUpInitCfm)
+
+   if (cmUnpkPjSecCxt(&secCxt, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB019, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmUnpkPtr(&ctxId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB020, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, secCxt, ctxId));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkLibObdIntProtCfm
+(
+Pst * pst,
+PTR cxtId,
+PjLibTrans libTrans,
+U32 macI
+)
+#else
+PUBLIC S16 cmPkLibObdIntProtCfm(pst, cxtId, libTrans, macI)
+Pst * pst;
+PTR cxtId;
+PjLibTrans libTrans;
+U32 macI;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkLibObdIntProtCfm)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB029, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (SPkU32(macI, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB030, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB031, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPtr(cxtId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB032, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) OBD_EVT_INT_PROT_CFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkLibObdIntProtCfm
+(
+ObdIntProtCfm func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkLibObdIntProtCfm(func, pst, mBuf)
+ObdIntProtCfm func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   PTR cxtId;
+   PjLibTrans libTrans;
+   U32 macI;
+   
+   TRC3(cmUnpkLibObdIntProtCfm)
+
+   if (cmUnpkPtr(&cxtId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB033, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB034, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (SUnpkU32(&macI, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB035, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, cxtId, libTrans, macI));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkLibObdCipherCfm
+(
+Pst * pst,
+PTR cxtId,
+PjLibTrans libTrans,
+Buffer * opSdu
+)
+#else
+PUBLIC S16 cmPkLibObdCipherCfm(pst, cxtId, libTrans, opSdu)
+Pst * pst;
+PTR cxtId;
+PjLibTrans libTrans;
+Buffer * opSdu;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   MsgLen msgLen = 0;
+   TRC3(cmPkLibObdCipherCfm)
+
+   if (pst->selector == OBD_SEL_LC) {
+      if ( opSdu != NULLP )
+      {
+         if (SFndLenMsg(opSdu, &msgLen) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+            SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+               __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+               (ErrVal)ELIB037, (ErrVal)0, "Packing failed");
+#endif
+            PJ_FREE_BUF(opSdu);
+            RETVALUE(RFAILED);
+         }
+         if (SCpyMsgMsg(opSdu, pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+            SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+               __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+               (ErrVal)ELIB038, (ErrVal)0, "Packing failed");
+#endif
+            PJ_FREE_BUF(opSdu);
+            RETVALUE(RFAILED);
+         }
+         /* SPutMsg(opSdu); */
+      }
+      else
+      {
+         msgLen = 0;
+         if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+            SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                  __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                  (ErrVal)ELIB036, (ErrVal)0, "Packing failed");
+#endif
+            RETVALUE(RFAILED);
+         }
+      }
+      CMCHKPK(cmPkMsgLen, msgLen, mBuf);
+
+   }
+   else
+   {
+      if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+               __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+               (ErrVal)ELIB036, (ErrVal)0, "Packing failed");
+#endif
+         PJ_FREE_BUF(opSdu);
+         RETVALUE(RFAILED);
+      }
+   }
+
+
+   if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB040, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(opSdu);
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPtr(cxtId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB041, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(opSdu);
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) OBD_EVT_CIPHER_CFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkLibObdCipherCfm
+(
+ObdCipherCfm func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkLibObdCipherCfm(func, pst, mBuf)
+ObdCipherCfm func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   PTR cxtId;
+   PjLibTrans libTrans;
+   Buffer *opSdu;
+   
+   TRC3(cmUnpkLibObdCipherCfm)
+
+   opSdu = NULLP;
+
+   if (cmUnpkPtr(&cxtId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB042, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB043, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+
+   if (pst->selector == OBD_SEL_LC) {
+      MsgLen msgLen, totalMsgLen;
+      CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf);
+      if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
+         RETVALUE(RFAILED);
+      if ( msgLen != 0 )
+      {
+         if (SSegMsg(mBuf, totalMsgLen-msgLen, &opSdu) != ROK)
+         {
+            RETVALUE(RFAILED);
+         }
+      }
+   }
+
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, cxtId, libTrans, opSdu));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkLibObdDecipherCfm
+(
+Pst * pst,
+PTR cxtId,
+PjLibTrans libTrans,
+Buffer * opSdu
+)
+#else
+PUBLIC S16 cmPkLibObdDecipherCfm(pst, cxtId, libTrans, opSdu)
+Pst * pst;
+PTR cxtId;
+PjLibTrans libTrans;
+Buffer * opSdu;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   MsgLen msgLen = 0;
+   TRC3(cmPkLibObdDecipherCfm)
+
+   if (pst->selector == OBD_SEL_LC) {
+      if ( opSdu != NULLP)
+      {
+         if (SFndLenMsg(opSdu, &msgLen) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+            SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+               __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+               (ErrVal)ELIB045, (ErrVal)0, "Packing failed");
+#endif
+            RETVALUE(RFAILED);
+         }
+         if (SCpyMsgMsg(opSdu, pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+            SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+               __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+               (ErrVal)ELIB046, (ErrVal)0, "Packing failed");
+#endif
+            RETVALUE(RFAILED);
+         }
+      }
+      else
+      {
+         msgLen = 0;
+         if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+            SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                  __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                  (ErrVal)ELIB036, (ErrVal)0, "Packing failed");
+#endif
+            RETVALUE(RFAILED);
+         }
+      }
+      CMCHKPK(cmPkMsgLen, msgLen, mBuf);
+
+   }
+   else
+   {
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB044, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   }
+
+   if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB048, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPtr(cxtId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB049, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) OBD_EVT_DECIPHER_CFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkLibObdDecipherCfm
+(
+ObdDecipherCfm func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkLibObdDecipherCfm(func, pst, mBuf)
+ObdDecipherCfm func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   PTR cxtId;
+   PjLibTrans libTrans;
+   Buffer *opSdu= NULLP;
+   
+   TRC3(cmUnpkLibObdDecipherCfm)
+
+   if (cmUnpkPtr(&cxtId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB050, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB051, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (pst->selector == OBD_SEL_LC) {
+      MsgLen msgLen, totalMsgLen;
+      CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf);
+      if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
+         RETVALUE(RFAILED);
+      if ( msgLen != 0 )
+      {
+         if (SSegMsg(mBuf, totalMsgLen-msgLen, &opSdu) != ROK)
+            RETVALUE(RFAILED);
+      }
+   }
+
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, cxtId, libTrans, opSdu));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkLibObdIntVerCfm
+(
+Pst * pst,
+PTR cxtId,
+PjLibTrans libTrans,
+Status status
+)
+#else
+PUBLIC S16 cmPkLibObdIntVerCfm(pst, cxtId, libTrans, status)
+Pst * pst;
+PTR cxtId;
+PjLibTrans libTrans;
+Status status;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkLibObdIntVerCfm)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB052, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (SPkS16(status, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB053, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB054, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPtr(cxtId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB055, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) OBD_EVT_INT_VER_CFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkLibObdIntVerCfm
+(
+ObdIntVerCfm func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkLibObdIntVerCfm(func, pst, mBuf)
+ObdIntVerCfm func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   PTR cxtId;
+   PjLibTrans libTrans;
+   Status status;
+   
+   TRC3(cmUnpkLibObdIntVerCfm)
+
+   if (cmUnpkPtr(&cxtId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB056, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB057, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (SUnpkS16(&status, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ELIB058, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, cxtId, libTrans, status));
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjSecCxt
+*
+*
+*     Desc : PjSecCxt
+Context for Security Algorithm
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjSecCxt
+(
+PjSecCxt *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjSecCxt(param, mBuf)
+PjSecCxt *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjSecCxt)
+
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   CMCHKPK(SPkU16, param->cfgTxId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjSecCxt
+*
+*
+*     Desc : PjSecCxt
+Context for Security Algorithm
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjSecCxt
+(
+PjSecCxt *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjSecCxt(param, mBuf)
+PjSecCxt *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjSecCxt)
+
+   CMCHKUNPK(SUnpkU16, &param->cfgTxId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjIntInfo
+*
+*
+*     Desc : PjIntInfo
+  PDCP Integrity Algo Information
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjIntInfo
+(
+PjIntInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjIntInfo(param, mBuf)
+PjIntInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmPkPjIntInfo)
+
+   for (i=PJ_INTG_KEY_LEN-1; i >= 0; i--) {
+      CMCHKPK(SPkU8, param->intKey[i], mBuf);
+   }
+   CMCHKPK(SPkU8, param->algoType, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjIntInfo
+*
+*
+*     Desc : PjIntInfo
+  PDCP Integrity Algo Information
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjIntInfo
+(
+PjIntInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjIntInfo(param, mBuf)
+PjIntInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmUnpkPjIntInfo)
+
+   CMCHKUNPK(SUnpkU8, &param->algoType, mBuf);
+   for (i=0; i<PJ_INTG_KEY_LEN; i++) {
+      CMCHKUNPK(SUnpkU8, &param->intKey[i], mBuf);
+   }
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjSecInp
+*
+*
+*     Desc : PjSecInp
+Input parameters for security algorithm
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjSecInp
+(
+PjSecInp *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjSecInp(param, mBuf)
+PjSecInp *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjSecInp)
+
+   CMCHKPK(SPkU8, param->dir, mBuf);
+   CMCHKPK(cmPkLteRbId, param->rbId, mBuf);
+   CMCHKPK(SPkU32, param->count, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjSecInp
+*
+*
+*     Desc : PjSecInp
+Input parameters for security algorithm
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjSecInp
+(
+PjSecInp *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjSecInp(param, mBuf)
+PjSecInp *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjSecInp)
+
+   CMCHKUNPK(SUnpkU32, &param->count, mBuf);
+   CMCHKUNPK(cmUnpkLteRbId, &param->rbId, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->dir, mBuf);
+   RETVALUE(ROK);
+}
+
+#endif /* PJ_SEC_ASYNC */
+
+\f
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+/***********************************************************
+*
+*     Func : cmPkPjLibTrans
+*
+*
+*     Desc : PjLibTrans
+  Transaction Id for Security Algorithm
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjLibTrans
+(
+PjLibTrans *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjLibTrans(param, mBuf)
+PjLibTrans *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjLibTrans)
+
+   CMCHKPK(cmPkPtr, (PTR)param->ueCb, mBuf);
+   CMCHKPK(cmPkLteRbId, param->rbId, mBuf);
+   CMCHKPK(SPkU8, param->rbType, mBuf);
+   CMCHKPK(SPkU32, param->count, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjLibTrans
+*
+*
+*     Desc : PjLibTrans
+  Transaction Id for Security Algorithm
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjLibTrans
+(
+PjLibTrans *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjLibTrans(param, mBuf)
+PjLibTrans *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjLibTrans)
+
+   CMCHKUNPK(SUnpkU32, &param->count, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->rbType, mBuf);
+   CMCHKUNPK(cmUnpkLteRbId, &param->rbId, mBuf);
+   CMCHKUNPK(cmUnpkPtr, (PTR*)&param->ueCb, mBuf);
+   RETVALUE(ROK);
+}
+
+#endif /*  PJ_SEC_ASYNC || PJ_CMP_ASYNC */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_lib.h b/src/5gnrpdcp/pj_lib.h
new file mode 100755 (executable)
index 0000000..7159a9b
--- /dev/null
@@ -0,0 +1,143 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:     LTE PDCP file 
+    
+        Type:     C include file
+  
+        Desc:     This file contain the hash definations for PDCP 
+        File:     pj_lib.h
+  
+*********************************************************************21*/
+/** @file pj_lib.h
+@brief PDCP Hash definitions
+*/
+
+#ifndef __KW_PJ_LIB_H__
+#define __KW_PJ_LIB_H__
+
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+
+#define OBD_SEL_LC                        0
+
+/* Off-board Async Events */
+#define OBD_EVT_CMP_INIT_CFM              0x90
+#define OBD_EVT_CMP_CFM                   0x91
+#define OBD_EVT_DECMP_CFM                 0x92
+#define OBD_EVT_CMP_CLOSE_CFM             0x93
+#define OBD_EVT_CMP_RESET_CFM             0x94
+
+#define OBD_EVT_INT_INIT_CFM              0xa0
+#define OBD_EVT_INT_PROT_CFM              0xa1
+#define OBD_EVT_INT_VER_CFM               0xa2
+#define OBD_EVT_INT_CLOSE_CFM             0xa3
+
+#define OBD_EVT_CP_INIT_CFM               0xb0
+#define OBD_EVT_UP_INIT_CFM               0xb1
+#define OBD_EVT_CIPHER_CFM                0xb2
+#define OBD_EVT_DECIPHER_CFM              0xb3
+#define OBD_EVT_CIPHER_CLOSE_CFM          0xb4
+
+#define ERRLIB                  0
+
+#define ELIB001         (ERRLIB + 1)
+#define ELIB002         (ERRLIB + 2)
+#define ELIB003         (ERRLIB + 3)
+#define ELIB004         (ERRLIB + 4)
+#define ELIB005         (ERRLIB + 5)
+#define ELIB006         (ERRLIB + 6)
+#define ELIB007         (ERRLIB + 7)
+#define ELIB008         (ERRLIB + 8)
+#define ELIB009         (ERRLIB + 9)
+#define ELIB010         (ERRLIB + 10)
+#define ELIB011         (ERRLIB + 11)
+#define ELIB012         (ERRLIB + 12)
+#define ELIB013         (ERRLIB + 13)
+#define ELIB014         (ERRLIB + 14)
+#define ELIB015         (ERRLIB + 15)
+#define ELIB016         (ERRLIB + 16)
+#define ELIB017         (ERRLIB + 17)
+#define ELIB018         (ERRLIB + 18)
+#define ELIB019         (ERRLIB + 19)
+#define ELIB020         (ERRLIB + 20)
+#define ELIB021         (ERRLIB + 21)
+#define ELIB022         (ERRLIB + 22)
+#define ELIB023         (ERRLIB + 23)
+#define ELIB024         (ERRLIB + 24)
+#define ELIB025         (ERRLIB + 25)
+#define ELIB026         (ERRLIB + 26)
+#define ELIB027         (ERRLIB + 27)
+#define ELIB028         (ERRLIB + 28)
+#define ELIB029         (ERRLIB + 29)
+#define ELIB030         (ERRLIB + 30)
+#define ELIB031         (ERRLIB + 31)
+#define ELIB032         (ERRLIB + 32)
+#define ELIB033         (ERRLIB + 33)
+#define ELIB034         (ERRLIB + 34)
+#define ELIB035         (ERRLIB + 35)
+#define ELIB036         (ERRLIB + 36)
+#define ELIB037         (ERRLIB + 37)
+#define ELIB038         (ERRLIB + 38)
+#define ELIB039         (ERRLIB + 39)
+#define ELIB040         (ERRLIB + 40)
+#define ELIB041         (ERRLIB + 41)
+#define ELIB042         (ERRLIB + 42)
+#define ELIB043         (ERRLIB + 43)
+#define ELIB044         (ERRLIB + 44)
+#define ELIB045         (ERRLIB + 45)
+#define ELIB046         (ERRLIB + 46)
+#define ELIB047         (ERRLIB + 47)
+#define ELIB048         (ERRLIB + 48)
+#define ELIB049         (ERRLIB + 49)
+#define ELIB050         (ERRLIB + 50)
+#define ELIB051         (ERRLIB + 51)
+#define ELIB052         (ERRLIB + 52)
+#define ELIB053         (ERRLIB + 53)
+#define ELIB054         (ERRLIB + 54)
+#define ELIB055         (ERRLIB + 55)
+#define ELIB056         (ERRLIB + 56)
+#define ELIB057         (ERRLIB + 57)
+#define ELIB058         (ERRLIB + 58)
+#define ELIB059         (ERRLIB + 59)
+#define ELIB060         (ERRLIB + 60)
+#define ELIB061         (ERRLIB + 61)
+#define ELIB062         (ERRLIB + 62)
+#define ELIB063         (ERRLIB + 63)
+#define ELIB064         (ERRLIB + 64)
+#define ELIB065         (ERRLIB + 65)
+#define ELIB066         (ERRLIB + 66)
+#define ELIB067         (ERRLIB + 67)
+#define ELIB068         (ERRLIB + 68)
+#define ELIB069         (ERRLIB + 69)
+#define ELIB070         (ERRLIB + 70)
+#define ELIB071         (ERRLIB + 71)
+#define ELIB072         (ERRLIB + 72)
+#define ELIB073         (ERRLIB + 73)
+#define ELIB074         (ERRLIB + 74)
+#define ELIB075         (ERRLIB + 75)
+
+#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
+#endif /* __KW_PJ_LIB_H__ */
+\f  
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_lib.x b/src/5gnrpdcp/pj_lib.x
new file mode 100755 (executable)
index 0000000..512974d
--- /dev/null
@@ -0,0 +1,695 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:     LTE PDCP file 
+    
+        Type:     C include file
+  
+        Desc:     This file contain the hash definations for PDCP 
+        File:     pj_lib.x
+
+*********************************************************************21*/
+
+#ifndef __PJ_LIB_X__
+#define __PJ_LIB_X__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifdef PJ_CMP_ASYNC
+
+typedef S16 (*ObdCmpInitCfm) ARGS((
+   Pst *                pst,
+   PjCmpCxt             cmpCxt,
+   PTR                  ctxId));
+
+typedef S16 (*ObdCmpCfm) ARGS((
+   Pst *                pst,
+   PTR                  cmpCxtId,
+   PjLibTrans           libTrans,
+   Buffer *             opSdu));
+
+typedef S16 (*ObdDecmpCfm) ARGS((
+   Pst *                pst,
+   PTR                  cmpCxtId,
+   PjLibTrans           libTrans,
+   Buffer *             opSdu,
+   Buffer *             fbPkt
+));
+
+/* Library function externs */
+EXTERN S16 PjLibObdCmpInitCfm ARGS((
+Pst      *pst,                    /* post structure */
+PjCmpCxt cmpCxt,                  /* Context for ROHC */
+PTR      ctxId                    /* Compression Context ID */
+));
+EXTERN S16 PjLibObdCmpCfm ARGS((
+Pst        *pst,        /* post structure             */
+PTR         cmpCxtId,   /* Context Id for compression */
+PjLibTrans  libTrans,   /* Transaction Id             */
+Buffer     *opSdu       /* compressed SDU             */
+));
+EXTERN S16 PjLibObdDecmpCfm ARGS((
+Pst         *pst,                 /* post structure */
+PTR         cmpCxtId,             /* Context Id for decompression */
+PjLibTrans  libTrans,             /* Transaction Id */
+Buffer      *opSdu,               /* decompressed SDU */
+Buffer      *fbPkt                /* Feedback pkt */
+));
+EXTERN S16 PjLibObdCmpInitReq ARGS((
+Pst * pst,
+PjCmpCxt cmpCxt,
+PjRohc rohc
+));
+EXTERN S16 PjLibObdCmpReq ARGS((
+Pst * pst,
+PTR cmpCxtId,
+PjLibTrans libTrans,
+Buffer * mBuf
+));
+EXTERN S16 PjLibObdDecmpReq ARGS((
+Pst * pst,
+PTR cmpCxtId,
+PjLibTrans libTrans,
+Buffer * mBuf
+));
+EXTERN S16 PjLibObdCmpCloseReq ARGS((
+Pst * pst,
+PTR cmpCxtId
+));
+EXTERN S16 PjLibObdCmpResetReq ARGS((
+Pst * pst,
+PTR cmpCxtId
+));
+EXTERN S16 PjLibObdCmpFbReq  ARGS((
+Pst      *pst,                    /* post structure */
+PTR      cmpCxtId,                /* Context Id for compression */
+PjLibTrans libTrans,             /* Transaction Id */
+Buffer   *feedback                /* SDU to be decompressed */
+));
+
+EXTERN S16 cmPkLibObdCmpInitCfm ARGS((
+Pst * pst,
+PjCmpCxt cmpCxt,
+PTR ctxId
+));
+
+EXTERN S16 cmUnpkLibObdCmpInitCfm ARGS((
+ObdCmpInitCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+
+EXTERN S16 cmPkLibObdCmpCfm ARGS((
+   Pst *                pst,
+   PTR                  cmpCxtId,
+   PjLibTrans           libTrans,
+   Buffer *             opSdu
+));
+
+EXTERN S16 cmUnpkLibObdCmpCfm ARGS((
+   ObdCmpCfm            func,
+   Pst *                pst,
+   Buffer               *mBuf
+));
+
+EXTERN S16 cmPkLibObdDecmpCfm ARGS((
+   Pst *                pst,
+   PTR                  cmpCxtId,
+   PjLibTrans           libTrans,
+   Buffer *             opSdu,
+   Buffer *             fbPkt
+));
+
+EXTERN S16 cmUnpkLibObdDecmpCfm ARGS((
+   ObdDecmpCfm          func,
+   Pst *                pst,
+   Buffer               *mBuf
+));
+
+EXTERN S16 cmPkPjRohc ARGS((
+   PjRohc               *param,
+   Buffer               *mBuf
+));
+EXTERN S16 cmUnpkPjRohc ARGS((
+   PjRohc               *param,
+   Buffer               *mBuf
+));
+EXTERN S16 cmPkPjCmpCxt ARGS((
+   PjCmpCxt             *param,
+   Buffer               *mBuf
+));
+EXTERN S16 cmUnpkPjCmpCxt ARGS((
+   PjCmpCxt             *param,
+   Buffer               *mBuf
+));
+
+#else
+
+EXTERN S16 pjLibCmpInitReq  ARGS((
+PjCmpCxt cmpCxt,                  
+PjRohc   rohc,                    
+PTR      *cmpCxtId                
+));
+EXTERN S16 pjLibCmpReq  ARGS((
+PTR      cmpCxtId,                
+Buffer   *mBuf,                   
+Buffer   **opSdu                  
+));
+EXTERN S16 pjLibDecmpReq  ARGS((
+PTR      cmpCxtId,                
+Buffer   *mBuf,                   
+Buffer   **opSdu,                 
+Buffer   **feedback               
+));
+EXTERN S16 pjLibCmpCloseReq ARGS((
+PTR      cmpCxtId                 
+));
+EXTERN S16 pjLibCmpResetReq ARGS((
+PTR      cmpCxtId                 
+));
+EXTERN S16 pjLibCmpFbReq ARGS((
+PTR      cmpCxtId,
+Buffer   *feedback
+));
+
+#endif /* PJ_CMP_ASYNC */
+
+#ifdef PJ_SEC_ASYNC
+
+typedef S16 (*ObdIntInitCfm) ARGS((
+   Pst *                pst,
+   PjSecCxt             secCtx,
+   PTR                  ctxId));
+
+typedef S16 (*ObdCpInitCfm) ARGS((
+   Pst *                pst,
+   PjSecCxt             secCxt,
+   PTR                  ctxId));
+
+typedef S16 (*ObdUpInitCfm) ARGS((
+   Pst *                pst,
+   PjSecCxt             secCxt,
+   PTR                  ctxId));
+
+typedef S16 (*ObdIntProtCfm) ARGS((
+   Pst *                pst,
+   PTR                  cxtId,
+   PjLibTrans           libTrans,
+   U32                  macI));
+
+typedef S16 (*ObdCipherCfm) ARGS((
+   Pst *                pst,
+   PTR                  cxtId,
+   PjLibTrans           libTrans,
+   Buffer *             opSdu));
+
+typedef S16 (*ObdDecipherCfm) ARGS((
+   Pst *                pst,
+   PTR                  cxtId,
+   PjLibTrans           libTrans,
+   Buffer *             opSdu));
+
+typedef S16 (*ObdIntVerCfm) ARGS((
+   Pst *                pst,
+   PTR                  cxtId,
+   PjLibTrans           libTrans,
+   Status               status));
+
+EXTERN S16 PjLibObdIntInitCfm ARGS((
+Pst      *pst,                    /* post structure */
+PjSecCxt secCxt,                  /* Secutiry Context */
+PTR      ctxId                    /* Integrity Context ID */
+));
+EXTERN S16 PjLibObdCpInitCfm ARGS((
+Pst      *pst,                    /* post structure */
+PjSecCxt secCxt,                  /* Secutiry Context */
+PTR      ctxId                    /* Ciphering Context ID */
+));
+EXTERN S16 PjLibObdUpInitCfm ARGS((
+Pst      *pst,                    /* post structure */
+PjSecCxt secCxt,                  /* Secutiry Context */
+PTR      ctxId                    /* Ciphering Context ID */
+));
+EXTERN S16 PjLibObdIntProtCfm ARGS((
+Pst      *pst,                    /* post structure */
+PTR      cxtId,                   /* Context Id for Integrity protection*/
+PjLibTrans libTrans,              /* Transaction Id */
+U32      macI                     /* Message authentication code */
+));
+EXTERN S16 PjLibObdCipherCfm ARGS((
+Pst      *pst,                    /* post structure */
+PTR      cxtId,                   /* Context Id for Ciphering */
+PjLibTrans libTrans,              /* Transaction Id */
+Buffer   *opSdu                   /* ciphered SDU */
+));
+EXTERN S16 PjLibObdDecipherCfm ARGS((
+Pst         *pst,                 /* post structure */
+PTR         cxtId,                /* Context Id for Integrity protection*/
+PjLibTrans  libTrans,             /* Transaction Id */
+Buffer      *opPdu                /* deciphered SDU */
+));
+EXTERN S16 PjLibObdIntVerCfm ARGS((
+Pst      *pst,                    /* post structure */
+PTR      cxtId,                   /* Context Id for Integrity protection*/
+PjLibTrans libTrans,              /* Transaction Id */
+Status   status                   /* Integrity verification status */
+));
+EXTERN S16 PjLibObdIntInitReq ARGS((
+Pst * pst,
+PjSecCxt secCtx,
+PjIntInfo intInfo
+));
+EXTERN S16 PjLibObdCpInitReq ARGS((
+Pst * pst,
+PjSecCxt secCxt,
+U8 algoType,
+U8 *cpKey
+));
+EXTERN S16 PjLibObdUpInitReq ARGS((
+Pst * pst,
+PjSecCxt secCxt,
+U8 algoType,
+U8 *upKey
+));
+EXTERN S16 PjLibObdIntProtReq ARGS((
+Pst * pst,
+PTR intCxtId,
+PjSecInp secInp,
+PjLibTrans libTrans,
+Buffer ** mBuf
+));
+EXTERN S16 PjLibObdCipherReq ARGS((
+Pst * pst,
+PTR cxtId,
+PjSecInp secInp,
+PjLibTrans libTrans,
+Buffer * mBuf
+));
+EXTERN S16 PjLibObdIntVerReq ARGS((
+Pst * pst,
+PTR intCxtId,
+PjSecInp secInp,
+PjLibTrans libTrans,
+Buffer * mBuf,
+U32 macI
+));
+EXTERN S16 PjLibObdDecipherReq ARGS((
+Pst * pst,
+PTR cxtId,
+PjSecInp secInp,
+PjLibTrans libTrans,
+Buffer * mBuf
+));
+EXTERN S16 PjLibObdIntCloseReq ARGS((
+Pst * pst,
+PTR intCxtId
+));
+EXTERN S16 PjLibObdCipherCloseReq ARGS((
+Pst * pst,
+PTR cpCxtId
+));
+
+EXTERN S16 cmPkLibObdIntInitCfm ARGS((
+   Pst *                pst,
+   PjSecCxt             secCtx,
+   PTR                  ctxId
+));
+
+EXTERN S16 cmUnpkLibObdIntInitCfm ARGS((
+   ObdIntInitCfm        func,
+   Pst *                pst,
+   Buffer               *mBuf
+));
+
+EXTERN S16 cmPkLibObdCpInitCfm ARGS((
+   Pst *                pst,
+   PjSecCxt             secCxt,
+   PTR                  ctxId
+));
+
+EXTERN S16 cmUnpkLibObdCpInitCfm ARGS((
+   ObdCpInitCfm         func,
+   Pst *                pst,
+   Buffer               *mBuf
+));
+
+EXTERN S16 cmPkLibObdUpInitCfm ARGS((
+   Pst *                pst,
+   PjSecCxt             secCxt,
+   PTR                  ctxId
+));
+
+EXTERN S16 cmUnpkLibObdUpInitCfm ARGS((
+   ObdUpInitCfm         func,
+   Pst *                pst,
+   Buffer               *mBuf
+));
+
+EXTERN S16 cmPkLibObdIntProtCfm ARGS((
+   Pst *                pst,
+   PTR                  cxtId,
+   PjLibTrans           libTrans,
+   U32                  macI
+));
+
+EXTERN S16 cmUnpkLibObdIntProtCfm ARGS((
+   ObdIntProtCfm        func,
+   Pst *                pst,
+   Buffer               *mBuf
+));
+
+EXTERN S16 cmPkLibObdCipherCfm ARGS((
+   Pst *                pst,
+   PTR                  cxtId,
+   PjLibTrans           libTrans,
+   Buffer *             opSdu
+));
+
+EXTERN S16 cmUnpkLibObdCipherCfm ARGS((
+   ObdCipherCfm         func,
+   Pst *                pst,
+   Buffer               *mBuf
+));
+
+EXTERN S16 cmPkLibObdDecipherCfm ARGS((
+   Pst *                pst,
+   PTR                  cxtId,
+   PjLibTrans           libTrans,
+   Buffer *             opSdu
+));
+
+EXTERN S16 cmUnpkLibObdDecipherCfm ARGS((
+   ObdDecipherCfm       func,
+   Pst *                pst,
+   Buffer               *mBuf
+));
+
+EXTERN S16 cmPkLibObdIntVerCfm ARGS((
+   Pst *                pst,
+   PTR                  cxtId,
+   PjLibTrans           libTrans,
+   Status               status
+));
+
+EXTERN S16 cmUnpkLibObdIntVerCfm ARGS((
+   ObdIntVerCfm         func,
+   Pst *                pst,
+   Buffer               *mBuf
+));
+
+EXTERN S16 cmPkPjSecCxt ARGS((
+   PjSecCxt             *param,
+   Buffer               *mBuf
+));
+EXTERN S16 cmUnpkPjSecCxt ARGS((
+   PjSecCxt             *param,
+   Buffer               *mBuf
+));
+EXTERN S16 cmPkPjIntInfo ARGS((
+   PjIntInfo            *param,
+   Buffer               *mBuf
+));
+EXTERN S16 cmUnpkPjIntInfo ARGS((
+   PjIntInfo            *param,
+   Buffer               *mBuf
+));
+EXTERN S16 cmPkPjSecInp ARGS((
+   PjSecInp             *param,
+   Buffer               *mBuf
+));
+EXTERN S16 cmUnpkPjSecInp ARGS((
+   PjSecInp             *param,
+   Buffer               *mBuf
+));
+
+#else
+
+EXTERN S16 PjLibObdUlInitReq ARGS ((
+PjCb    *gCb
+));
+
+EXTERN S16 PjLibObdDlInitReq ARGS ((
+PjCb    *gCb
+));
+
+EXTERN S16 pjLibObdPrcKenbCfg ARGS ((
+PjCb                   *gCb,
+CpjAsKeyInfo*       kenbInf,
+CpjAskeyCfmInfo     *kdfCfm
+));
+
+EXTERN S16 pjLibObdPrcKenbStarCfg ARGS ((
+PjCb                   *gCb,
+CpjKenbStarInfo*       kenbInf,
+CpjKenbStarCfmInfo     *kdfCfm
+));
+
+#ifdef INTEL_QAT_DP
+EXTERN S16 PjLibObdDlCloseReq ARGS ((Void *));
+#else
+EXTERN S16 PjLibObdDlCloseReq ARGS ((Void));
+#endif
+
+#ifdef INTEL_QAT_DP
+EXTERN S16 PjLibObdUlCloseReq ARGS ((Void *));
+#else
+EXTERN S16 PjLibObdUlCloseReq ARGS ((Void));
+#endif
+
+EXTERN S16 PjLibObdIntInitReq ARGS ((
+PjSec *secInp
+));
+
+EXTERN Void PjUlSpaccTrigger ARGS ((Void));
+
+EXTERN Void PjDlSpaccTrigger ARGS ((Void));
+
+#ifdef INTEL_SW_INTEG
+EXTERN S16 PjLibObdIntProtReq ARGS ((
+PjCb *gCb,
+PjLibTrans  *libTrans, 
+Buffer **mBuf
+));
+#else
+EXTERN S16 PjLibObdIntProtReq ARGS ((
+PjLibTrans  *libTrans, 
+Buffer **mBuf
+));
+#endif
+
+
+
+#ifdef TENB_AS_SECURITY
+EXTERN S16 PjLibObdDlInitReq ARGS ((
+PjCb    *gCb
+));
+
+EXTERN S16 PjLibObdUlInitReq ARGS ((
+PjCb    *gCb
+));
+#ifdef INTEL_QAT_DP
+EXTERN S16 PjLibObdDlCloseReq ARGS ((Void *));
+#else
+EXTERN S16 PjLibObdDlCloseReq ARGS ((Void));
+#endif
+
+#ifdef INTEL_QAT_DP
+EXTERN S16 PjLibObdUlCloseReq ARGS ((Void *));
+#else
+EXTERN S16 PjLibObdUlCloseReq ARGS ((Void));
+#endif
+#endif
+
+#ifdef TENB_AS_SECURITY
+#ifdef INTEL_SW_INTEG
+EXTERN S16 PjLibObdIntVerReq ARGS ((
+PjCb *gCb,
+PjLibTrans  *libTrans,
+Buffer * mBuf,
+U32   macI
+));
+#else
+EXTERN S16 PjLibObdIntVerReq ARGS ((
+PjLibTrans  *libTrans,
+Buffer * mBuf,
+U32   macI
+));
+#endif
+#else
+EXTERN S16 PjLibObdIntVerReq ARGS((
+Pst * pst,
+PTR intCxtId,
+PjSecInp secInp,
+PjLibTrans libTrans,
+Buffer * mBuf,
+U32 macI
+));
+
+#endif
+
+#ifdef INTEL_QAT_DP
+EXTERN S16 PjLibObdIntCloseReq ARGS ((
+Void *instHndl,                                 /* Instance Handler */
+Void *intCxtId
+));
+#else
+EXTERN S16 PjLibObdIntCloseReq ARGS ((
+Void *intCxtId
+));
+#endif
+
+EXTERN S16 PjLibObdCpInitReq ARGS ((
+PjSec *secInp
+));
+
+EXTERN S16 PjLibObdUpInitReq ARGS ((
+PjSec *secInp
+));
+
+
+EXTERN S16 PjLibObdCipherReq ARGS ((
+PjLibTrans  *libTrans,
+Buffer      *mBuf,
+Buffer      **opSdu
+));
+
+#ifdef FLAT_BUFFER_OPT
+EXTERN S16 PjLibObdCipherReqFB ARGS ((
+PjLibTrans  *libTrans,
+FlatBuffer  *mBuf,
+Buffer      **opSdu
+));
+#endif
+
+EXTERN S16 PjLibObdDecipherReq ARGS ((
+PjLibTrans  *libTrans,
+Buffer      *mBuf,
+Buffer      **opSdu
+));
+
+#ifdef INTEL_QAT_DP
+EXTERN S16 PjLibObdCipherCloseReq ARGS ((
+Void *instHndl,                                  /* Instance Handler */
+Void *cpCxtId
+));
+#else
+EXTERN S16 PjLibObdCipherCloseReq ARGS ((
+Void *cpCxtId
+));
+#endif
+
+#ifdef INTEL_QAT_DP
+EXTERN S16 pjLibIntInitReq ARGS (( 
+PjCb  *gCb,
+PjIntInfo intInfo,                /* Integrity Cfg Info */
+Void      **cxtId                  /* FD */
+));
+#else
+EXTERN S16 pjLibIntInitReq ARGS (( 
+PjSecCxt secCxt,                  /* Context for Intg protection/verification */
+PjIntInfo intInfo,                /* Integrity Cfg Info */
+Void      **cxtId                  /* FD */
+));
+#endif
+
+#ifdef INTEL_QAT_DP
+EXTERN S16 pjLibCpInitReq ARGS ((
+PjCb     *gCb,
+PjSecCxt secCxt,                  /* Context for Intg protection/verificatino */
+U8       algoType,                /* Type of the algorithm */
+U8       *cpKey,                  /* Control plane ciphering key */
+Void     **cxtId                   /* FD */
+));
+#else
+EXTERN S16 pjLibCpInitReq ARGS ((
+PjSecCxt secCxt,                  /* Context for Intg protection/verificatino */
+U8       algoType,                /* Type of the algorithm */
+U8       *cpKey,                  /* Control plane ciphering key */
+Void     **cxtId                   /* FD */
+));
+#endif
+
+#ifdef INTEL_QAT_DP
+EXTERN S16 pjLibUpInitReq ARGS ((
+PjCb     *gCb,
+PjSecCxt secCxt,                  /* Context for Intg protection/verificatino */
+U8       algoType,                /* Type of the algorithm */
+U8       *upKey,                  /* User plane ciphering key */
+Void     **cxtId                   /* FD */
+));
+#else
+EXTERN S16 pjLibUpInitReq ARGS ((
+PjSecCxt secCxt,                  /* Context for Intg protection/verificatino */
+U8       algoType,                /* Type of the algorithm */
+U8       *upKey,                  /* User plane ciphering key */
+Void     **cxtId                   /* FD */
+));
+#endif
+EXTERN S16 pjLibDecipherReq ARGS((
+PTR         intCxtId,           /* Context Id for compression */
+PjSecInp    secInp,             /* Input for Deciphering */
+Buffer      *mBuf,              /* SDU to be deciphered */
+Buffer      **opSdu             /* deciphered SDU */
+));
+EXTERN S16 pjLibIntVerReq  ARGS((
+PTR        intCxtId,                /* Context Id for compression */
+PjSecInp   secInp,                  /* Input for Integrity protection */                  
+Buffer     *mBuf,                   /* SDU to be compressed */
+U32        macI,                    /* Message authentication code for the SDU */
+Status     *status                  /* Status of the Integrity verification */
+));
+#endif
+
+#if defined(PJ_CMP_ASYNC) || defined(PJ_SEC_ASYNC)
+EXTERN S16 cmPkPjLibTrans ARGS((
+   PjLibTrans           *param,
+   Buffer               *mBuf
+));
+EXTERN S16 cmUnpkPjLibTrans ARGS((
+   PjLibTrans           *param,
+   Buffer               *mBuf
+));
+
+#endif /* PJ_CMP_ASYNC || PJ_SEC_ASYNC */
+/* kw003.201 */
+
+/* kw004.201 Guarded under PTPJLIB */
+#ifdef PTPJLIB 
+EXTERN S16 pjLibPktAdmCtrl ARGS((
+   PjDlRbCb             *pjRbCb,  
+   Buffer               *pkt
+));
+#endif
+#if defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF)
+EXTERN S16 pjUlBatchProcSplit ARGS ((Void));
+#endif
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __PJ_LIB_X__ */
+\f  
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_lim.c b/src/5gnrpdcp/pj_lim.c
new file mode 100755 (executable)
index 0000000..8b66cc7
--- /dev/null
@@ -0,0 +1,1094 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+     Name:    LTE-PDCP Layer - Lower Interface Functions
+    
+     Type:    C file
+  
+     Desc:     Source code for PDCP Lower Interface Module.
+               This file contains following functions
+      
+                    --pjLimDatInd
+                    --pjLimDatCfm
+                    --pjLimStaInd
+
+     File:     pj_lim.c
+
+**********************************************************************/
+     
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=219;
+/** @file pj_lim.c
+@brief PDCP Lower Interface Module
+*/
+
+\f
+/* header (.h) include files */
+#include "envopt.h"             /* environment options */
+#include "envdep.h"             /* environment dependent */
+#include "envind.h"             /* environment independent */
+
+#include "gen.h"                /* general */
+#include "ssi.h"                /* system services interface */
+#include "cm5.h"                /* Timer Functions */
+#include "cm_lte.h"             /* common LTE header file */
+#include "cm_hash.h"            /* common hash module  file */
+#include "cm_llist.h"           /* common list header file */
+#include "cpj.h"                /* RRC layer */
+#include "kwu.h"
+#include "pju.h"                /* PDCP service user */
+#include "lpj.h"                /* RRC layer */
+#include "pj_env.h"             /* RLC environment options */
+#include "pj.h"                 /* RLC layer */
+#include "pj_err.h"
+
+/* header/extern include files (.x) */
+
+#include "gen.x"                /* general */
+#include "ssi.x"                /* system services interface */
+#include "cm_lib.x"             /* common library */
+#include "cm5.x"                /* Timer Functions */
+#include "cm_hash.x"            /* common hash module */
+#include "cm_lte.x"             /* common LTE file */
+#include "cm_llist.x"           /* common list header file */
+#include "kwu.x"
+#include "cpj.x"                /* RRC layer */
+#include "pju.x"                /* PDCP service user */
+#include "lpj.x"                /* LM Interface */
+#include "pj.x"                 /* RLC layer */
+#include "pj_udx.h"
+#include "pj_udx.x"
+#include "pj_ul.x" 
+#include "pj_dl.x" 
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif /* __cplusplus */
+PRIVATE S16 pjLimDiscSduCfm ARGS((PjCb *gCb, 
+                                  PjDlRbCb *pjRbCb, 
+                                  KwuDiscSduInfo *discSduCfm));
+
+/**
+ *
+ * @brief Handler for Sending sdu to Rlc.
+ *       
+ *
+ * @b Description
+ *
+ *
+ *  @param[in] pjRbCb      PDCP control block.
+ *  @param[in] sduId         PDCP SDU id.
+ *  @param[in] mBuf        Pointer to PDCP Sdu
+ *
+ * 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjDlmSendDatReq
+(
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb,
+U32        sduId,
+Buffer     *mBuf
+)
+#else
+PUBLIC S16 pjDlmSendDatReq(gCb,pjRbCb,sduId, mBuf)
+PjCb       *gCb;
+PjDlRbCb   *pjRbCb;
+U32        sduId;
+Buffer     *mBuf;
+#endif
+{
+   PjKwuSapCb     *pjSapCb;
+   KwuDatReqInfo datReq;
+   TRC2(pjDlmSendDatReq);
+
+   pjSapCb = gCb->u.dlCb->kwuSap;
+   datReq.rlcId.rbId = pjRbCb->rbId;
+   datReq.rlcId.rbType = pjRbCb->rbType;
+   datReq.rlcId.ueId   = pjRbCb->ueCb->key.ueId;
+   datReq.rlcId.cellId = pjRbCb->ueCb->key.cellId;
+#ifdef CCPU_OPT
+   datReq.lcType = (U8)((pjRbCb->rbType == CM_LTE_SRB) ?
+                     CM_LTE_LCH_DCCH : CM_LTE_LCH_DTCH);  /*KW_FIX*/
+#endif
+
+   datReq.sduId  = sduId;
+
+   RETVALUE(PjLiKwuDatReq(&(pjSapCb->pst),pjSapCb->spId, &datReq, mBuf));
+}
+
+/**
+ *
+ * @brief Handler for Discarding SDU  to Rlc.
+ *       
+ *
+ * @b Description
+ *
+ *
+ *  @param[in] pjRbCb      PDCP control block.
+ *  @param[in] sduId         PDCP SDU id.
+ *
+ * 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjDlmSendDiscSdu
+(
+PjCb    *gCb,
+PjDlRbCb  *pjRbCb,
+U32      sduId
+)
+#else
+PUBLIC S16 pjDlmSendDiscSdu(gCb,pjRbCb,sduId)
+PjCb    *gCb;
+PjDlRbCb  *pjRbCb;
+U32      sduId;
+#endif
+{
+   KwuDiscSduInfo  *discSdu;
+   PjKwuSapCb     *pjSapCb;
+   TRC2(pjDlmSendDiscSdu);
+
+   pjSapCb = gCb->u.dlCb->kwuSap;
+   KwuDiscSduInfo discSduTmp;
+   discSdu = &discSduTmp;
+
+   discSdu->rlcId.rbId = pjRbCb->rbId;
+   discSdu->rlcId.rbType = pjRbCb->rbType;
+   discSdu->rlcId.ueId   = pjRbCb->ueCb->key.ueId;
+   discSdu->rlcId.cellId = pjRbCb->ueCb->key.cellId; 
+  
+   discSdu->sduIds[0]  = sduId;
+   discSdu->numSduIds  = 1;
+
+   PjLiKwuDiscSduReq(&(pjSapCb->pst),pjSapCb->spId, discSdu);
+
+   RETVALUE(ROK);
+}
+
+
+\f
+/*****************************************************************************
+ *                          PDCP LOWER INTERFACE
+ ****************************************************************************/
+/**
+ *
+ * @brief 
+ *
+ *        Handler for getting the BndCfm from RLC.
+ *
+ * @b Description:
+ *
+ *        This function receives the PDU from RLC 
+ *        and invokes the handler for processing the PDU.
+ *
+ *  @param[in] pjRbCb    -   PDCP RB Control Block
+ *  @param[in] mBuf    -   PDU
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLiKwuBndCfm
+(
+Pst           *pst,       /* Post */
+SuId          suId,       /* Service User Id */
+U8            status     /* Status */
+)
+#else
+PUBLIC Void PjLiKwuBndCfm (pst, suId, datCfm)
+Pst           *pst;        /* Post */
+SuId          suId;        /* Service User Id */
+U8          status;     /* Status */
+#endif
+{
+   U16             event;              /* Event */
+   U16             cause;              /* Cause */
+   PjKwuSapCb      *kwuSap;            /* RGU SAP Control Block */ 
+   PjCb   *tPjCb;
+   
+   TRC1(PjLiKwuBndCfm);
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)     /* KW_FIX */
+   {
+       RETVALUE(RFAILED);
+   }
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   RLOG2(L_DEBUG, "PjLiKwuBndCfm(SuId (%d), status (%d) ",suId, status);  
+   UNUSED(pst);
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
+   {
+      /* INNC: ERROR CLASS */
+      RLOG0(L_FATAL, "General configuration not done");
+      /*PJ_SEND_SAPID_ALARM(tPjCb,suId, LPJ_EVENT_LI_BND_CFM, LPJ_CAUSE_INV_STATE);*/
+
+      RETVALUE(RFAILED);
+   }
+
+   if (suId < 0)
+   {
+      /* INNC: ERROR CLASS */
+      RLOG0(L_ERROR, "Invalid suId");
+      /*PJ_SEND_SAPID_ALARM(tPjCb,suId, LPJ_EVENT_LI_BND_CFM, LPJ_CAUSE_INV_SUID);*/
+
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      kwuSap = tPjCb->u.ulCb->kwuSap;
+   }
+   else
+   {
+      kwuSap = tPjCb->u.dlCb->kwuSap;
+   }
+
+#ifdef DEBUGP
+   RLOG1(L_DEBUG, "PjLiKwuBndCfm: For KWU SAP state=%d",
+                  kwuSap->state);
+#endif
+
+   /* Check rguSap state */
+   switch (kwuSap->state)
+   {
+      case PJ_SAP_BINDING:
+      {
+         pjStopTmr (tPjCb, (PTR)kwuSap, PJ_EVT_WAIT_KWU_BNDCFM);
+
+         kwuSap->retryCnt = 0;
+          
+         if (status == CM_BND_OK)
+         {
+            kwuSap->state = PJ_SAP_BND;
+            event = LCM_EVENT_BND_OK;
+            cause = LPJ_CAUSE_SAP_BNDENB;
+         }
+         else
+         {
+            kwuSap->state = PJ_SAP_CFG;
+            event = LCM_EVENT_BND_FAIL;
+            cause = LPJ_CAUSE_UNKNOWN;
+         }
+      }
+      break;
+     default:
+        event = LPJ_EVENT_RGU_BND_CFM;
+        cause = LCM_CAUSE_INV_STATE;
+        break;
+   }
+
+   /* Send an alarm with proper event and cause */
+ /*  PJ_SEND_SAPID_ALARM(tPjCb, suId, event, cause);*/
+#ifdef LTE_L2_MEAS
+   pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, event, cause, suId, 0,0);
+#else
+   pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, event, cause, suId, 0);
+#endif
+
+   RETVALUE(ROK);
+} /* pjLimDatInd */
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for getting the PDU from RLC.
+ *
+ * @b Description:
+ *
+ *        This function receives the PDU from RLC 
+ *        and invokes the handler for processing the PDU.
+ *
+ *  @param[in] pjRbCb    -   PDCP RB Control Block
+ *  @param[in] mBuf    -   PDU
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLiKwuDatInd
+(
+Pst           *pst,        /* Post */
+SuId          suId,        /* Service User Id */
+KwuDatIndInfo *datInd,     /* Data Indication Info */
+Buffer        *mBuf        /* Buffer */
+)
+#else
+PUBLIC Void PjLiKwuDatInd(pst, suId, datInd, mBuf)
+Pst           *pst;        /* Post */
+SuId          suId;        /* Service User Id */
+KwuDatIndInfo *datInd;     /* Data Indication Info */
+Buffer        *mBuf;       /* Buffer */
+#endif
+{
+   S16         ret;           /* Return Value */
+   PjUlRbCb     *pjRbCb;
+   PjCb   *tPjCb;
+
+   TRC1(PjLiKwuDatInd);
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)     /* KW_FIX*/
+   {
+       RETVALUE(RFAILED);
+   }
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   ret = pjDbmFetchUlRbCb (tPjCb,datInd->rlcId,&pjRbCb);
+   if (ret != ROK)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,datInd->rlcId.ueId, "CellId[%u]:UL RbId[%d] not found",
+            datInd->rlcId.cellId, datInd->rlcId.rbId);
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+  
+   pjLimDatInd(tPjCb, pjRbCb, mBuf, datInd->isOutOfSeq);  
+
+
+   RETVALUE(ROK);
+} /* pjLimDatInd */
+
+   PUBLIC int pdcpDatCfmsReceived = 0;
+/**
+ *
+ * @brief 
+ *
+ *        Handler for getting the datCfm from RLC.
+ *
+ * @b Description:
+ *
+ *        This function receives the PDU from RLC 
+ *        and invokes the handler for processing the PDU.
+ *
+ *  @param[in] pjRbCb    -   PDCP RB Control Block
+ *  @param[in] mBuf    -   PDU
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLiKwuDatCfm
+(
+Pst           *pst,       /* Post */
+SuId          suId,       /* Service User Id */
+KwuDatCfmInfo *datCfm     /* Data Confirm Info */
+)
+#else
+PUBLIC Void PjLiKwuDatCfm(pst, suId, datCfm)
+Pst           *pst;        /* Post */
+SuId          suId;        /* Service User Id */
+KwuDatCfmInfo *datCfm;     /* Data Confirm Info */
+#endif
+{
+   S16         ret;           /* Return Value */
+   PjDlRbCb     *pjRbCb;      
+   PjDatCfm   pjCfm;
+   PjCb   *tPjCb;
+
+   TRC1(PjLiKwuDatCfm);
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)    /* KW_FIX */
+   {
+       RETVALUE(RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   RLOG2(L_DEBUG, "PjLiKwuDatCfm(rbId(%d),rbType (%d), mBuf)",
+                    datCfm->rlcId.rbId,datCfm->rlcId.rbType);
+
+   ret = pjDbmFetchDlRbCb (tPjCb,datCfm->rlcId,&pjRbCb);
+   if (ret != ROK)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,datCfm->rlcId.ueId, "CellId[%u]:DL RbId[%d] not found",
+            datCfm->rlcId.cellId, datCfm->rlcId.rbId);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datCfm, sizeof(KwuDatCfmInfo));
+      RETVALUE(RFAILED);
+   }
+
+   pdcpDatCfmsReceived++; 
+
+   pjCfm.rlcId = datCfm->rlcId;
+   pjCfm.numSdu = (U16)(datCfm->numSduIds); /*KW_FIX*/
+   cmMemcpy((U8*)pjCfm.sduId, (U8*)datCfm->sduIds, sizeof(U32)*datCfm->numSduIds);
+   pjLimDatCfm (tPjCb, pjRbCb, &pjCfm);
+
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datCfm, sizeof(KwuDatCfmInfo));
+   RETVALUE(ROK);
+} /* pjLimDatInd */
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for flow control indication from RLC.
+ *
+ * @b Description:
+ *
+ *        TODO
+ *
+ *  @param[in] pst           - Pointer to post structure
+ *  @param[in] suId          - Service user Id
+ *  @param[in] flowCntrlInfo - Flow control information
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLiKwuFlowCntrlInd
+(
+Pst           *pst,       
+SuId          suId,       
+KwuFlowCntrlIndInfo *flowCntrlInfo
+)
+#else
+PUBLIC Void PjLiKwuFlowCntrlInd(pst, suId, flowCntrlInfo)
+Pst           *pst;       
+SuId          suId;       
+KwuFlowCntrlIndInfo *flowCntrlInfo;
+#endif
+{
+   S16        ret;       
+   PjDlRbCb   *pjRbCb;      
+   PjCb       *tPjCb;
+
+   TRC1(PjLiKwuFlowCntrlInd);
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+       RETVALUE(RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   RLOG2(L_DEBUG, "PjLiKwuFlowCntrlInd(rbId(%d),rbType (%d), mBuf)",
+                     flowCntrlInfo->rlcId.rbId,flowCntrlInfo->rlcId.rbType);
+
+   ret = pjDbmFetchDlRbCb (tPjCb,flowCntrlInfo->rlcId,&pjRbCb);
+   if (ret != ROK)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,flowCntrlInfo->rlcId.ueId, "CellId[%u]:DL RbId[%d] not found",
+            flowCntrlInfo->rlcId.cellId, flowCntrlInfo->rlcId.rbId);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, flowCntrlInfo, sizeof(KwuFlowCntrlIndInfo));
+      RETVALUE(RFAILED);
+   }
+
+   /* if RLC is requesting to stop the flow means RB is overloaded */
+   if (flowCntrlInfo->pktAdmitCnt) 
+   {
+      if (pjRbCb->mode == PJ_DRB_AM)
+      {
+         pjRbCb->dropOnlyOne = 1;
+         pjRbCb->pktAdmitCnt= 0;
+      }
+      else
+      {
+         pjRbCb->dropOnlyOne = 0;
+         pjRbCb->pktAdmitCnt = flowCntrlInfo->pktAdmitCnt;
+      }
+   }
+   else
+   {
+      /*  flowCntrlInfo->pktAdmitCnt = 0 indicates PDB Recovered and no FC required
+       *  reset FC state  */
+      pjRbCb->dropOnlyOne = 0;
+      pjRbCb->pktAdmitCnt = 0;
+   }
+   pjRbCb->pktCnt = 0;
+
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, flowCntrlInfo, sizeof(KwuFlowCntrlIndInfo));
+   RETVALUE(ROK);
+} /* PjLiKwuFlowCntrlInd */
+/**
+ *
+ * @brief 
+ *
+ *        Handler for getting the Status Ind from RLC.
+ *
+ * @b Description:
+ *
+ *        This function receives the PDU from RLC 
+ *        and invokes the handler for processing the PDU.
+ *
+ *  @param[in] pjRbCb    -   PDCP RB Control Block
+ *  @param[in] mBuf    -   PDU
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLiKwuStaInd
+(
+Pst           *pst,       /* Post */
+SuId          suId,       /* Service User Id */
+KwuStaIndInfo *staInd     /* StatusIndication Info */
+)
+#else
+PUBLIC Void PjLiKwuStaInd(pst, suId, datCfm)
+Pst           *pst;        /* Post */
+SuId          suId;        /* Service User Id */
+KwuStaIndInfo *staInd;     /* Status Indication Info */
+#endif
+{
+   S16         ret;           /* Return Value */
+   PjDlRbCb     *pjRbCb;
+   PjCb   *tPjCb;
+   U32 minSduCnt;
+
+   TRC1(PjLiKwuStaInd);
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   if ((pst->dstInst >= PJ_MAX_PDCP_INSTANCES) || (tPjCb->init.cfgDone == FALSE))
+   {
+       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staInd, sizeof(KwuStaIndInfo));
+       RETVALUE(RFAILED);
+   }
+
+
+   RLOG2(L_DEBUG, "PjLiKwuStaInd(rbId(%d),rbType (%d), mBuf)",
+                         staInd->rlcId.rbId,staInd->rlcId.rbType);
+
+   ret = pjDbmFetchDlRbCb (tPjCb,staInd->rlcId,&pjRbCb);
+   if (ret != ROK)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,staInd->rlcId.ueId, "CellId[%u]:DL RbId[%d] not found",
+            staInd->rlcId.cellId, staInd->rlcId.rbId);
+/* To confirm :: BRDCM team */
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staInd, sizeof(KwuStaIndInfo));
+      RETVALUE(RFAILED);
+  }
+  minSduCnt = (KWU_MAX_STA_IND_SDU < PJ_MAX_DAT_CFM)?KWU_MAX_STA_IND_SDU:PJ_MAX_DAT_CFM;
+  if(staInd->numSdu > minSduCnt)
+  {
+          staInd->numSdu = (U16)minSduCnt;    /*KW_FIX*/
+          RLOG_ARG2(L_ERROR, DBG_RBID , pjRbCb->rbId , "numSdu [%u] in StaInd is more than acceptable limit [%lu]",
+              staInd->numSdu , minSduCnt);
+  }
+  pjLimStaInd(tPjCb, pjRbCb, (PjDatCfm *) staInd);
+/* To confirm :: BRDCM team */
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staInd, sizeof(KwuStaIndInfo));
+   RETVALUE(ROK);
+} /* pjLimKwuStaInd */
+
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for getting the ReEstablish Ind from RLC.
+ *
+ * @b Description:
+ *
+ *        This function receives the PDU from RLC 
+ *        and invokes the handler for processing the PDU.
+ *
+ *  @param[in] pjRbCb    -   PDCP RB Control Block
+ *  @param[in] mBuf    -   PDU
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLiKwuReEstCmpInd
+(
+Pst           *pst,       /* Post */
+SuId          suId,       /* Service User Id */
+CmLteRlcId    rlcId       /* RlcId */
+)
+#else
+PUBLIC Void PjLiKwuReEstCmpInd(pst, suId, rlcId)
+Pst           *pst;        /* Post */
+SuId          suId;        /* Service User Id */
+CmLteRlcId    rlcId;       /* RlcId */
+#endif
+{
+   S16        ret;           /* Return Value */
+   PjUlRbCb   *ulRbCb;
+   PjCb   *tPjCb;
+
+   TRC1(PjLiKwuReEstCmpInd);
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   if ((pst->dstInst >= PJ_MAX_PDCP_INSTANCES) || (tPjCb->init.cfgDone == FALSE))
+   {
+       RETVALUE(RFAILED);
+   }
+
+
+   RLOG2(L_DEBUG, "PjLiKwuReEstCmpInd(rbId(%d),rbType (%d), mBuf)",
+                         rlcId.rbId,rlcId.rbType);
+
+   ret = pjDbmFetchUlRbCb (tPjCb,rlcId,&ulRbCb);
+   if (ret != ROK)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:UL RbId[%d] not found",
+            rlcId.cellId, rlcId.rbId);
+      RETVALUE(RFAILED);
+   }
+   pjUlmReEstCmpInd(tPjCb,ulRbCb);
+
+   RETVALUE(ROK);
+} /* pjLimDatInd */
+
+#ifdef LTE_L2_MEAS
+/**
+ *
+ * @brief 
+ *
+ *        Handler for getting the Ack Ind from RLC.
+ *
+ * @b Description:
+ *
+ *        This function receives the PDU from RLC 
+ *        and invokes the handler for processing the PDU.
+ *
+ *  @param[in] pjRbCb    -   PDCP RB Control Block
+ *  @param[in] mBuf    -   PDU
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLiKwuDatAckInd
+(
+Pst           *pst,       /* Post */
+SuId           suId,      /* Service User Id */
+KwuDatAckInfo *ackInfo    /* Data Ack  Info */
+)
+#else
+PUBLIC Void PjLiKwuDatAckInd(pst, suId, datCfm)
+Pst           *pst;        /* Post */
+SuId          suId;        /* Service User Id */
+KwuDatAckInfo *ackInfo;    /* Data Ack Info */
+#endif
+{
+   RETVALUE(ROK);
+} /* pjLimDatInd */
+#endif
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for getting the DiscSdu Cfm from RLC.
+ *
+ * @b Description:
+ *
+ *        This function receives the PDU from RLC 
+ *        and invokes the handler for processing the PDU.
+ *
+ *  @param[in] pjRbCb    -   PDCP RB Control Block
+ *  @param[in] mBuf    -   PDU
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLiKwuDiscSduCfm
+(
+Pst           *pst,       /* Post */
+SuId           suId,      /* Service User Id */
+KwuDiscSduInfo *discInfo    /* Data Ack  Info */
+)
+#else
+PUBLIC Void PjLiKwuDiscSduCfm(pst, suId, discInfo)
+Pst           *pst;        /* Post */
+SuId          suId;        /* Service User Id */
+KwuDiscSduInfo *discInfo;    /* Data Ack Info */
+#endif
+{
+   S16         ret;           /* Return Value */
+   PjDlRbCb     *pjRbCb;
+   PjCb   *tPjCb;
+
+   TRC1(PjLiKwuDiscSduCfm);
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+
+   RLOG2(L_DEBUG, "PjLiKwuDiscSduCfm (rbId(%d),rbType (%d), mBuf)",
+                      discInfo->rlcId.rbId,discInfo->rlcId.rbType);
+
+   ret = pjDbmFetchDlRbCb (tPjCb,discInfo->rlcId,&pjRbCb);
+   if (ret != ROK)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,discInfo->rlcId.ueId, "CellId[%u]:DL RbId[%d] not found",
+            discInfo->rlcId.cellId, discInfo->rlcId.rbId);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, discInfo, sizeof(KwuDiscSduInfo));
+      RETVALUE(RFAILED);
+  }
+
+   pjLimDiscSduCfm(tPjCb, pjRbCb, discInfo);
+
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, discInfo, sizeof(KwuDiscSduInfo));
+
+   RETVALUE(ROK);
+} /* pjLimDatInd */
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler for getting the PDU from RLC.
+ *
+ * @b Description:
+ *
+ *        This function receives the PDU from RLC 
+ *        and invokes the handler for processing the PDU.
+ *
+ *  @param[in] pjRbCb    -   PDCP RB Control Block
+ *  @param[in] mBuf    -   PDU
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC Void pjLimDatInd
+(
+PjCb          *gCb,
+PjUlRbCb        *pjRbCb,        /* RB Control Block */
+Buffer        *mBuf,           /* RLC PDU */
+Bool          isOutOfSeq
+)
+#else
+PUBLIC Void pjLimDatInd(gCb, pjRbCb, mBuf, isOutOfSeq)
+PjCb          *gCb;
+PjUlRbCb      *pjRbCb;        /* RB Control Block */
+Buffer        *mBuf;          /* RLC PDU */
+Bool           isOutOfSeq;
+#endif
+{
+#if (ERRCLASS & ERRCLS_DEBUG)
+   S16         ret;           /* Return Value */
+#endif
+
+   TRC3(pjLimDatInd);
+
+   PJ_STS_INC_GEN_CNT(gCb, rxPdus);
+
+   /* Extract the header */
+   if(pjRbCb->rbType == PJ_SRB)
+   {
+      if((pjRbCb->rbId == 1) || (pjRbCb->ueCb->libInfo.state == PJ_STATE_NORMAL))
+      {
+#if (ERRCLASS & ERRCLS_DEBUG)
+         ret = pjUlmHdlSrbPkt(gCb, pjRbCb, mBuf);
+#else
+         pjUlmHdlSrbPkt(gCb, pjRbCb, mBuf);
+#endif
+      }
+      else
+      {
+         /* in reestablishment state */
+         PJ_FREE_BUF(mBuf);
+      }
+   }
+   else if(pjRbCb->rbType == PJ_DRB)
+   {
+#if (ERRCLASS & ERRCLS_DEBUG)
+      ret = pjUlmHdlDrbPkt(gCb, pjRbCb, mBuf, isOutOfSeq);
+#else
+      pjUlmHdlDrbPkt(gCb, pjRbCb, mBuf, isOutOfSeq);
+#endif
+   }
+
+#if (ERRCLASS & ERRCLS_DEBUG)
+   if (ret != ROK)
+   {
+      RLOG_ARG0(L_ERROR, DBG_RBID,pjRbCb->rbId, "pjLimDatInd: pjHdlProcessPdu Failed");
+   }
+#endif
+
+   RETVOID;
+} /* pjLimDatInd */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler for getting the Data Cfm from RLC.
+ *
+ * @b Description:
+ *
+ *        This function receives the Data Cfm from RLC 
+ *        and invokes the handler for processing it.
+ *
+ *  @param[in] pjRbCb    -   PDCP RB Control Block
+ *  @param[in] datCfm    -   Data Confirmation Information 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC Void pjLimDatCfm
+(
+PjCb          *gCb,
+PjDlRbCb        *pjRbCb,     /* RB Control Block */
+PjDatCfm      *datCfm      /* Data Confirmation Information */
+)
+#else
+PUBLIC Void pjLimDatCfm(gCb, pjRbCb, datCfm)
+PjCb          *gCb;
+PjDlRbCb        *pjRbCb;     /* RB Control Block */
+PjDatCfm      *datCfm;     /* Data Confirmation Information */
+#endif
+{
+#if (ERRCLASS & ERRCLS_DEBUG)
+   S16         ret = ROK;  /* Return Value */
+#endif
+
+   TRC3(pjLimDatCfm);
+
+
+   /* Process the PDU */
+#if (ERRCLASS & ERRCLS_DEBUG)
+   ret = pjDlmProcessCfm(gCb, pjRbCb, datCfm, PJ_CFM_OK);
+   if (ret != ROK)
+   {
+      RLOG_ARG0(L_ERROR, DBG_RBID,pjRbCb->rbId, "pjLimDatCfm: pjDlmProcessCfm Failed");
+   }
+#else
+   pjDlmProcessCfm(gCb, pjRbCb, datCfm, PJ_CFM_OK);
+#endif
+   /* pj002.201 : Removed freeing and allocation of datCfm */
+   RETVOID;
+} /* pjLimDatCfm */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler for trigerring the error indication when RLC times out
+ *        for sending AM data.
+ *
+ * @b Description:
+ *
+ *        This function receives the pduIds of the PDU that were not
+ *        successfully sent to the layer.
+ *
+ *  @param[in] pjRbCb  -   PDCP RB Control Block
+ *  @param[in] staInd  -   Status Indication Information.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC Void pjLimStaInd
+(
+PjCb         *gCb,
+PjDlRbCb       *pjRbCb,            /* PDCP RB Control Block */
+PjDatCfm     *staInd             /* Status Indication Information */
+)
+#else
+PUBLIC Void pjLimStaInd(gCb, pjRbCb, staInd)
+PjCb         *gCb;
+PjDlRbCb       *pjRbCb;           /* PDCP RB control Block */
+PjDatCfm     *staInd;           /* Status Indication Information */
+#endif
+{
+#if (ERRCLASS & ERRCLS_DEBUG)
+   S16         ret = ROK;       /* Return Value */
+#endif
+
+   TRC3(pjLimStaInd)
+
+   if (gCb->init.cfgDone == FALSE)
+   {
+      RETVOID;
+   }
+   RLOG1(L_DEBUG, "pjLimStaInd(pjRbCb(%d), staInd)", pjRbCb->rbId);
+
+   /* Call the confirm code */
+#if (ERRCLASS & ERRCLS_DEBUG)
+   ret = pjDlmProcessCfm(gCb, pjRbCb, staInd, PJ_CFM_NOK);
+   if (ret != ROK)
+   {
+      RLOG_ARG0(L_ERROR, DBG_RBID,pjRbCb->rbId, "pjLimStaInd: pjDlmProcessCfm Failed");
+   }
+#else
+   pjDlmProcessCfm(gCb, pjRbCb, staInd, PJ_CFM_NOK);
+#endif
+   /* pj002.201 : Removed freeing and allocation of staInd */
+   RETVOID;
+} /* pjLimStaInd */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler for informing the PDCP that RLC has successfully discarded
+ *        certain PDUs.
+ *
+ * @b Description:
+ *
+ *        This function receives the pointer to the PDCP control block of the
+ *        RB that has finished transmitting its data to PDCP.
+ *
+ *  @param[in] pjRbCb       -   PDCP RB Control Block
+ *  @param[in] discSduCfm   -   Info about the discarded SDUs
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PRIVATE S16 pjLimDiscSduCfm
+(
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb,        /* PDCP RB Control Block */
+KwuDiscSduInfo *discSduCfm /* Info about the discarded SDUs*/
+)
+#else
+PRIVATE S16 pjLimDiscSduCfm(gCb, pjRbCb, count)
+PjCb       *gCb;
+PjDlRbCb   *pjRbCb;         /* PDCP RB control Block */
+KwuDiscSduInfo *discSduCfm; /* Info about the discarded SDUs*/
+#endif
+{
+   PjuDatCfmInfo datCfm;       /* DatCfm structure */
+   CmLtePdcpId   pdcpId;       /* PDCP ID */
+   PjTxEnt       *txEnt;        /* Transmission Entity */
+   U32           count = 0;
+   U16           cfmsToUpperLayer = 0;    /*KW_FIX*/
+
+   TRC3(pjLimDiscSduCfm);
+
+   RLOG1(L_DEBUG, "pjLimDiscSduCfm(pjRbCb(%d))", pjRbCb->rbId);
+
+   if((gCb->init.cfgDone == FALSE) || (discSduCfm->numSduIds == 0))
+   {
+      RETVALUE(ROK);
+   }
+   
+   while(count < discSduCfm->numSduIds)
+   {
+      txEnt = pjDbmGetTxEnt(gCb, &(pjRbCb->dlCb.txBuf), discSduCfm->sduIds[count]); 
+
+      if(txEnt != NULLP)
+      {
+         if( pjRbCb->dlCb.cfmReqd)
+         {
+            datCfm.cfmSta[cfmsToUpperLayer].sduId  = txEnt->sduId;
+            datCfm.cfmSta[cfmsToUpperLayer++].status = PJU_DISCARD_TMR_EXP;
+         }
+
+         if( txEnt->pdu == txEnt->sdu )
+         {
+            txEnt->sdu = NULLP;
+         }
+
+         /* if the PDU being discarded was a one for which confirm was expected
+            then we need to set the confirm expectation correctly */
+
+         if(pjRbCb->dlCb.cfmExp < txEnt->count)
+         {
+            /* need to check if count should be just incremented by one or should the txHfn
+               also need to be considered */
+            pjRbCb->dlCb.cfmExp = txEnt->count + 1;
+         }
+         
+         pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count);
+
+#ifdef LTE_L2_MEAS 
+         PJ_UPD_L2_DLDISC_STS(gCb,pjRbCb);
+#endif
+      }
+
+      count++;
+   }
+
+   if(pjRbCb->dlCb.cfmReqd)
+   {
+      PjPjuSapCb    *pjuSap;       /* PJU SAP */
+
+      datCfm.numSdus = cfmsToUpperLayer;
+
+      pdcpId.rbId   = pjRbCb->rbId;
+      pdcpId.rbType = pjRbCb->rbType;
+      pdcpId.ueId   = pjRbCb->ueCb->key.ueId;
+      pdcpId.cellId = pjRbCb->ueCb->key.cellId;
+
+      if (pjRbCb->rbType == PJ_SRB)
+      {
+         pjuSap = &(gCb->u.dlCb->pjuSap[PJ_SRB_SAP]);
+      }
+      else
+      {
+         pjuSap = &(gCb->u.dlCb->pjuSap[PJ_DRB_SAP]);
+      }
+
+      /* If trace flag is enabled send the trace indication */
+      if(gCb->init.trc == TRUE)
+      {
+         /* Populate the trace params */
+         pjLmmSendTrc(gCb, EVTPJUDATCFM, NULLP);
+      }
+
+      PjUiPjuDatCfm(&pjuSap->pst, pjuSap->suId, &pdcpId, &datCfm);
+   }
+
+
+   RETVALUE(ROK);
+} /* pjLimDiscSduCfm */
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_lmm.c b/src/5gnrpdcp/pj_lmm.c
new file mode 100755 (executable)
index 0000000..4ddbb07
--- /dev/null
@@ -0,0 +1,2975 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+
+        Name:    LTE - PDCP - Layer Manager file
+
+        Type:    C source file
+
+        Desc:    It contains the following common  functions for processing
+                 the all the external interfaces.
+                    -- PjMiLpjCfgReq
+                    -- PjMiLpjCfgCfm 
+                    -- PjMiLpjCntrlReq
+                    -- PjMiLpjCntrlCfm
+                    -- PjMiLpjStaReq
+                    -- PjMiLpjStaCfm
+                    -- PjMiLpjStaInd
+                    -- PjMiLpjStsReq
+                    -- PjMiLpjStsCfm
+                    -- PjMiLpjTrcInd 
+
+        File:     pj_lmm.c
+
+*********************************************************************21*/
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_FILE_ID=135;
+static int RLOG_MODULE_ID=1024;
+
+/** @file pj_lmm.c
+@brief PDCP Layer Manager Module
+**/
+
+\f
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "kwu.h"
+#include "lpj.h"           /* LPJ defines */
+#include "cpj.h"           /* CPJ defines */
+#include "pju.h"           /* PJU defines */
+#include "lpj.h"           
+#include "pj_err.h"        /* Err defines */
+#include "pj_env.h"        /* PDCP environment options */
+#include "pj.h"            /* PDCP defines */
+#include "pj_udx.h"
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "kwu.x"
+#include "lpj.x"           /* LPJ */
+#include "cpj.x"           /* CPJ */
+#include "pju.x"           /* PJU */
+
+#include "pj.x"
+#include "pj_udx.h"
+#include "pj_udx.x"
+#include "pj_ul.x"
+#include "pj_dl.x"
+#include "pj_lib.x"
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif /* CPLUSPLUS */
+
+EXTERN S16 pjGetSId ARGS((SystemId *s));
+#ifdef __cplusplus
+}
+#endif /* CPLUSPLUS */
+
+U8 *gPoolId; 
+PDCPStats gPdcpStats;
+
+#ifdef TENB_AS_SECURITY
+U8 isSecBatchMode;
+#endif
+
+\f
+/*********************************************************************
+ *             Forward Declaration of LPJ Porting Functions
+ ********************************************************************/
+PUBLIC PjCb  *pjCb[PJ_MAX_PDCP_INSTANCES];
+EXTERN S16 pjActvTmr ARGS ((Ent ent, Inst inst));
+
+PRIVATE S16 pjLmmSendCfm ARGS ((Pst *pst,PjMngmt *cfm,U8 type,Header *hdr));
+PRIVATE S16 pjLmmGenCfg ARGS ((PjCb *gCb,PjGenCfg *cfg));
+PRIVATE S16 pjLmmPjuSapCfg ARGS ((PjCb *gCb,PjSapCfg *cfg));
+PRIVATE S16 pjLmmKwuSapCfg ARGS ((PjCb *gCb,PjSapCfg *cfg));
+PRIVATE S16 pjLmmUdxSapCfg ARGS ((PjCb *gCb,PjSapCfg *cfg));
+PRIVATE S16 pjLmmCpjSapCfg ARGS ((PjCb *gCb,PjSapCfg   *cfg));
+PRIVATE S16 pjLmmGenCntrl ARGS ((PjCb *gCb,PjMngmt *cntrl));
+PRIVATE S16 pjLmmUdxSapCntrl ARGS ((PjCb *gCb,PjMngmt *cntrl));
+PRIVATE S16 pjLmmLSapCntrl ARGS ((PjCb *gCb,PjMngmt *cntrl));
+PRIVATE S16 pjLmmFormLmCfm ARGS ((Pst *pst, Header *hdr, Reason reason));
+PRIVATE S16 pjLmmGetPjuSapSta ARGS ((PjCb *gCb,PjPjuSapSta *sta));
+PRIVATE S16 pjLmmGetKwuSapSta ARGS ((PjCb *gCb,PjKwuSapSta *sta));
+PRIVATE S16 pjLmmGetUdxSapSta ARGS ((PjCb *gCb,PjUdxSapSta *sta));
+PRIVATE S16 pjLmmGetCpjSapSta ARGS ((PjCb *gCb,PjCpjSapSta *sta));
+PRIVATE S16 pjLmmGetGenSts ARGS ((PjCb *gCb,PjGenSts *sts,Action action));
+PRIVATE S16 pjLmmGetSapSts ARGS ((PjCb *gCb,PjMngmt *sts,Elmnt elmnt,Action action));
+PRIVATE Void pjLmmCleanGblRsrcs ARGS ((PjCb *gCb));
+\f
+/*********************************************************************
+ *             Primitives for LPJ interface 
+ ********************************************************************/
+/**
+ * @brief
+      Stores the general PDCP configuration. It calculates the
+      memory requirement and reserves it. It also initializes the
+      control blocks, the hash lists and registers the timers. In
+      case of error it rolls back and reports error in the confirm.
+      If the general configuration is already done it is treated as
+      reconfiguration, but right now reconfiguration is not supported.
+ *  @param[in] cfm         PDCP LM general config structure
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL 
+ *      -# Failure : LCM_REASON_MEM_NOAVAIL
+ *                   LCM_REASON_REGTMR_FAIL
+ *                   LCM_REASON_INVALID_PAR_VAL
+ *                   LCM_REASON_HASHING_FAILED
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmGenCfg
+(
+PjCb        *gCb,
+PjGenCfg    *cfg
+)
+#else
+PRIVATE S16 pjLmmGenCfg(gCb, cfg)
+PjCb        *gCb;
+PjGenCfg    *cfg;
+#endif
+{
+   Size       pjMemSize;
+   CmTqCp     *pjTqCp;
+   U16        cnt;
+   S16        ret;
+
+   TRC2(pjLmmGenCfg)
+
+   ret       =   ROK;
+   pjMemSize =   0;
+
+   if(cfg->maxUe > PJ_MAX_UE) 
+   {
+#if (ERRCLASS & ERRCLS_INT_PAR)
+      RLOG2(L_ERROR, "Invalid maxUe : Max [%lu] Received [%lu]", 
+                        PJ_MAX_UE, cfg->maxUe);
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }
+
+   if(cfg->maxPjuSaps > PJ_MAX_PJUSAPS)
+   {
+#if (ERRCLASS & ERRCLS_INT_PAR)
+      RLOG2(L_ERROR, "Invalid maxPjuSaps : Max [%lu] Received [%lu]", 
+                       PJ_MAX_PJUSAPS, cfg->maxPjuSaps);
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }
+
+   if(cfg->maxKwuSaps > PJ_MAX_KWUSAPS)
+   {
+#if (ERRCLASS & ERRCLS_INT_PAR)
+      RLOG2(L_ERROR, "Invalid maxKwuSaps : Max [%lu] Received [%lu]", 
+                        PJ_MAX_KWUSAPS, cfg->maxKwuSaps);
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }
+
+   if(cfg->maxUdxSaps > PJ_MAX_UDXSAPS)
+   {
+#if (ERRCLASS & ERRCLS_INT_PAR)
+      RLOG2(L_ERROR, "Invalid maxUduSaps : Max [%lu] Received [%lu]", 
+                       PJ_MAX_UDXSAPS, cfg->maxUdxSaps);
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }   
+
+   if(gCb->init.cfgDone & PJ_LMM_GENCFG_DONE)
+   {
+      /* reconfiguration is supported only for obdDiscTmrInt */
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+      gCb->pjGenCfg.obdTmrInt = cfg->obdTmrInt;
+      gCb->pjGenCfg.obdWtTmrInt = cfg->obdWtTmrInt;
+#endif /* PJ_SEC_ASYNC || PJ_CMP_ASYNC */
+      RETVALUE(LCM_REASON_NOT_APPL);
+   }
+
+   PJ_MEM_CPY(&(gCb->pjGenCfg), cfg, sizeof(PjGenCfg));
+#ifdef TENB_AS_SECURITY
+   isSecBatchMode = TRUE;
+   /* Rangeley Fix */
+#ifdef INTEL_SW_SEC
+   isSecBatchMode = FALSE;
+#endif
+
+#endif
+
+   /* Timer Queue Control point initialization */
+   pjTqCp         = &(gCb->pjTqCp);
+   pjTqCp->tmrLen = PJ_TMR_LEN;
+   pjTqCp->nxtEnt = 0;
+
+   /* calculate the memory requirements */
+   pjMemSize += (Size)SBUFSIZE(PJ_UE_LIST_BUCKET_SIZE * sizeof(CmListEnt));
+
+   /* Cell Hash List Size */
+   pjMemSize += (Size)SBUFSIZE(PJ_CELL_LIST_BUCKET_SIZE * sizeof(CmListEnt));
+
+   /* Reserve the memory */
+   if(SGetSMem(PJ_GET_MEM_REGION(gCb), pjMemSize,
+              PJ_GET_MEM_POOL_ADDRESS(gCb)) != ROK)
+   {
+      RETVALUE(LCM_REASON_MEM_NOAVAIL);
+   }
+   cmMemset((U8 *)&gCb->pjTq, 0, sizeof(CmTqType)*PJ_TMR_LEN);
+   cmMemset((U8 *)&gCb->pjTqCp, 0, sizeof(CmTqCp));
+   gCb->pjTqCp.tmrLen = PJ_TMR_LEN;
+   /* Register the timer */
+   if(SRegTmrMt(gCb->init.ent, gCb->init.inst, (U16)cfg->timeRes,
+              pjActvTmr) != ROK)
+   {
+      (Void) SPutSMem(PJ_GET_MEM_REGION(gCb), PJ_GET_MEM_POOL(gCb));
+
+      RETVALUE(LCM_REASON_REGTMR_FAIL);
+   }
+
+   /* Timer Initialization  */
+   gCb->pjTqCp.tmrLen = PJ_TMR_LEN;
+   for(cnt = 0; cnt < PJ_TMR_LEN; cnt++)
+   {
+      gCb->pjTq[cnt].first = NULLP;
+      gCb->pjTq[cnt].tail = NULLP;
+   }
+
+
+   if (cfg->mode == LPJ_MODE_PDCP_UL)
+   {
+      PJ_ALLOC(gCb, gCb->u.ulCb, sizeof(PjUlgCb)); 
+      if (gCb->u.ulCb == NULLP)
+      {  
+        RLOG0(L_FATAL, "Memory Allocation failed.");
+        /* Do clean up */
+        RETVALUE(RFAILED);
+      }
+      
+      /* Initialize the Ue and Cell hash list */
+      ret = pjDbmUlInit(gCb); /*How would DbmDlInit be called? */
+      if (ret != ROK)
+      {
+         /* Do Clean up */
+         RETVALUE(LCM_REASON_HASHING_FAILED);
+      }
+    
+      /* Initialize the PJU SAP control blocks */
+      PJ_MEM_SET(&(gCb->u.ulCb->pjuSap[PJ_SRB_SAP]), 0, sizeof(PjPjuSapCb));
+      PJ_MEM_SET(&(gCb->u.ulCb->pjuSap[PJ_DRB_SAP]), 0, sizeof(PjPjuSapCb));
+
+      /* Initialize the KWU SAP Control blocks */
+      PJ_MEM_SET(&(gCb->u.ulCb->kwuSap), 0, (PJ_MAX_KWUSAPS * sizeof(PjPjuSapCb)));
+      PJ_MEM_SET(&(gCb->u.ulCb->udxUlSap), 0, (PJ_MAX_UDXSAPS * sizeof(PjUdxUlSapCb)));
+
+      /* Initialize CPJ SAP control block */
+      PJ_MEM_SET(&(gCb->u.ulCb->cpjSap), 0, sizeof(PjCpjSapCb)); 
+#ifdef LTE_L2_MEAS
+      pjUtlL2MeasUlInit(gCb);
+#endif
+   }
+   else
+   {
+      PJ_ALLOC(gCb, gCb->u.dlCb, sizeof(PjDlgCb)); 
+      if (gCb->u.dlCb == NULLP)
+      {
+        RLOG0(L_FATAL, "Memory Allocation failed.");
+        /* Do clean up */
+        RETVALUE(RFAILED);
+      }
+      
+      /* Initialize the Ue and Cell hash list */
+      ret = pjDbmDlInit(gCb);
+      if (ret != ROK)
+      {
+         RETVALUE(LCM_REASON_HASHING_FAILED);
+      }
+    
+
+      /* Initialize the PJU SAP control blocks */
+      PJ_MEM_SET(&(gCb->u.dlCb->pjuSap[PJ_SRB_SAP]), 0, sizeof(PjPjuSapCb));
+      PJ_MEM_SET(&(gCb->u.dlCb->pjuSap[PJ_DRB_SAP]), 0, sizeof(PjPjuSapCb));
+
+      /* Initialize the KWU SAP Control blocks */
+      PJ_MEM_SET(&(gCb->u.dlCb->kwuSap), 0, (PJ_MAX_KWUSAPS * sizeof(PjPjuSapCb)));
+      PJ_MEM_SET(&(gCb->u.dlCb->udxDlSap), 0, (PJ_MAX_UDXSAPS * sizeof(PjUdxDlSapCb)));
+#ifdef LTE_L2_MEAS
+      pjUtlL2MeasDlInit(gCb);
+#endif
+   }
+
+   PJ_MEM_CPY(&(gCb->init.lmPst), &cfg->lmPst,
+                      sizeof(Pst));
+
+   gCb->init.lmPst.srcProcId = gCb->init.procId;
+   gCb->init.lmPst.srcEnt = gCb->init.ent;
+   gCb->init.lmPst.srcInst = gCb->init.inst;
+   gCb->init.lmPst.event = EVTNONE;
+
+   /* pj002.201 For multi core and multi region, no need to reinitiailize the region again .
+      This would be done with pjActvInit from SSI */
+#if !defined(SS_MULTICORE_SUPPORT) && !defined(SS_M_PROTO_REGION)
+   gCb->init.region = cfg->lmPst.region;
+#endif
+   gCb->init.pool   = cfg->lmPst.pool;
+
+   gCb->init.cfgDone |= PJ_LMM_GENCFG_DONE;
+
+   gPoolId = &(gCb->u.dlCb->kwuSap->pst.pool);
+
+#ifdef TENB_AS_SECURITY
+   /* Initialize UL fd for interfacing with SPAcc */
+   if (cfg->mode == LPJ_MODE_PDCP_UL)
+   {
+      if(PjLibObdUlInitReq(gCb) != ROK)
+      {
+         RETVALUE(LCM_REASON_MISC_FAILURE);
+      }
+   }
+   else
+   {
+      /* Initialize DL fd for interfacing with SPAcc */
+      if(PjLibObdDlInitReq(gCb) != ROK)
+      {
+         RETVALUE(LCM_REASON_MISC_FAILURE);
+      }
+   }
+#endif
+
+
+   RETVALUE(LCM_REASON_NOT_APPL);
+} /* pjLmmGenCfg */
+
+/**
+ *
+ * @brief
+ *     Sends confirmation message to LM Called by Request function
+ *  @param[in] pst         Post structure
+ *  @param[in] cfm         PDCP LM structure 
+ *  @param[in] type        type of message
+ *  @param[in] hdr         message header
+ *  @return  S16
+ *      -# ROK
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmSendCfm
+(
+Pst *pst,                    /* Post structure */
+PjMngmt *cfm,                /* PDCP LM structure */
+U8 type,                     /* type of message */
+Header *hdr                  /* message header */
+)
+#else
+PRIVATE S16 pjLmmSendCfm(pst, cfm, type, hdr)
+Pst *pst;                    /* Post structure */
+PjMngmt *cfm;                /* PDCP LM structure */
+U8 type;                     /* type of message */
+Header *hdr;                 /* message header */
+#endif
+{
+   Pst rPst;                 /* Reply post structure */
+   PjCb   *tPjCb;
+   TRC2(pjLmmSendCfm);
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   PJ_MEM_SET(&rPst, 0, sizeof(Pst));   
+   /* reply post structure for confirmation */
+   rPst.srcEnt = tPjCb->init.ent;
+   rPst.srcInst = tPjCb->init.inst;
+   rPst.srcProcId = SFndProcId();
+   rPst.dstEnt = pst->srcEnt;
+   rPst.dstInst = pst->srcInst;
+   rPst.dstProcId = pst->srcProcId;
+   rPst.selector = hdr->response.selector;
+   rPst.prior = hdr->response.prior;
+   rPst.route = hdr->response.route;
+   rPst.region = hdr->response.mem.region;
+   rPst.pool= hdr->response.mem.pool;
+
+   /* Fill the reply header */
+   PJ_MEM_SET (&cfm->hdr, '\0', sizeof(cfm->hdr));
+   cfm->hdr.elmId.elmnt = hdr->elmId.elmnt;
+   cfm->hdr.entId.ent = tPjCb->init.ent;
+   cfm->hdr.entId.inst = tPjCb->init.inst;
+   cfm->hdr.transId = hdr->transId;
+
+   switch(type)
+   {
+      case TCFG:
+         PjMiLpjCfgCfm(&rPst,cfm);
+         break;
+      case TCNTRL:
+         SGetDateTime(&(cfm->t.cntrl.dt));
+         PjMiLpjCntrlCfm(&rPst,cfm);
+         break;
+      case TSTS:
+         SGetDateTime(&(cfm->t.sts.dt));
+         PjMiLpjStsCfm(&rPst,0,cfm);
+         break;
+      case TSSTA:
+         SGetDateTime(&(cfm->t.ssta.dt));
+         PjMiLpjStaCfm(&rPst,cfm);
+         break;
+      default:
+#if (ERRCLASS & ERRCLS_INT_PAR)
+         RLOG0(L_ERROR, "Invalid message type");
+          
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+         break;
+   }
+
+   RETVALUE(ROK);
+} /* pjLmmSendCfm */
+
+
+/**
+@brief
+This function processes configuration requests received from the layer manager.
+The configuration requests can be for general configuration, or configuration
+of PJU, and CPJ SAPs. The type of the configuration request can be determined
+from the elmId field in the header of the layer manager message.This function
+is called by the layer manager to configure PDCP. 
+
+This function implements the following logic: \n
+
+- switch (cfg->hdr.elmId.elmnt)
+   - case STGEN 
+      - update the genCfg field in RlCb; 
+      - allocate the maximum static memory required by the PDCP product; 
+      - register the timer service by calling SReqTmr; 
+      - set CfgDone for not configuring again; 
+   - case STPJUSAP 
+      - if genCfg is not done, send negative Cfm to the layer manager; 
+      - if all the parameters are valid, then allocate the RlSap control block;
+      - update the SAP control block with the information provided in the 
+      - configuration request; 
+      - send configuration confirm with the status, success; 
+   - case STCPJSAP 
+      - if genCfg is not done, send negative Cfm to the layer manager; 
+      - if all the parametes are valid, then allocate the CrSap control block; 
+      - update the SAP control block with the information provided in the
+         configuration request; 
+      - send configuration confirm with the status, success; 
+- end switch;
+ *  @param[in] pst      post structure 
+ *  @param[in] cfg      LM management structure 
+ *  @return S16
+ *      -# Success : ROK
+ *      -# Failure : RFAILED
+*/
+
+#ifdef ANSI
+PUBLIC S16 PjMiLpjCfgReq 
+(
+Pst *pst, 
+PjMngmt *cfg
+)
+#else
+PUBLIC S16 PjMiLpjCfgReq (pst, cfg)
+Pst  *pst;
+PjMngmt *cfg;
+#endif
+{
+   S16   ret;
+   Elmnt elmnt;          /* header element */
+   PjMngmt rCfm;         /* Reply cfm */
+   Reason reason;        /* failure reason */
+   PjCb   *tPjCb;
+
+   TRC3(PjMiLpjCfgReq);
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)     /* KW_FIX */
+   {
+       RETVALUE(RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   RLOG1(L_DEBUG, "PjMiLpjCfgReq(post, elmId(%d))", cfg->hdr.elmId.elmnt);
+
+   ret = ROK;
+
+   /* check configuration is done or not */
+   if ((!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) &&
+         (cfg->hdr.elmId.elmnt != STGEN))
+   {
+      /*
+       * if general config is not over then use pst structure
+       * in primitive to communicate to stack manager
+       */
+
+      rCfm.cfm.status = LCM_PRIM_NOK;
+      rCfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
+      pjLmmSendCfm(pst, &rCfm, TCFG, &cfg->hdr);     
+      RETVALUE(RFAILED);
+   }
+
+   elmnt = cfg->hdr.elmId.elmnt;
+
+   switch(elmnt)
+   {
+      case STGEN:
+      {
+         reason = pjLmmGenCfg(tPjCb,&cfg->t.cfg.s.gen);
+         break;
+      }
+      case STPJUSAP:
+      {
+         reason = pjLmmPjuSapCfg(tPjCb,&cfg->t.cfg.s.sap);
+         break;
+      }
+      case STKWUSAP:
+      {
+         reason = pjLmmKwuSapCfg(tPjCb,&cfg->t.cfg.s.sap);
+         break;
+      }
+      case STCPJSAP:
+      {
+         reason = pjLmmCpjSapCfg(tPjCb,&cfg->t.cfg.s.sap);
+         break;
+      }
+      case STUDXSAP:
+      {
+         reason = pjLmmUdxSapCfg(tPjCb,&cfg->t.cfg.s.sap);
+         break;
+      }
+      default:
+      {
+         reason = LCM_REASON_INVALID_ELMNT;
+         break;
+      }   
+   }
+
+   if (reason == LCM_REASON_NOT_APPL)
+   {
+      rCfm.cfm.status = LCM_PRIM_OK;
+      rCfm.cfm.reason = LCM_REASON_NOT_APPL;
+
+      ret = ROK;
+   }
+   else
+   {
+      rCfm.cfm.status = LCM_PRIM_NOK;
+      rCfm.cfm.reason = reason;
+
+      ret = RFAILED;
+   }
+
+   RLOG2(L_DEBUG, "Cfg  Req processed : status(%d) reason(%d)",
+            rCfm.cfm.status, rCfm.cfm.reason);
+
+   ret = pjLmmSendCfm(pst, &rCfm, TCFG, &cfg->hdr);
+
+   RETVALUE(ret);
+} /* PjMiLpjCfgReq */
+
+/**
+@brief 
+The layer manager initiates and uses the management-control procedure to
+control PDCP elements.The PDCP control request primitive (PjMiLpjCntrlReq)
+can be called more than once and at any time after the management-configuration
+procedure.The control request primitive is confirmed by a PjMiLpjCntrlCfm
+primitive.
+
+This function implements the following logic: \n
+
+- if(cfgDone = FALSE) 
+   - send negative confirmation to the layer manager; 
+   - return; 
+- else 
+- switch(cntrl->hdr.elmId.elmnt) 
+   -  case STGEN 
+        - switch (action) 
+        - case AENA 
+             - switch(subAction) 
+             - case SAUSTA 
+                  - enable the unsolicited status flag; 
+                  - send the control Cfm with success; 
+             - case SADBG 
+                  - set the debug mask; 
+                  - send the control Cfm with success; 
+             - case SATRC 
+                  - enable the trace flag; 
+                  - send the control Cfm with success; 
+        - case ADISIMM 
+             - switch(subAction) 
+             - case SAUSTA 
+                  - disable the unsolicited status flag; 
+                  - send the control Cfm with success; 
+             - case SATRC 
+                  - disable the trace flag; 
+                  - send the control Cfm with success; 
+        - case ASHUTDOWN 
+   - case STMKSAP 
+        - switch (action) 
+        - case ABND 
+        - case AUBND 
+   - default  
+- end else  
+ *  @param[in] pst      post structure
+ *  @param[in] cntrl    LM management structure
+ *  @return S16
+ *      -# Success : ROK
+ *      -# Failure : RFAILED
+*/
+#ifdef ANSI
+PUBLIC S16 PjMiLpjCntrlReq
+(
+Pst *pst, 
+PjMngmt *cntrl
+)
+#else
+PUBLIC S16 PjMiLpjCntrlReq(pst, cntrl)
+Pst     *pst;
+PjMngmt *cntrl;
+#endif
+{
+   Elmnt elmnt;          /* header element */
+   PjMngmt rCfm;         /* Reply cfm */
+   Reason reason;        /* failure reason */
+
+   S16 ret;
+   PjCb   *tPjCb;
+   TRC3(PjMiLpjCntrlReq)
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)     /* KW_FIX */
+   {
+     RETVALUE(RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   RLOG1(L_DEBUG,  "Cntrl Req Received (post, elmId(%d))", 
+                       cntrl->hdr.elmId.elmnt);
+
+   ret = ROK;
+
+   if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
+   {
+      rCfm.cfm.status = LCM_PRIM_NOK;
+      rCfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
+
+      pjLmmSendCfm(pst, &rCfm, TCNTRL, &cntrl->hdr);
+      RETVALUE(RFAILED);
+   }
+
+   /* In normal cases, LCM_REASON_NOT_APPL is returned in cfm.
+    * In all error cases appropriate reason is returned
+    * by the functions below
+    */
+
+   elmnt = cntrl->hdr.elmId.elmnt;
+
+   reason = LCM_REASON_NOT_APPL;
+
+
+   switch (elmnt)
+   {
+      case STGEN:
+      {
+         /* general control */
+         reason = pjLmmGenCntrl(tPjCb,cntrl);
+         break;
+      }
+
+      case STKWUSAP:
+      {
+         /* general control */
+         reason = pjLmmLSapCntrl(tPjCb,cntrl);
+         break;
+      }
+      case STUDXSAP:
+      {
+         /* general control */
+         reason = pjLmmUdxSapCntrl(tPjCb,cntrl);
+         break;
+      }
+
+      default:
+      {
+         reason = LCM_REASON_INVALID_ELMNT;
+         break;
+      }
+   } /* end switch */
+
+   RLOG1(L_DEBUG, "Cntrl Req  Processed sending cfm: reason(%d)", reason);
+
+   ret = pjLmmFormLmCfm(pst, &cntrl->hdr, reason);
+   RETVALUE(ret);
+} /* PjMiLpjCntrlReq */
+
+/**
+@brief 
+This function processes solicited status requests received from the layer
+manager. The layer manager can request status information regarding the
+system ID, PJUSAP, or CPJSAP.
+
+ *  @param[in] pst      post structure
+ *  @param[in] cfm    LM management structure
+ *  @return S16
+ *      -# Success : ROK
+ *      -# Failure : RFAILED
+*/
+#ifdef ANSI
+PUBLIC S16 PjMiLpjStaReq
+(
+Pst *pst, 
+PjMngmt *sta
+)
+#else
+PUBLIC S16 PjMiLpjStaReq(pst, sta)
+Pst     *pst;
+PjMngmt *sta;
+#endif
+{
+   S16      ret;
+   Elmnt    elmnt;            /* Header element */
+   PjMngmt  rSta;             /* Status */
+   Reason   reason;           /* Failure reason */
+   PjCb   *tPjCb;
+
+   TRC3(PjMiLpjStaReq);
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   RLOG1(L_DEBUG, "Status  Req Received (post, elmId(%d))", 
+                         sta->hdr.elmId.elmnt);
+
+   PJ_MEM_SET(&rSta, 0, sizeof(PjMngmt));
+
+   reason = LCM_REASON_NOT_APPL;
+
+   elmnt = sta->hdr.elmId.elmnt;
+
+   switch (elmnt)
+   {
+      case STSID:
+      {
+         reason = LCM_REASON_NOT_APPL;
+         pjGetSId(&rSta.t.ssta.s.sysId);
+         break;
+      }
+      case STGEN:
+      {
+         break;
+      }
+      case STKWUSAP:
+      {
+         PJ_MEM_CPY (&rSta.t.ssta.s.kwuSap, &sta->t.ssta.s.kwuSap,
+               sizeof (PjKwuSapSta));
+         reason = pjLmmGetKwuSapSta (tPjCb,&rSta.t.ssta.s.kwuSap);
+         break;
+      }
+      case STUDXSAP:
+      {
+         PJ_MEM_CPY (&rSta.t.ssta.s.udxSap, &sta->t.ssta.s.udxSap,
+               sizeof (PjUdxSapSta));
+         reason = pjLmmGetUdxSapSta (tPjCb,&rSta.t.ssta.s.udxSap);
+         break;
+      }
+      case STPJUSAP:
+      {
+         PJ_MEM_CPY (&rSta.t.ssta.s.pjuSap, &sta->t.ssta.s.pjuSap,
+               sizeof (PjPjuSapSta));
+         reason = pjLmmGetPjuSapSta (tPjCb,&rSta.t.ssta.s.pjuSap);
+         break;
+      }
+      case STCPJSAP:
+      {
+         PJ_MEM_CPY (&rSta.t.ssta.s.cpjSap, &sta->t.ssta.s.cpjSap,
+               sizeof (PjCpjSapSta));
+         reason = pjLmmGetCpjSapSta (tPjCb,&rSta.t.ssta.s.cpjSap);
+         break;
+      }
+      default:
+      {
+         reason = LCM_REASON_INVALID_ELMNT;
+         break;
+      }
+   } /* end of switch */
+
+   if (reason == LCM_REASON_NOT_APPL)
+   {
+      rSta.cfm.status = LCM_PRIM_OK;
+      rSta.cfm.reason = LCM_REASON_NOT_APPL;
+
+      ret = ROK;
+   }
+   else
+   {
+      rSta.cfm.status = LCM_PRIM_NOK;
+      rSta.cfm.reason = reason;
+
+      ret = RFAILED;
+   }
+
+   RLOG2(L_DEBUG, "Sta Req processed - sending cfm: status(%d) reason(%d)",
+             rSta.cfm.status, rSta.cfm.reason);
+
+   ret = pjLmmSendCfm(pst, &rSta, TSSTA, &sta->hdr);
+
+   RETVALUE(ret);
+} /* PjMiLpjStaReq */
+
+/**
+@brief 
+This function processes statistics requests received from the layer manager.
+After collecting the statistics, this function calls the statistics confirm
+function to send the statistics to the layer manager.
+
+- switch(sts->hdr.elmId.elmnt) 
+  - case STGEN 
+     - get the general statistics from the PJ control block; 
+     - if (action = RESET) 
+        - reset the general statistic field in the RlCb; 
+        - call PjMiLpjStsCfm to send statistics back to layer manager; 
+  - case STCPJSAP 
+  - case STPJUSAP 
+      - get the SAP specific statistics from PJ control block; 
+      - if (action = RESET) 
+      - reset the general statistic field in the RlCb; 
+      - call PjMiLpjStsCfm to send statistics to the layer manager; 
+-end switch;
+
+ *  @param[in] pst      post structure
+ *  @param[in] action   action 
+ *  @param[in] cfg      LM management structure
+ *  @return S16
+ *      -# Success : ROK
+ *      -# Failure : RFAILED
+*/
+#ifdef ANSI
+PUBLIC S16 PjMiLpjStsReq 
+(
+Pst *pst, 
+Action action, 
+PjMngmt *sts
+)
+#else
+PUBLIC S16 PjMiLpjStsReq (pst, action, sts)
+Pst     *pst;
+Action  action;
+PjMngmt *sts;
+#endif
+{
+   S16      ret;
+   PjMngmt  rSts;             /* Statistics */
+   Reason   reason;           /* Reason for failure */
+   Elmnt    elmnt;            /* Element Id */
+   PjCb   *tPjCb;
+
+   TRC3(PjMiLpjStsReq);
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   RLOG2(L_DEBUG,  "Sts Req (post, elmId(%d),action(%d))",
+            action, sts->hdr.elmId.elmnt);
+
+   PJ_MEM_SET(&rSts, 0, sizeof(PjMngmt));
+   elmnt = sts->hdr.elmId.elmnt;
+
+   switch (elmnt)
+   {
+      case STGEN:
+      {
+         reason = pjLmmGetGenSts(tPjCb,&rSts.t.sts.s.gen, action);
+         break;
+      }
+      case STPJUSAP:
+      {
+         reason = pjLmmGetSapSts(tPjCb,sts, elmnt, action);
+         PJ_MEM_CPY(&rSts.t.sts.s.pjuSap, &sts->t.sts.s.pjuSap, 
+                    sizeof(PjPjuSts));
+         break;
+      }
+      case STCPJSAP: /* No CPJ SAP statistics available */
+      default:
+      {
+         reason = LCM_REASON_INVALID_ELMNT;
+         break;
+      }
+   } /* end switch */
+
+   if (reason == LCM_REASON_NOT_APPL)
+   {
+      rSts.cfm.status = LCM_PRIM_OK;
+      rSts.cfm.reason = LCM_REASON_NOT_APPL;
+
+      ret = ROK;
+   }
+   else
+   {
+      rSts.cfm.status = LCM_PRIM_NOK;
+      rSts.cfm.reason = reason;
+
+      ret = RFAILED;
+   }
+
+   RLOG2(L_DEBUG, "Sts Req Processed - sending cfm: status(%d) reason(%d)",
+            rSts.cfm.status, rSts.cfm.reason);
+
+   ret = pjLmmSendCfm(pst, &rSts, TSTS, &sts->hdr);
+
+   RETVALUE(ret);
+} /* PjMiLpjStsReq */
+/* pj005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+/**
+ * @brief  Validates the measurement request parameters. 
+ *
+ * @details
+ *
+ *     Function :pjUtlValidateL2Meas 
+ *
+ *  @param[in]  PjL2MeasReqEvt measReqEvt
+ *  @param[out] PjL2MeasCfmEvt measCfmEvt
+ **/
+#ifdef ANSI
+PRIVATE S16 pjUtlValidateL2Meas
+(
+PjCb            *tPjCb, 
+PjL2MeasReqEvt  *measReqEvt,
+PjL2MeasCfmEvt  *measCfmEvt
+)
+#else
+PRIVATE S16 pjUtlValidateL2Meas(tPjCb, measReqEvt, measCfmEvt)
+PjCb             *tPjCb;   
+PjL2MeasReqEvt  *measReqEvt;
+PjL2MeasCfmEvt  *measCfmEvt;
+#endif
+{
+   U16      measType;
+   S16     ret;
+   U8      qciIdx, qciVal;
+
+   TRC3(pjUtlValidateL2Meas)
+   
+   ret = ROK;
+   measType = measReqEvt->measReq.measType;
+
+   if(measType == 0)
+   {
+      measCfmEvt->numQciCfm = 1;
+      measCfmEvt->measCfm[0].qci = measReqEvt->measReq.qci[0];
+      measCfmEvt->transId = measReqEvt->transId;
+      measCfmEvt->measType = measType;
+      measCfmEvt->status.status = LCM_PRIM_NOK;
+      measCfmEvt->status.reason = LPJ_CAUSE_INVALID_MEASTYPE;
+      RETVALUE(RFAILED);
+   }
+   if(((measReqEvt->measReq.measType & LPJ_L2CPU_PERCORE_STATS) || 
+       (measReqEvt->measReq.measType & LPJ_L2MEM_PERPOOL_STATS)) &&
+       (~(measReqEvt->measReq.measType & LPJ_L2MEAS_UL_LOSS))) 
+
+   {
+      RETVALUE(ROK);
+   }
+   if(measReqEvt->measReq.numQci > LPJ_MAX_QCI || measReqEvt->measReq.numQci == 0)
+   {
+      measCfmEvt->numQciCfm = 1;
+      measCfmEvt->transId = measReqEvt->transId;
+      measCfmEvt->measType = measType;
+      measCfmEvt->status.status = LCM_PRIM_NOK;
+      measCfmEvt->status.reason = LPJ_CAUSE_EXCEED_NUMQCI;
+      RETVALUE(RFAILED);
+   }
+   if(measReqEvt->measPeriod != 0)
+   {
+      measCfmEvt->numQciCfm = 1;
+      measCfmEvt->transId = measReqEvt->transId;
+      measCfmEvt->measType = measType;
+      measCfmEvt->status.status = LCM_PRIM_NOK;
+      measCfmEvt->status.reason = LPJ_CAUSE_INVALID_MEASTYPE;
+      RETVALUE(RFAILED);
+   }
+   for(qciIdx = 0; qciIdx < measReqEvt->measReq.numQci; qciIdx++)
+   {
+      if(tPjCb->u.ulCb->pjL2Cb.measOn[measReqEvt->measReq.qci[qciIdx]] & 
+            measReqEvt->measReq.measType)
+      {
+        /* Measurement is already ongoing */
+        measCfmEvt->measCfm[measCfmEvt->numQciCfm].qci = qciIdx;
+        measCfmEvt->measType = measType;
+        measCfmEvt->numQciCfm++;
+      }
+   }
+   if(measCfmEvt->numQciCfm > 0)
+   {
+      measCfmEvt->status.status = LCM_PRIM_NOK;
+      measCfmEvt->status.reason = LPJ_CAUSE_MEAS_ALREADY_ENA;
+      measCfmEvt->transId = measReqEvt->transId;
+      RETVALUE(RFAILED);
+   }
+   for(qciIdx = 0; qciIdx < measReqEvt->measReq.numQci; qciIdx++)
+   {
+      qciVal = measReqEvt->measReq.qci[qciIdx];
+      if(qciVal == 0 || qciVal > 9)
+      {
+         measCfmEvt->numQciCfm = 1;
+         measCfmEvt->measCfm[0].qci = measReqEvt->measReq.qci[qciIdx];
+         measCfmEvt->transId = measReqEvt->transId;
+         measCfmEvt->measType = measReqEvt->measReq.measType;
+         measCfmEvt->status.status = LCM_PRIM_NOK;
+         measCfmEvt->status.reason = LPJ_CAUSE_INVALID_QCI;
+         RETVALUE(RFAILED);
+      }
+   }
+   
+   
+   RETVALUE(ROK);
+}/* pjUtlValidateL2Meas */
+
+/**
+@brief 
+This function processes L2 Measurement requests received from the layer manager.
+The L2 Measurement is start for a time period and after the timer expiry, the 
+measurement confirm is sent.
+
+-  Accept only one set of measurements.
+-  Allocate and initialise KwL2MeasEvtCb.
+-  Validate if the measurement is already in progress.
+   -  Loop through the existing measEvtCb with matching measType
+      -  Check if measurement is running for any qci present in the measReq
+      -  If present, move the qCi to list of invalid qCIs.
+-  Set KwL2MeasEvtCb.measOn to TRUE for QCIs to be measured.
+-  For the number of measurements requested.
+   -  For all Ues with RBs matching qCI.
+      -  Add RbCb to the RB linked list.
+      -  Set kwRbCb.measOn to measurement type.
+      -  If Meas type is DL_DELAY
+         -  Update COUNT to startCount.
+-  Start l2Timer
+
+ *  @param[in] pst      post structure
+ *  @param[in] action   action 
+ *  @param[in] cfg      LM management structure
+ *  @return S16
+ *      -# Success : ROK
+ *      -# Failure : RFAILED
+*/
+#ifdef ANSI
+PUBLIC S16 PjMiLpjL2MeasReq 
+(
+Pst            *pst, 
+PjL2MeasReqEvt *measReqEvt 
+)
+#else
+PUBLIC S16 PjMiLpjL2MeasReq (pst, measReqEvt)
+Pst            *pst; 
+PjL2MeasReqEvt *measReqEvt;
+#endif
+{
+   S16            ret = ROK;
+   U16             measType;
+   PjL2MeasCfmEvt measCfmEvt;
+   PjL2Cb   *pjL2Cb = NULLP;
+   PjCb     *tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   TRC3(PjMiLpjL2MeasReq);
+
+   tPjCb =  PJ_GET_PJCB(pst->dstInst);
+   
+   measType = measReqEvt->measReq.measType;
+   
+   RLOG1(L_DEBUG, "L2_MEAS START Measurement type is %u\n", measType);
+   /* Initialize measCfmEvt */
+   memset(&measCfmEvt,0, sizeof(PjL2MeasCfmEvt));
+
+   ret = pjUtlValidateL2Meas(tPjCb, measReqEvt, &measCfmEvt);
+   if(ret != ROK)
+   {
+      pjUtlSndUlL2MeasNCfm(tPjCb, &measCfmEvt);
+      RETVALUE(RFAILED);
+   }
+
+   RLOG1(L_DEBUG,"Measurement Start Req type is [%lu]", measType);
+   if (measType & LPJ_L2MEAS_UL_LOSS)
+   {
+      U32      cntr    = 0;
+
+      pjL2Cb = &tPjCb->u.ulCb->pjL2Cb;
+
+      for(cntr = 1; cntr < LPJ_MAX_QCI; cntr++)
+      {
+         pjL2Cb->measOn[cntr] |= measType;
+      }
+   }
+   if ((measType & LPJ_L2MEM_PERPOOL_STATS) || (measType & LPJ_L2CPU_PERCORE_STATS) )
+   {
+      /* starting measurement timer */
+      ret = pjStartTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR); 
+      if(ret == RFAILED) 
+      {
+         RETVALUE(ret);
+      }  
+   }
+   if(measType & LPJ_L2MEM_PERPOOL_STATS)
+   {   
+      pjL2Cb->memUtilizationMask |= LPJ_L2MEM_PERPOOL_STATS;
+   }
+   if(measType & LPJ_L2CPU_PERCORE_STATS)
+   {
+      pjL2Cb->cpuUtilizationMask |= LPJ_L2CPU_PERCORE_STATS;
+   }
+   /* Use else for DL in future */
+   RETVALUE(ret);
+} /* PjMiLpjL2MeasReq */
+
+/**
+@brief 
+This function processes L2 Measurement stop request received from the layer manager.
+After receving this request, PDCP stops L2 Measurement
+ *  @param[in] pst      post structure
+ *  @param[in] measType meas Type 
+ *  @return S16
+ *      -# Success : ROK
+ *      -# Failure : RFAILED
+*/
+
+#ifdef ANSI
+PUBLIC S16 PjMiLpjL2MeasStopReq
+(
+Pst            *pst,
+U16            measType
+)
+#else
+PUBLIC S16 PjMiLpjL2MeasStopReq (pst, measType)
+Pst            *pst;
+U16             measType;
+#endif
+{
+   U16            cntr;
+   PjCb             *tPjCb     = PJ_GET_PJCB(pst->dstInst);
+   PjL2MeasEvtCb    *measEvtCb = NULLP;
+   PjL2MeasCfmEvt          measCfmEvt;  
+   TRC3(PjMiLpjL2MeasStopReq);
+
+
+   RLOG1(L_DEBUG,"Meas Stop Req type is [%lu]", measType);
+   /* For UL counters only */
+   cmMemset((U8*)&measCfmEvt, 0, sizeof(PjL2MeasCfmEvt)); 
+   
+   if(measType & LPJ_L2MEM_PERPOOL_STATS || 
+      measType & LPJ_L2CPU_PERCORE_STATS)
+   {
+       /* stopping timer */
+       pjStopTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR);
+   }
+   if(measType & LPJ_L2MEM_PERPOOL_STATS)
+   {   
+      tPjCb->u.ulCb->pjL2Cb.memUtilizationMask = 0;
+   }
+   if(measType & LPJ_L2CPU_PERCORE_STATS)
+   {
+      tPjCb->u.ulCb->pjL2Cb.cpuUtilizationMask = 0;
+   }
+   for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++)
+   {
+      measEvtCb = &(tPjCb->u.ulCb->pjL2Cb.pjL2EvtCb[cntr]);
+      if(measEvtCb->measCb.measType & measType)
+      {
+         pjUtlResetUlL2MeasCntr(tPjCb, &measEvtCb->measCb, measType);
+      }
+   }
+   PjMiLpjL2MeasStopCfm(&tPjCb->pjGenCfg.lmPst, measType,LCM_PRIM_OK); 
+   RETVALUE(ROK);
+}
+
+\f
+/**
+ *
+ * @brief For reporting measurement.
+ *
+ *
+ * @b Description
+ *        This function is called when the l2 measurement report send request is received. 
+ *        This function sends a consolidates the mesaurements taken during
+ *        this time and sends the confirm .
+ *
+ *  @param[in] measEvtCb    Measurement Event Control Block.
+ *
+ *
+ *  @return  S16
+ *      -# ROK
+ */
+
+#ifdef ANSI
+PRIVATE S16 PjUtlPrepNSndL2MeasSendCfm
+(
+PjCb          *tPjCb,
+PjL2MeasEvtCb *measEvtCb
+)
+#else
+PRIVATE S16 PjUtlPrepNSndL2MeasSendCfm(tPjCb, measEvtCb)
+PjCb          *tPjCb;
+PjL2MeasEvtCb *measEvtCb;
+#endif
+{
+   PjL2MeasCb     *measCb;
+   PjL2MeasCfmEvt measCfmEvt;
+   U8             qciIdx;
+   U8             coreIdx;
+   S16            ret;
+   TRC3(PjUtlPrepNSndL2MeasSendCfm);
+
+   measCb = &measEvtCb->measCb;
+   /* Initialize measCfmEvt */
+   cmMemset((U8 *) &measCfmEvt, 0, sizeof(PjL2MeasCfmEvt));
+   measCfmEvt.measType = measCb->measType;
+   measCfmEvt.status.status = LCM_PRIM_OK;
+   measCfmEvt.status.reason = LCM_REASON_NOT_APPL;
+
+   /* Filling Memory Utilzation structure */
+   if(measCb->measType &  LPJ_L2MEM_PERPOOL_STATS)
+   {
+      if(tPjCb->u.ulCb->pjL2Cb.memUtilizationMask & LPJ_L2MEM_PERPOOL_STATS)
+      {
+         cmFillMemUtilizationMeas(&(measCfmEvt.memoryInfo),&(measCb->memInfo));
+         cmClearMemUtilizationCounter(&(measCb->memInfo));
+         if(FALSE == (pjChkTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR)))
+         {
+            /* starting measurement timer */
+            ret = pjStartTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR); 
+            if(ret == RFAILED) 
+            {
+               RETVALUE(ret);
+            }
+         }
+      }
+      else
+      {
+         RLOG0(L_DEBUG,"Meas Send  Req without configuring Memory meas");
+      }
+   }
+   if(measCb->measType &  LPJ_L2MEAS_UL_LOSS)
+   {
+      /* Fill the measCfmEvt structure */
+      for(qciIdx = 1; qciIdx < LPJ_MAX_QCI; qciIdx++)
+      {
+         U8 qci = measCb->qci[qciIdx];
+         if(qci > 0)
+         {   
+            if(measCb->measType &  LPJ_L2MEAS_UL_LOSS)
+            {
+               U64 totPkts, lostPkts;
+
+               lostPkts = (U64)(measCb->measData[qci].ulLoss.val);
+               totPkts = (U64)(measCb->measData[qci].ulLoss.numPkts);
+
+               measCfmEvt.measCfm[measCfmEvt.numQciCfm].qci = qci;
+               measCfmEvt.measCfm[measCfmEvt.numQciCfm].ulLoss = 0;
+               if (totPkts > 0)
+               {
+                  /* ul Loss  = num of Pkts lost * 10^6 / total no of pkts. */
+                  measCfmEvt.measCfm[measCfmEvt.numQciCfm].ulLoss = (((U64)(lostPkts  * ((U64)1000000))) / totPkts);
+
+                  measCb->measData[qci].ulLoss.val     = 0;
+                  measCb->measData[qci].ulLoss.numPkts = 0;
+               }
+            }
+            if (measCb->measData[qci].totDrbsPerQci == 0)
+            {
+               measCb->qci[qciIdx] = 0;
+            }
+            measCfmEvt.numQciCfm++;
+         }
+      }
+   }
+   if((measCb->measType &  LPJ_L2CPU_PERCORE_STATS) &&(tPjCb->u.ulCb->pjL2Cb.cpuUtilizationMask & LPJ_L2CPU_PERCORE_STATS))
+   {  
+      CmCpuStatsInfo *cpuInfo = &measCb->cpuInfo;
+      for(coreIdx = 0; (coreIdx < cpuInfo->numCores) && (coreIdx < CM_MAX_CPU_CORES); coreIdx++)
+      {
+         measCfmEvt.cmLteCpuInfo[coreIdx].avgCpuUtil = cpuInfo->cpuUtil[coreIdx].totCpuUtil / cpuInfo->cpuUtil[coreIdx].numSamples ;  
+         measCfmEvt.cmLteCpuInfo[coreIdx].maxCpuUtil = cpuInfo->cpuUtil[coreIdx].maxCpuUtil ;
+         cpuInfo->cpuUtil[coreIdx].totCpuUtil = 0;
+         cpuInfo->cpuUtil[coreIdx].maxCpuUtil = 0; 
+         cpuInfo->cpuUtil[coreIdx].numSamples = 0;
+      }
+      measCfmEvt.numCores = cpuInfo->numCores;
+      cpuInfo->numCores = 0;
+      if(FALSE == (pjChkTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR)))
+      {
+         /* starting measurement timer */
+         ret = pjStartTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR); 
+         if(ret == RFAILED) 
+         {
+            RETVALUE(ret);
+         }
+      }
+   } 
+   /* Send Measurement confirmation to layer manager */
+   pjUtlSndUlL2MeasNCfm(tPjCb, &measCfmEvt);
+
+   RETVALUE(ROK);
+} /* PjUtlPrepNSndL2MeasSendCfm */
+
+/**
+@brief 
+This function processes L2 Measurement Send request received from the layer manager.
+After receving this request, RLC sends L2 Measurement
+ *  @param[in] pst      post structure
+ *  @param[in] measType meas Type 
+ *  @return S16
+ *      -# Success : ROK
+ *      -# Failure : RFAILED
+*/
+
+#ifdef ANSI
+PUBLIC S16 PjMiLpjL2MeasSendReq
+(
+Pst            *pst,
+U16            measType
+)
+#else
+PUBLIC S16 PjMiLpjL2MeasSendReq (pst, measType)
+Pst            *pst;
+U16            measType;
+#endif
+{
+   TRC3(PjMiLpjL2MeasSendReq);
+
+   if((measType & LPJ_L2MEAS_UL_LOSS) || 
+      (measType & LPJ_L2MEM_PERPOOL_STATS) || 
+      (measType & LPJ_L2CPU_PERCORE_STATS))
+   {
+      U8             cntr;
+      PjCb           *tPjCb     = PJ_GET_PJCB(pst->dstInst);
+      PjL2MeasEvtCb  *measEvtCb = NULLP;
+
+      if((measType & LPJ_L2MEM_PERPOOL_STATS) && 
+         (tPjCb->u.ulCb->pjL2Cb.memUtilizationMask & LPJ_L2MEM_PERPOOL_STATS))
+      {
+         if(TRUE == (pjChkTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR)))
+         {
+          /* stopping timer */
+          pjStopTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR);
+         }
+      }
+      if((measType & LPJ_L2CPU_PERCORE_STATS) && 
+         (tPjCb->u.ulCb->pjL2Cb.cpuUtilizationMask & LPJ_L2CPU_PERCORE_STATS))
+      {
+         if(TRUE == (pjChkTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR)))
+         {
+          /* stopping timer */
+          pjStopTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR);
+         }
+      }
+      for(cntr = 0; cntr < PJ_MAX_L2MEAS_EVT; cntr++)
+      {
+         measEvtCb = &tPjCb->u.ulCb->pjL2Cb.pjL2EvtCb[cntr];
+         if(measEvtCb->measCb.measType & measType)
+         {
+            PjUtlPrepNSndL2MeasSendCfm(tPjCb, measEvtCb);
+         } 
+      }
+   }
+   RETVALUE(ROK);
+}
+#ifdef ANSI
+PUBLIC Void UpdateMemInfo
+(
+PjL2Cb *tPjL2Cb
+)
+#else
+PUBLIC Void UpdateMemInfo(tPjL2Cb)
+PjL2Cb *tPjL2Cb;
+#endif
+{
+   U8             cntr;
+   PjL2MeasEvtCb  *measEvtCb = NULLP;
+   for(cntr = 0; cntr < PJ_MAX_L2MEAS_EVT; cntr++)
+   {
+      measEvtCb = &tPjL2Cb->pjL2EvtCb[cntr];
+      if(measEvtCb->measCb.measType & LPJ_L2MEM_PERPOOL_STATS)
+      {
+         /* Update Memory Info for SSI Memory */
+         cmUpdateSsiMemInfo(&(measEvtCb->measCb.memInfo));
+
+#ifdef SS_LOCKLESS_MEMORY
+#ifndef LTE_PAL_ENB
+         UpdateSocMemInfo(CM_L2_MEM_UTIL_AREAIDX, &(measEvtCb->measCb.memInfo));
+#endif
+#endif
+         break;
+      } 
+   }
+}
+
+#ifdef ANSI
+PUBLIC S16 UpdateCpuInfo
+(
+PjL2Cb *tPjL2Cb
+)
+#else
+PUBLIC S16 UpdateCpuInfo(tPjL2Cb)
+PjL2Cb *tPjL2Cb;
+#endif
+{
+   U8             cntr;
+   PjL2MeasEvtCb  *measEvtCb = NULLP;
+#ifndef LTE_PAL_ENB
+   for(cntr = 0; cntr < PJ_MAX_L2MEAS_EVT; cntr++)
+   {
+      measEvtCb = &tPjL2Cb->pjL2EvtCb[cntr];
+      if(measEvtCb->measCb.measType & LPJ_L2CPU_PERCORE_STATS)
+      {
+         /* Update CpuUtilization Info */
+         UpdateSocCpuInfo(&(measEvtCb->measCb.cpuInfo), CM_L2_CPU_UTIL);
+         break;
+      } 
+   }
+#endif
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 pjUtlMemCpuHdlTmrExp 
+(
+PjCb          *tPjCb,
+PjL2Cb *tPjL2Cb
+)
+#else
+PUBLIC S16 pjUtlMemCpuHdlTmrExp(tPjCb,tPjL2Cb)
+PjCb   *tPjCb;
+PjL2Cb *tPjL2Cb;
+#endif
+{
+   S16 ret = ROK;
+   if(tPjCb->u.ulCb->pjL2Cb.memUtilizationMask & LPJ_L2MEM_PERPOOL_STATS)
+   {
+      /* calling memory Info */
+      UpdateMemInfo(tPjL2Cb);
+   }
+   if(tPjCb->u.ulCb->pjL2Cb.cpuUtilizationMask & LPJ_L2CPU_PERCORE_STATS)
+   {
+      UpdateCpuInfo(tPjL2Cb);
+   }
+   /*TODO: call cpu util */
+   /* starting measurement timer */
+   ret = pjStartTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR);
+   if(ret == RFAILED) 
+   {
+      RETVALUE(ret);
+   }
+   RETVALUE(ROK);
+}
+
+
+#endif /* LTE_L2_MEAS */
+/**
+ * @brief
+      This function configures the PDCP data sap
+ *
+ *  @param[in] cfg         PDCP LM Sap structure
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_SAP
+ *                   LCM_REASON_INVALID_SAP 
+ *                   LCM_REASON_RECONFIG_FAIL 
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmPjuSapCfg
+(
+PjCb       *gCb,
+PjSapCfg   *cfg               /* SAP control block */
+)
+#else
+PRIVATE S16 pjLmmPjuSapCfg(gCb, cfg)
+PjCb       *gCb;
+PjSapCfg   *cfg;              /* SAP control block */
+#endif
+{
+   PjPjuSapCb  *pjuSap;
+   
+   TRC2(pjLmmPjuSapCfg)
+
+   /* Validate config parameters */
+   if (cfg->sapId >= PJ_MAX_PJUSAPS )
+   {
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }
+
+   if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      pjuSap = &(gCb->u.ulCb->pjuSap[cfg->sapId]);
+   }
+   else
+   {
+      pjuSap = &(gCb->u.dlCb->pjuSap[cfg->sapId]);
+   }
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   /* Check for reconfiguration */
+   if(pjuSap->state  != PJ_SAP_NOT_CFG)
+   {
+      RLOG0(L_ERROR, "Invalid pjuSap State");
+      RETVALUE(LCM_REASON_RECONFIG_FAIL);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+   
+   /* Fill the parameters */
+   pjuSap->pst.selector = cfg->selector;
+   pjuSap->pst.route = cfg->route;
+   pjuSap->pst.prior =  cfg->priority;
+   /* pj002.201 With multicore support layer shall use the assigned region
+      and pool from SSI */
+#if defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION)
+   pjuSap->pst.region = gCb->init.region; 
+   pjuSap->pst.pool = gCb->init.pool;
+#else
+   pjuSap->pst.region = cfg->mem.region; 
+   pjuSap->pst.pool = cfg->mem.pool;
+#endif
+   pjuSap->pst.dstProcId = cfg->procId;
+   pjuSap->pst.dstEnt = cfg->ent;
+   pjuSap->pst.dstInst = cfg->inst;
+   pjuSap->pst.srcProcId = gCb->init.procId;
+   pjuSap->pst.srcEnt = gCb->init.ent;
+   pjuSap->pst.srcInst = gCb->init.inst;
+   pjuSap->pst.event = EVTNONE;
+   pjuSap->spId = cfg->sapId;
+
+   /* make sap unbound initially */
+   pjuSap->state = PJ_SAP_CFG;
+
+   RETVALUE(LCM_REASON_NOT_APPL);
+} /* pjLmmPjuSapCfg */
+
+/**
+ * @brief
+      This function configures the PDCP / RLC data sap
+ *
+ *  @param[in] cfg         PDCP LM Sap structure
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_SAP
+ *                   LCM_REASON_INVALID_SAP 
+ *                   LCM_REASON_RECONFIG_FAIL 
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmKwuSapCfg
+(
+PjCb       *gCb,
+PjSapCfg   *cfg               /* SAP control block */
+)
+#else
+PRIVATE S16 pjLmmKwuSapCfg(gCb, cfg)
+PjCb       *gCb;
+PjSapCfg   *cfg;              /* SAP control block */
+#endif
+{
+   PjKwuSapCb  *kwuSap;
+   
+   TRC2(pjLmmKwuSapCfg)
+   
+
+   /* Validate config parameters */
+   if (cfg->sapId >= PJ_MAX_KWUSAPS )
+   {
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }
+
+   if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      kwuSap = &(gCb->u.ulCb->kwuSap[cfg->sapId]);
+   }
+   else
+   {
+      kwuSap = &(gCb->u.dlCb->kwuSap[cfg->sapId]);
+   }
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   /* Check for reconfiguration */
+   if(kwuSap->state  != PJ_SAP_NOT_CFG)
+   {
+      RLOG0(L_ERROR, "Invalid kwuSap State");
+      RETVALUE(LCM_REASON_RECONFIG_FAIL);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+   
+   /* Fill the parameters */
+   kwuSap->pst.selector = cfg->selector;
+   kwuSap->pst.route = cfg->route;
+   kwuSap->pst.prior =  cfg->priority;
+   /* pj002.201 With multicore support layer shall use the assigned region
+      and pool from SSI */
+#if defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION)
+   kwuSap->pst.region = gCb->init.region; 
+   kwuSap->pst.pool = gCb->init.pool;
+#else
+   kwuSap->pst.region = cfg->mem.region; 
+   kwuSap->pst.pool = cfg->mem.pool;
+#endif
+   kwuSap->pst.dstProcId = cfg->procId;
+   kwuSap->pst.dstEnt = cfg->ent;
+   kwuSap->pst.dstInst = cfg->inst;
+   kwuSap->pst.srcProcId = gCb->init.procId;
+   kwuSap->pst.srcEnt = gCb->init.ent;
+   kwuSap->pst.srcInst = gCb->init.inst;
+   kwuSap->pst.event = EVTNONE;
+   kwuSap->suId = cfg->sapId;
+
+   /* make sap unbound initially */
+   kwuSap->bndTmrInt = cfg->bndTmrIntvl;
+   cmInitTimers(&kwuSap->bndTmr,PJ_MAX_KWUSAP_TMR); 
+   kwuSap->state = PJ_SAP_CFG;
+
+   RETVALUE(LCM_REASON_NOT_APPL);
+} /* pjLmmKwuSapCfg */
+
+/**
+ * @brief
+      This function configures the PDCP / RLC data sap
+ *
+ *  @param[in] cfg         PDCP LM Sap structure
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_SAP
+ *                   LCM_REASON_INVALID_SAP 
+ *                   LCM_REASON_RECONFIG_FAIL 
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmUdxSapCfg
+(
+PjCb       *gCb,
+PjSapCfg   *cfg               /* SAP control block */
+)
+#else
+PRIVATE S16 pjLmmUdxSapCfg(gCb, cfg)
+PjCb       *gCb;
+PjSapCfg   *cfg;              /* SAP control block */
+#endif
+{
+
+   TRC2(pjLmmUdxSapCfg)
+   
+
+   /* Validate config parameters */
+   if (cfg->sapId >= PJ_MAX_UDXSAPS )
+   {
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }
+
+   if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      PjUdxUlSapCb *udxSap;
+      udxSap = (gCb->u.ulCb->udxUlSap + cfg->sapId);
+#if (ERRCLASS & ERRCLS_INT_PAR)
+      /* Check for reconfiguration */
+      if(udxSap->state  != PJ_SAP_NOT_CFG)
+      {
+         RLOG0(L_ERROR, "Invalid udxSap State");
+         RETVALUE(LCM_REASON_RECONFIG_FAIL);
+      }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+   
+      /* Fill the parameters */
+      udxSap->pst.selector = cfg->selector;
+      udxSap->pst.route = cfg->route;
+      udxSap->pst.prior =  cfg->priority;
+      /* pj002.201 With multicore support layer shall use the assigned region
+         and pool from SSI */
+#if defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION)
+      udxSap->pst.region = gCb->init.region; 
+      udxSap->pst.pool = gCb->init.pool;
+#else
+      udxSap->pst.region = cfg->mem.region; 
+      udxSap->pst.pool = cfg->mem.pool;
+#endif
+      udxSap->pst.dstProcId = cfg->procId;
+      udxSap->pst.dstEnt = cfg->ent;
+      udxSap->pst.dstInst = cfg->inst;
+      udxSap->pst.srcProcId = gCb->init.procId;
+      udxSap->pst.srcEnt = gCb->init.ent;
+      udxSap->pst.srcInst = gCb->init.inst;
+      udxSap->pst.event = EVTNONE;
+      udxSap->suId = cfg->sapId;
+
+      /* make sap unbound initially */
+      udxSap->bndTmrInt = cfg->bndTmrIntvl;
+      cmInitTimers(&udxSap->bndTmr,PJ_MAX_UDXSAP_TMR); 
+      udxSap->state = PJ_SAP_CFG;
+
+   }
+   else
+   {
+      PjUdxDlSapCb *udxSap;
+      udxSap = (gCb->u.dlCb->udxDlSap + cfg->sapId);
+#if (ERRCLASS & ERRCLS_INT_PAR)
+      /* Check for reconfiguration */
+      if(udxSap->state  != PJ_SAP_NOT_CFG)
+      {
+         RLOG0(L_ERROR, "Invalid udxSap State");
+         RETVALUE(LCM_REASON_RECONFIG_FAIL);
+      }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+   
+      /* Fill the parameters */
+      udxSap->pst.selector = cfg->selector;
+      udxSap->pst.route = cfg->route;
+      udxSap->pst.prior =  cfg->priority;
+      /* pj002.201 With multicore support layer shall use the assigned region
+         and pool from SSI */
+#if defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION)
+      udxSap->pst.region = gCb->init.region; 
+      udxSap->pst.pool = gCb->init.pool;
+#else
+      udxSap->pst.region = cfg->mem.region; 
+      udxSap->pst.pool = cfg->mem.pool;
+#endif
+      udxSap->pst.dstProcId = cfg->procId;
+      udxSap->pst.dstEnt = cfg->ent;
+      udxSap->pst.dstInst = cfg->inst;
+      udxSap->pst.srcProcId = gCb->init.procId;
+      udxSap->pst.srcEnt = gCb->init.ent;
+      udxSap->pst.srcInst = gCb->init.inst;
+      udxSap->pst.event = EVTNONE;
+      udxSap->suId = cfg->sapId;
+      udxSap->state = PJ_SAP_CFG;
+   }
+
+   RETVALUE(LCM_REASON_NOT_APPL);
+} /* pjLmmUdxSapCfg */
+
+
+
+/**
+ * @brief
+      This function configures the PDCP control sap
+ *
+ *  @param[in] cfg         PDCP LM Sap structure
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_SAP
+ *                   LCM_REASON_INVALID_SAP 
+ *                   LCM_REASON_RECONFIG_FAIL 
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmCpjSapCfg
+(
+PjCb       *gCb,
+PjSapCfg   *cfg               /* SAP control block */
+)
+#else
+PRIVATE S16 pjLmmCpjSapCfg(gCb,cfg)
+PjCb       *gCb;
+PjSapCfg   *cfg;              /* SAP control block */
+#endif
+{
+   PjCpjSapCb  *cpjSap;
+   
+   TRC2(pjLmmCpjSapCfg)
+
+   /* Validate config parameters */
+   if (cfg->sapId >= PJ_MAX_CPJSAPS )
+   {
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }
+
+   if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      cpjSap = &(gCb->u.ulCb->cpjSap);
+   }
+   else
+   {
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   /* Check for reconfiguration */
+   if(cpjSap->state  != PJ_SAP_NOT_CFG)
+   {
+      RLOG0(L_ERROR, "Invalid cpjSap State");
+      RETVALUE(LCM_REASON_RECONFIG_FAIL);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+   
+   /* Fill the parameters */
+   cpjSap->pst.selector = cfg->selector;
+   cpjSap->pst.route = cfg->route;
+   cpjSap->pst.prior =  cfg->priority;
+   /* pj002.201 With multicore support layer shall use the assigned region
+      and pool from SSI */
+#if defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION)
+   cpjSap->pst.region = gCb->init.region; 
+   cpjSap->pst.pool = gCb->init.pool;
+#else
+   cpjSap->pst.region = cfg->mem.region; 
+   cpjSap->pst.pool = cfg->mem.pool;
+#endif
+   cpjSap->pst.dstProcId = cfg->procId;
+   cpjSap->pst.dstEnt = cfg->ent;
+   cpjSap->pst.dstInst = cfg->inst;
+   cpjSap->pst.srcProcId = gCb->init.procId;
+   cpjSap->pst.srcEnt = gCb->init.ent;
+   cpjSap->pst.srcInst = gCb->init.inst;
+   cpjSap->pst.event = EVTNONE;
+   cpjSap->spId = cfg->sapId;
+
+   /* make sap unbound initially */
+   cpjSap->state = PJ_SAP_CFG;
+
+   RETVALUE(LCM_REASON_NOT_APPL);
+} /* pjLmmCpjSapCfg */
+
+/**
+ * @brief
+     Validates the PDCP general control parameters 
+ *
+ *  @param[in] cntrl PDCP LM structure 
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_SUBACTION
+ *                   LCM_REASON_INVALID_ACTION
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmValidateGenCntrl
+(
+PjMngmt *cntrl                 /* PDCP LM structure */
+)
+#else
+PRIVATE S16 pjLmmValidateGenCntrl(cntrl)
+PjMngmt *cntrl;                /* PDCP LM structure */
+#endif
+{
+   S16 reason;                 /* reason for failure */
+   U8 action;                  /* action parameter */
+   U8 sAction;                 /* subaction field */
+
+
+   reason = LCM_REASON_NOT_APPL;
+
+   TRC2(pjLmmValidateGenCntrl);
+
+   action = cntrl->t.cntrl.action;
+   sAction = cntrl->t.cntrl.subAction;
+
+   switch (action)
+   {
+      case AENA:
+      case ADISIMM:
+         if ((sAction != SAUSTA)
+            && (sAction != SADBG)
+            && (sAction != SATRC))
+         {
+            reason = LCM_REASON_INVALID_SUBACTION;
+         }
+         break;
+      case ASHUTDOWN:
+         break;
+      default:
+         reason = LCM_REASON_INVALID_ACTION;
+         break;
+   }
+   
+   RETVALUE(reason);
+} /* pjLmmValidateGenCntrl */
+
+/**
+ * @brief
+      Delete all SAPs and Control Blocks
+ *
+ * @b Description
+ *       Shutdown of PDCP happens at modules level, tm, um and am modules will
+ *       be shutdown using utility functin and dbm shutdown will clean up the
+ *       SAPs, control blocks and lists. 
+ *
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_HASHING_FAILED 
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmShutdown
+(
+PjCb   *gCb
+)
+#else
+PRIVATE S16 pjLmmShutdown(gCb)
+PjCb   *gCb;
+#endif
+{
+   TRC2(pjLmmShutdown)
+   S16 ret;
+   /* Call PDCP DBM Cleanup function.
+    * RLC LM shutdown takes care of cleanup of Gloabal and RLC resources */
+   if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      ret = pjUtlUlShutdown(gCb);
+    
+#ifdef TENB_AS_SECURITY
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+      PjLibObdUlCloseReq(gCb->u.ulCb->instHndl);
+#else
+      /* There is only one instance so its already freed as part of UL shutdown */
+#endif
+#else
+      PjLibObdUlCloseReq();
+#endif
+#endif
+   }
+   else
+   {
+      ret = pjUtlDlShutdown(gCb);
+      
+#ifdef TENB_AS_SECURITY
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+      PjLibObdDlCloseReq(gCb->u.dlCb->instHndl);
+#else
+      /* There is only one instance so its already freed as part of UL shutdown */
+#endif
+#else
+      PjLibObdDlCloseReq();
+#endif
+#endif
+   }
+   pjLmmCleanGblRsrcs(gCb);
+
+   if(ret != ROK)
+   {
+      RETVALUE(ret);
+   }
+   else
+   {   
+   RETVALUE(LCM_REASON_NOT_APPL);
+   }
+} /* end of pjLmmShutdown */
+
+/**
+ * @brief
+     Function processes the general control request 
+ *
+ *  @param[in] cntrl PDCP LM structure
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_SUBACTION
+ *                   LCM_REASON_INVALID_ACTION
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmGenCntrl
+(
+PjCb    *gCb,
+PjMngmt *cntrl                 /* PDCP LM structure */
+)
+#else
+PRIVATE S16 pjLmmGenCntrl(gCb,cntrl)
+PjCb    *gCb;
+PjMngmt *cntrl;                /* PDCP LM structure */
+#endif
+{
+   U8 action;            /* action parameter */
+   U8 sAction;           /* subaction field */
+   PjTrcCntrl *trcCntrl; /* trace */
+
+#ifdef DEBUGP
+   PjDbgCntrl *dbgCntrl; /* debug */
+#endif /* DEBUGP */
+
+   S16   reason;         /* reason for failure */
+   
+   TRC2(pjLmmGenCntrl);
+
+   reason = LCM_REASON_NOT_APPL;
+
+   /* Validate control parameters */
+   reason = pjLmmValidateGenCntrl (cntrl);
+
+   action = cntrl->t.cntrl.action;
+   sAction = cntrl->t.cntrl.subAction;
+
+   if (reason != LCM_REASON_NOT_APPL)
+   {
+      RETVALUE(reason);
+   }
+
+   switch(action)
+   {
+      case AENA:
+      {
+         switch(sAction)
+         {
+            case SAUSTA:
+            {
+               PJ_SET_USTA_FLAG(gCb, TRUE);
+               break;
+            }
+            case SADBG:
+            {
+#ifdef DEBUGP
+               dbgCntrl = &cntrl->t.cntrl.s.dbgCntrl;
+               PJ_GET_DBG_MASK(gCb) |= dbgCntrl->dbgMask;
+#endif /* DEBUGP */
+               break;
+            }
+            case SATRC:
+            {
+               trcCntrl = &cntrl->t.cntrl.s.trcCntrl;
+               gCb->init.trc = TRUE;
+               gCb->trcLen = trcCntrl->trcLen;
+               (gCb->trcMask) |= trcCntrl->trcMask;
+                break;
+            }
+         }
+         break;
+      }
+      case ADISIMM:
+      {
+         switch(sAction)
+         {
+            case SAUSTA:
+            {
+               gCb->init.usta = FALSE;
+            }
+            break;
+            case SADBG:
+            {
+#ifdef DEBUGP
+               dbgCntrl = &cntrl->t.cntrl.s.dbgCntrl;
+               PJ_GET_DBG_MASK(gCb) &= ~(dbgCntrl->dbgMask);
+#endif /* DEBUGP */
+            }
+            break;
+            case SATRC:
+            {
+               trcCntrl = &cntrl->t.cntrl.s.trcCntrl;
+               gCb->init.trc = FALSE;
+               gCb->trcMask &= ~(trcCntrl->trcMask);
+            }
+            break;
+         }
+         break;
+      }
+      case ASHUTDOWN:
+      {
+         reason = pjLmmShutdown(gCb);
+         break;
+      }
+   }
+   RETVALUE(reason);
+} /* pjLmmGenCntrl */
+
+/**
+ * @brief
+     Bind/Unbind RLC upper sap 
+ *
+ *  @param[in] cntrl RLC LM structure
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_SAP 
+ *                   LCM_REASON_INVALID_STATE
+ *                   LCM_REASON_INVALID_ACTION 
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmUdxSapCntrl
+(
+PjCb    *gCb,
+PjMngmt *cntrl                 /* RLC LM structure */
+)
+#else
+PRIVATE S16 pjLmmUdxSapCntrl(gCb,cntrl)
+PjCb    *gCb;
+PjMngmt *cntrl;                /* RLC LM structure */
+#endif
+{
+   U8         action;                  /* action parameter */
+   S16        reason;                 /* reason for failure */
+   PjUdxUlSapCb *udxSap;                /* udx sap pointer */
+   
+   TRC2(kwLmmUdxSapCntrl)
+   
+
+   reason = LCM_REASON_NOT_APPL;
+   action = cntrl->t.cntrl.action;
+
+   /* validate SuId */
+   if((cntrl->t.cntrl.s.sapCntrl.suId < 0)
+   || (cntrl->t.cntrl.s.sapCntrl.suId >= PJ_MAX_KWUSAPS))
+   {
+      reason = LCM_REASON_INVALID_SAP;
+      RETVALUE(reason);
+   }
+
+
+   if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      /*udxSap = &(gCb->u.ulCb->udxUlSap[cntrl->t.cntrl.s.sapCntrl.suId]);*/
+      udxSap = (gCb->u.ulCb->udxUlSap + cntrl->t.cntrl.s.sapCntrl.suId);
+   }
+   else
+   {
+      reason = LCM_REASON_INVALID_SAP;
+      RETVALUE(reason);
+   }
+
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   /* validate SAP */
+   if(udxSap->state == PJ_SAP_NOT_CFG)
+   {
+      RLOG0(L_ERROR, "Invalid udxSap State");
+      reason = LCM_REASON_INVALID_STATE;
+      RETVALUE(reason);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   switch(action)
+   {
+      case ABND:
+      {
+         if(udxSap->state != PJ_SAP_BND)
+         {
+            S16 ret;
+            /* start timer to wait for bind confirm */
+            ret = pjStartTmr(gCb, (PTR)udxSap, PJ_EVT_WAIT_UDX_BNDCFM); 
+            if(ret == RFAILED) 
+            {
+               reason = LCM_REASON_REGTMR_FAIL; 
+            } 
+            else
+            {
+            udxSap->state = PJ_SAP_BINDING;
+           /* udxSap->spId = cntrl->t.cntrl.s.sapCntrl.spId; */
+            PjUlUdxBndReq(&(udxSap->pst), udxSap->suId, udxSap->spId);
+         }
+         }
+         else
+         {
+            /* control request received for an already bound SAP */
+            reason = LCM_REASON_INVALID_STATE;
+         }
+      }
+      break;
+      case AUBND:
+      {
+         /* make the state of RGUSAP is configure but not bound */
+         udxSap->state = PJ_SAP_CFG;
+         PjUlUdxUbndReq(&(udxSap->pst), udxSap->spId, 0);
+      }
+      break;
+      default:
+         reason = LCM_REASON_INVALID_ACTION;
+         break;
+   } /* end of switch */
+
+   RETVALUE(reason);
+} /* pjLmmUdxSapCntrl */
+
+
+/**
+ * @brief
+     Bind/Unbind RLC upper sap 
+ *
+ *  @param[in] cntrl RLC LM structure
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_SAP 
+ *                   LCM_REASON_INVALID_STATE
+ *                   LCM_REASON_INVALID_ACTION 
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmLSapCntrl
+(
+PjCb    *gCb,
+PjMngmt *cntrl                 /* RLC LM structure */
+)
+#else
+PRIVATE S16 pjLmmLSapCntrl(gCb,cntrl)
+PjCb    *gCb;
+PjMngmt *cntrl;                /* RLC LM structure */
+#endif
+{
+   U8         action;                  /* action parameter */
+   S16        reason;                 /* reason for failure */
+   PjKwuSapCb *kwuSap;                /* rgu sap pointer */
+
+   TRC2(kwLmmLSapCntrl)
+
+   reason = LCM_REASON_NOT_APPL;
+   action = cntrl->t.cntrl.action;
+
+   /* validate SuId */
+   if((cntrl->t.cntrl.s.sapCntrl.suId < 0)
+   || (cntrl->t.cntrl.s.sapCntrl.suId >= PJ_MAX_KWUSAPS))
+   {
+      reason = LCM_REASON_INVALID_SAP;
+      RETVALUE(reason);
+   }
+
+   if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      kwuSap = &(gCb->u.ulCb->kwuSap[cntrl->t.cntrl.s.sapCntrl.suId]);
+   }
+   else  
+   {
+      kwuSap = &(gCb->u.dlCb->kwuSap[cntrl->t.cntrl.s.sapCntrl.suId]);
+   }
+
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   /* validate SAP */
+   if(kwuSap->state == PJ_SAP_NOT_CFG)
+   {
+      RLOG0(L_ERROR, "Invalid kwuSap State");
+      reason = LCM_REASON_INVALID_STATE;
+      RETVALUE(reason);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   switch(action)
+   {
+      case ABND:
+      {
+         if(kwuSap->state != PJ_SAP_BND)
+         {
+            S16 ret;
+            /* start timer to wait for bind confirm */
+            ret = pjStartTmr(gCb, (PTR)kwuSap, PJ_EVT_WAIT_KWU_BNDCFM);
+            if(ret == RFAILED) 
+            {
+               reason = LCM_REASON_REGTMR_FAIL; 
+            } 
+            else
+            {
+            kwuSap->state = PJ_SAP_BINDING;
+            kwuSap->spId = cntrl->t.cntrl.s.sapCntrl.spId;
+            PjLiKwuBndReq(&(kwuSap->pst), kwuSap->suId, kwuSap->spId);
+         }
+         }
+         else
+         {
+            /* control request received for an already bound SAP */
+            reason = LCM_REASON_INVALID_STATE;
+         }
+      }
+      break;
+      case AUBND:
+      {
+         /* make the state of RGUSAP is configure but not bound */
+         kwuSap->state = PJ_SAP_CFG;
+         PjLiKwuUbndReq(&(kwuSap->pst), kwuSap->spId, 0);
+      }
+      break;
+      default:
+         reason = LCM_REASON_INVALID_ACTION;
+         break;
+   } /* end of switch */
+
+   RETVALUE(reason);
+} /* pjLmmLSapCntrl */
+
+
+/**
+ * @brief
+     forms Lm Cfm based on the return values 
+ *
+ *  @param[in] cntrl PDCP LM structure
+ *  @return  S16
+ *      -# Success : ROK 
+ *      -# Failure : RFAILED
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmFormLmCfm
+(
+Pst      *pst,
+Header   *hdr,
+Reason   reason
+)
+#else
+PRIVATE S16 pjLmmFormLmCfm(pst, hdr, reason)
+Pst      *pst;
+Header   *hdr;
+Reason   reason;
+#endif
+{
+   PjMngmt  rCfm;
+   S16      ret;
+   TRC3(pjLmmFormLmCfm)
+
+   ret = ROK;
+
+   if (reason == LCM_REASON_NOT_APPL)
+   {
+      rCfm.cfm.status = LCM_PRIM_OK;
+      rCfm.cfm.reason = LCM_REASON_NOT_APPL;
+
+      ret = ROK;
+   }
+   else
+   {
+      rCfm.cfm.status = LCM_PRIM_NOK;
+      rCfm.cfm.reason = reason;
+
+      ret = RFAILED;
+   }
+
+   pjLmmSendCfm(pst, &rCfm, TCNTRL, hdr);
+
+   RETVALUE(ret);
+} /* pjLmmFormLmCfm */
+
+/**
+ * @brief
+     Function gather the general PJU SAP status 
+ *
+ *  @param[in] sta LM PJU Sap Status structure 
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_PAR_VAL
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmGetPjuSapSta 
+(
+PjCb        *gCb,
+PjPjuSapSta *sta                /* PJU SAP status */
+)
+#else
+PRIVATE S16 pjLmmGetPjuSapSta(gCb,sta)
+PjCb        *gCb;
+PjPjuSapSta *sta;               /* PJU SAP status */
+#endif
+{
+   PjPjuSapCb *pjuSap;
+   TRC2(pjLmmGetPjuSapSta);
+
+   /* Validate config parameters */
+   if (sta->spId >= PJ_MAX_PJUSAPS )
+   {
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }
+
+   if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      pjuSap = &(gCb->u.ulCb->pjuSap[sta->spId]);
+   }
+   else
+   {
+      pjuSap = &(gCb->u.dlCb->pjuSap[sta->spId]);
+   }
+
+
+   /* Get Sap control block */
+   sta->state = pjuSap->state;
+
+   RETVALUE(LCM_REASON_NOT_APPL);
+} /* pjLmmGetPjuSapSta */
+
+/**
+ * @brief
+     Function gather the general PJU SAP status 
+ *
+ *  @param[in] sta LM PJU Sap Status structure 
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_PAR_VAL
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmGetKwuSapSta 
+(
+PjCb        *gCb,
+PjKwuSapSta *sta                /* PJU SAP status */
+)
+#else
+PRIVATE S16 pjLmmGetKwuSapSta(gCb,sta)
+PjCb        *gCb;
+PjKwuSapSta *sta;               /* PJU SAP status */
+#endif
+{
+   PjKwuSapCb *kwuSap;
+   TRC2(pjLmmGetKwuSapSta);
+
+   /* Validate config parameters */
+   if (sta->spId >= PJ_MAX_PJUSAPS )
+   {
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }
+
+   if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      kwuSap = &(gCb->u.ulCb->kwuSap[sta->spId]);
+   }
+   else
+   {
+      kwuSap = &(gCb->u.dlCb->kwuSap[sta->spId]);
+   }
+
+   /* Get Sap control block */
+   sta->state = kwuSap->state;
+
+   RETVALUE(LCM_REASON_NOT_APPL);
+} /* pjLmmGetKwuSapSta */
+
+/**
+ * @brief
+     Function gather the general PJU SAP status 
+ *
+ *  @param[in] sta LM PJU Sap Status structure 
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_PAR_VAL
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmGetUdxSapSta 
+(
+PjCb        *gCb,
+PjUdxSapSta *sta                /* PJU SAP status */
+)
+#else
+PRIVATE S16 pjLmmGetUdxSapSta(gCb,sta)
+PjCb        *gCb;
+PjUdxSapSta *sta;               /* PJU SAP status */
+#endif
+{
+   PjUdxUlSapCb *udxUlSap;   
+   PjUdxDlSapCb *udxDlSap;   
+   TRC2(pjLmmGetUdxSapSta);
+
+   /* Validate config parameters */
+   if (sta->spId >= PJ_MAX_UDXSAPS )   /* KW_FIX */
+   {
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }
+
+   if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      udxUlSap = &(gCb->u.ulCb->udxUlSap[sta->spId]);
+      /* Get Sap control block */
+      sta->state = udxUlSap->state;
+   }
+   else
+   {
+      udxDlSap = &(gCb->u.dlCb->udxDlSap[sta->spId]);
+      /* Get Sap control block */
+      sta->state = udxDlSap->state;
+   }
+
+
+   RETVALUE(LCM_REASON_NOT_APPL);
+} /* pjLmmGetKwuSapSta */
+
+
+/**
+ * @brief
+     Function gather the general CPJ SAP status
+ *
+ *  @param[in] sta LM CPJ Sap Status structure
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_PAR_VAL
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmGetCpjSapSta
+(
+PjCb        *gCb,
+PjCpjSapSta *sta              /* RLU SAP status */
+)
+#else
+PRIVATE S16 pjLmmGetCpjSapSta(sta)
+PjCb        *gCb;
+PjCpjSapSta *sta;             /* RLU SAP status */
+#endif
+{
+   PjCpjSapCb *cpjSap;
+   TRC2(pjLmmGetCpjSapSta);
+
+   if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      cpjSap = &(gCb->u.ulCb->cpjSap);
+   }
+   else
+   {
+      RETVALUE(LCM_REASON_INVALID_SAP);
+   }
+
+
+   sta->state = cpjSap->state;
+
+   RETVALUE(LCM_REASON_NOT_APPL);
+
+} /* pjLmmGetCpjSapSta */
+
+/**
+ * @brief
+     Gather the general statistics 
+ *
+ *  @param[in] sts       LM general statistics structure
+ *  @param[in] action    action
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_PAR_VAL
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmGetGenSts
+(
+PjCb     *gCb,
+PjGenSts *sts,              /* general statistics structure */
+Action action               /* Action */
+)
+#else
+PRIVATE S16 pjLmmGetGenSts(gCb, sts, action)
+PjCb     *gCb;
+PjGenSts *sts;              /* general statistics structure */
+Action action;              /* Action */
+#endif
+{
+   PjGenSts *genSts;        /* General statistics */
+
+   TRC2(pjLmmGetGenSts);
+
+   /* Validate protocol parameters */
+   if ((action != LPJ_ZEROSTS) && (action != LPJ_NOZEROSTS))
+   {
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }
+
+   PJ_MEM_CPY (sts, &(gCb->pjGenSts), sizeof (PjGenSts));
+   
+   if(action == LPJ_ZEROSTS)
+   {
+      genSts = &(gCb->pjGenSts);
+      PJ_MEM_SET (genSts, 0, sizeof (PjGenSts));
+   }
+
+   RETVALUE(LCM_REASON_NOT_APPL);
+} /* pjLmmGetGenSts */
+
+/**
+ * @brief
+     Gather the SAP statistics
+ *
+ *  @param[in] sts     LM general statistics structure
+ *  @param[in] elmnt   element 
+ *  @param[in] action  action 
+ *  @return  S16
+ *      -# Success : LCM_REASON_NOT_APPL
+ *      -# Failure : LCM_REASON_INVALID_PAR_VAL
+ */
+#ifdef ANSI
+PRIVATE S16 pjLmmGetSapSts
+(
+PjCb    *gCb,
+PjMngmt *sts,               /* PDCP layer management */
+Elmnt elmnt,                /* element */
+Action action               /* Action */
+)
+#else
+PRIVATE S16 pjLmmGetSapSts(gCb, sts, elmnt, action)
+PjCb    *gCb;
+PjMngmt *sts;               /* PDCP layer management */
+Elmnt elmnt;                /* element */
+Action action;              /* Action */
+#endif
+{
+   PjPjuSapCb   *pjuSapCb;      /* PDCP User SAP control block */
+   PjPjuSts     *pjuSap;        /* place holder for SAP statistics */
+
+   TRC2(pjLmmGetSapSts);
+
+   /* Validate protocol parameters */
+   if (action != LPJ_ZEROSTS && action != LPJ_NOZEROSTS)
+   {
+      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
+   }
+
+   pjuSap = &sts->t.sts.s.pjuSap;
+
+   /* Get Sap control block */
+   /* pj005.201, modified suId to spId */
+   
+   pjuSapCb = (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_DL)?               
+       (PjPjuSapCb*)(gCb->u.dlCb->pjuSap + pjuSap->spId):          
+       (PjPjuSapCb*)(gCb->u.ulCb->pjuSap + pjuSap->spId);          
+
+
+   pjuSap->rxSdus = pjuSapCb->sts.rxSdus;
+   pjuSap->txSdus = pjuSapCb->sts.txSdus;
+
+   if (action == LPJ_ZEROSTS)
+   {
+      PJ_MEM_SET (&pjuSapCb->sts, 0, sizeof (PjPjuSts));
+   }
+
+   SGetDateTime(&sts->t.sts.dt);
+
+   RETVALUE(LCM_REASON_NOT_APPL);
+} /* pjLmmGetSapSts */
+
+
+/**
+ * @brief
+    This function sends Unsolicited Status Indication to the Layer Management
+    Entity. 
+ *
+ *  @param[in] category  Category 
+ *  @param[in] event     event
+ *  @param[in] cause     cause
+ *  @param[in] cause     ueId 
+ *  @return  Void
+ */
+/* pj005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+#ifdef ANSI
+PUBLIC Void pjLmmSendAlarm
+(
+PjCb     *gCb,
+U16      category,  /* Category */
+U16      event,     /* Alarm event */
+U16      cause,     /* Alarm cause */
+SuId     suId,      /* suId */
+U32      ueId,      /* ueId */
+U8       qci        /* qci */
+)
+#else
+PUBLIC Void pjLmmSendAlarm(gCb, category, event, cause, suId, ueId, qci)
+PjCb     *gCb;
+U16      category;  /* Category */
+U16      event;     /* Alarm event */
+U16      cause;     /* Alarm cause */
+SuId     suId;      /* suId */
+U32      ueId;      /* ueId */
+U8       qci;       /* qci */
+#endif
+#else
+#ifdef ANSI
+PUBLIC Void pjLmmSendAlarm
+(
+PjCb     *gCb,
+U16      category,  /* Category */
+U16      event,     /* Alarm event */
+U16      cause,     /* Alarm cause */
+SuId     suId,      /* suId */
+U32      ueId       /* ueId */
+)
+#else
+PUBLIC Void pjLmmSendAlarm(gCb, category, event, cause, suId, ueId)
+PjCb     *gCb;
+U16      category;  /* Category */
+U16      event;     /* Alarm event */
+U16      cause;     /* Alarm cause */
+SuId     suId;      /* suId */
+U32      ueId;      /* ueId */
+#endif
+#endif
+{
+
+   PjMngmt usta;    /* Rlc Management Structure */
+
+   TRC2(pjLmmSendAlarm);
+
+   if(gCb->init.usta == FALSE)
+   {
+      RETVOID;
+   }
+
+   /* initialize the management structure */
+   PJ_MEM_SET(&usta, 0, sizeof(PjMngmt));
+
+   usta.hdr.elmId.elmnt = STGEN;
+   usta.hdr.entId.ent = gCb->init.ent;
+   usta.hdr.entId.inst = gCb->init.inst;
+
+   /* fill in the event and category */
+   usta.t.usta.alarm.category = category;
+   usta.t.usta.alarm.event = event;
+   usta.t.usta.alarm.cause = cause;
+
+   /* set the suId and ueId */
+   usta.t.usta.ueId = ueId;
+   usta.t.usta.suId = suId;
+   /* pj005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+   if(event == LPJ_EVT_MEAS_HALT)
+   {
+      usta.t.usta.qci = qci;
+   }
+#endif
+
+   /* update the date and time */
+   (Void) SGetDateTime(&usta.t.usta.alarm.dt);
+
+   PjMiLpjStaInd(&(gCb->init.lmPst), &usta);
+
+   RETVOID;
+
+} /* pjLmmSendAlarm */
+
+/**
+ * @brief
+    This function sends trace indication to LM 
+ *
+ *  @param[in] event    event
+ *  @param[in] mBuf     meessage buffer
+ *  @return S16
+ *      -# Success : ROK 
+ *      -# Failure : RFAILED 
+ */
+#ifdef ANSI
+PUBLIC S16 pjLmmSendTrc
+(
+PjCb  *gCb,
+Event event,                 /* event */
+Buffer *mBuf                 /* message buffer */
+)
+#else
+PUBLIC S16 pjLmmSendTrc(gCb, event, mBuf)
+PjCb  *gCb;
+Event event;                 /* event */
+Buffer *mBuf;                /* message buffer */
+#endif
+{
+   /* patch pj004.201 Corrected pjLmmSendTrc function definition */
+   PjMngmt trc;              /* PDCP management control block */
+   Buffer   *dstMbuf;   
+   MsgLen   bufLen;
+   Data     *tempBuf;
+   MsgLen   tempCnt;
+   Pst      pst;
+
+   TRC2(pjLmmSendTrc);
+
+   PJ_MEM_SET(&trc, 0, sizeof(PjMngmt));
+
+   cmMemset((U8 *)&trc, 0, sizeof(PjMngmt));
+
+   pst = gCb->init.lmPst;
+
+   trc.t.trc.event = event;
+   SGetDateTime(&trc.t.trc.dt);
+   trc.cfm.status = LCM_PRIM_OK;
+   trc.cfm.reason = LCM_REASON_NOT_APPL;
+    
+   if(mBuf != NULLP)
+   {
+     /* Check if the whole buffer is to be sent in Trace indication */
+     if(gCb->trcLen == LPJ_FULL_TRACE)
+     {
+        if (SCpyMsgMsg(mBuf, pst.region, pst.pool, &dstMbuf)
+            != ROK)
+        {
+           /* rg005.201 removed SPutSBuf on error */
+           RLOG0(L_DEBUG,"SCpyMsgMsg Failed.");
+           RETVALUE(RFAILED);
+        }
+        /* Send Trace Indication to Layer manager */
+        PjMiLpjTrcInd(&pst, &trc, dstMbuf);
+     }
+     /* check if only a specified number of bytes are to be sent */
+     else if(gCb->trcLen > 0)
+     {
+        /* Get the length of the recvd message buffer */
+        if (SFndLenMsg(mBuf, &bufLen) != ROK)
+        {
+           RLOG0(L_DEBUG, "SFndLenMsg Failed.");
+           RETVALUE(RFAILED);
+        }
+        /* Check if the recvd buffer size is less than request trace len */
+        if(bufLen < gCb->trcLen)
+        {
+           /* Copy the whole of the recvd buffer in trace indication */
+      
+           if (SCpyMsgMsg(mBuf, pst.region, pst.pool, &dstMbuf)
+              != ROK)
+           {
+              RLOG0(L_DEBUG, "pjLmmSendTrc(): SCpyMsgMsg Failed.");
+              RETVALUE(RFAILED);
+           }
+         
+           /* Send Trace Indication to Layer manager */
+           PjMiLpjTrcInd(&pst, &trc, dstMbuf);
+        }
+        /* if the recvd buffer size is greater than request trace len */
+        if(bufLen >= gCb->trcLen)
+        {
+           /* Get a temporary buffer to store the msg */
+           PJ_ALLOC(gCb, tempBuf, gCb->trcLen);
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+           if(tempBuf == NULLP)
+           {
+              (Void) SPutSMem(PJ_GET_MEM_REGION(gCb), PJ_GET_MEM_POOL(gCb));
+               RLOG0(L_FATAL, "Memory Allocation failed.");
+               RETVALUE(LCM_REASON_MEM_NOAVAIL);
+           }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+         
+           /* Copy trcLen nos of bytes from the recvd message */
+           if (SCpyMsgFix(mBuf,0,gCb->trcLen,tempBuf,&tempCnt) != ROK)   
+           {
+              RLOG0(L_DEBUG, "SCpyMsgFix Failed.");
+              RETVALUE(RFAILED);
+           }
+
+           if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
+           {
+              RLOG0(L_FATAL, "Memory Allocation failed.");
+              RETVALUE(RFAILED);
+           }
+           /* Copy the tempBuf data to dst mBuf */
+           if (SCpyFixMsg(tempBuf,dstMbuf,0,gCb->trcLen,&tempCnt) != ROK)
+           {
+              RLOG0(L_DEBUG, "SCpyFixMsg Failed.");
+              RETVALUE(RFAILED);
+           }
+  
+           /* Free the memory allocated for tempBuf */
+           PJ_FREE(gCb, tempBuf, gCb->trcLen);
+           /* Send Trace Indication to Layer manager */
+           PjMiLpjTrcInd(&pst, &trc, dstMbuf);
+        }
+     }
+   }
+   else
+   {
+      PjMiLpjTrcInd(&pst, &trc, mBuf);
+   }
+
+   RETVALUE(ROK);
+
+} /* end of pjLmmSendTrc */
+
+\f
+/*
+*
+*       Fun:   Activate Task - timer
+*
+*       Desc:  Invoked by system services to activate a task with
+*              a timer tick.
+*
+*       Ret:   ROK      - ok
+*
+*       Notes: None
+*
+*       File:  gp_lmm.c
+*
+*/
+#ifdef ANSI
+PUBLIC S16 pjActvTmr
+(
+Ent     ent,
+Inst    inst
+)
+#else
+PUBLIC S16 pjActvTmr(ent,inst)
+Ent     ent;
+Inst    inst;
+#endif
+{
+   PjCb  *gCb; 
+   TRC2(pjActvTmr)
+
+   if (inst >= PJ_MAX_PDCP_INSTANCES) 
+   {
+      RETVALUE (RFAILED);
+   }
+   gCb = PJ_GET_PJCB(inst); 
+   cmPrcTmr(&(gCb->pjTqCp), gCb->pjTq, (PFV) pjTmrExpiry);
+
+   RETVALUE(ROK);
+
+} /* end of pjActvTmr */
+
+/**
+ * @brief
+ it deregisters the timers and deregisters the kwuSap Control blocks
+ *
+ *  @return  Void
+ */
+#ifdef ANSI
+PRIVATE Void pjLmmCleanGblRsrcs
+(
+PjCb *gCb
+)
+#else
+PRIVATE Void pjLmmCleanGblRsrcs(gCb)
+PjCb *gCb;
+#endif
+{
+
+    TRC2(pjLmmCleanGblRsrcs)
+
+        if (gCb->init.cfgDone)
+        {
+            /* Deregister the timers */
+            (Void) SDeregTmrMt(gCb->init.ent, gCb->init.inst,
+                    (S16)gCb->pjGenCfg.timeRes, pjActvTmr);
+            /*(Void) SDeregTmr(gCb->init.ent, gCb->init.inst,
+              (S16)gCb->genCfg.timeRes, kwActvTmr);*/
+
+            if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_DL)
+            {
+                if (gCb->u.dlCb)
+                {
+                    if (gCb->u.dlCb->kwuSap != (PjKwuSapCb *)NULLP)
+                    {
+                        /*PJ_FREE(gCb,gCb->u.dlCb->kwuSap, kwSapSize); */
+                    }
+
+                    PJ_FREE(gCb,gCb->u.dlCb, sizeof (PjDlgCb));
+                }
+
+            }
+            else
+            {
+                if (gCb->u.ulCb)
+                {
+                    if (gCb->u.ulCb->kwuSap != (PjKwuSapCb *)NULLP)
+                    {
+                        /*PJ_FREE(gCb,gCb->u.ulCb->kwuSap, kwSapSize);*/
+                    }
+
+                    PJ_FREE(gCb,gCb->u.ulCb, sizeof (PjUlgCb));
+                }
+            }
+
+            (Void) SPutSMem(gCb->init.region, gCb->init.pool);
+            gCb->init.cfgDone = FALSE;
+            gCb->init.acnt = FALSE;
+            gCb->init.trc = FALSE;
+            gCb->init.usta = FALSE;
+        }
+    
+    RETVOID;
+} /* pjLmmCleanGblRsrcs */
+
+/********************************************************************30**
+
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_ptli.c b/src/5gnrpdcp/pj_ptli.c
new file mode 100755 (executable)
index 0000000..9fb1ab5
--- /dev/null
@@ -0,0 +1,627 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    RLC service user (PDCP) lower interface
+    
+        Type:    C file
+  
+        Desc:    This file Contains the RLC service user lower interface
+                  primitive implementain
+        File:    pj_ptli.c
+  
+*********************************************************************21*/
+\f
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "kwu.h"           /* KWU defines */
+#include "pj_err.h"        
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+//#if defined(PDCP_RLC_DL_RBUF)
+#include "ss_rbuf.h"
+#include "ss_rbuf.x"
+#include "kwu.h"                /* PJU */
+#include "ss_queue.h"
+#include "ss_queue.x"
+#include "ss_task.h"
+#include "ss_task.x"
+#include "ss_timer.x"           /* System services */
+#include "ss_msg.h"           /* System services */
+#include "ss_msg.x"           /* System services */
+#include "ss_mem.h"           /* System services */
+#include "ss_mem.x"           /* System services */
+#include "ss_drvr.x"
+#include "ss_gen.h"
+#include "ss_gen.x"
+//#endif
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "kwu.x"           /* KWU */
+
+
+PUBLIC U8 SUpdMbufMemInfo (Pst    *pst,Buffer *mBuf);
+#if defined(PDCP_RLC_DL_RBUF) && !defined(SS_RBUF)
+PUBLIC S16 pjKwuRbufDatReq(Pst * pst,SpId spId,KwuDatReqInfo* datReq,Buffer * mBuf);
+#endif
+
+EXTERN S16 PtLiKwuBndReq ARGS ((
+Pst         *post,
+SuId        suId,
+SpId        spId
+));
+
+EXTERN S16 PtLiKwuUbndReq ARGS ((
+Pst         *post,
+SpId        spId,
+Reason      reason
+));
+
+EXTERN S16 PtLiKwuDiscSduReq ARGS ((
+Pst               *post,
+SpId              spId,
+KwuDiscSduInfo    *discSdu
+));
+
+EXTERN S16 PtLiKwuDatReq ARGS ((
+Pst            *post,
+SpId           spId,
+KwuDatReqInfo  *datReq,
+Buffer         *mBuf
+));
+\f
+/************************************************************************
+                             KWU Interface Matrices
+************************************************************************/
+
+PUBLIC KwuBndReq pjLiKwuBndReqMt [] =
+{
+#ifdef LCKWUIKWU
+   cmPkKwuBndReq,        /* 0 - loosely coupled */
+#else
+   PtLiKwuBndReq,        /* 0 - loosely coupled, portable */
+#endif
+#ifdef KW
+   KwUiKwuBndReq,        /* 1 - tightly coupled, stub layer */
+#else
+   PtLiKwuBndReq,        /* 1 - tightly coupled, portable */
+#endif
+#ifdef LWLCKWUIKWU
+   cmPkKwuBndReq,        /* 3 - light weight loosely coupled */
+#else
+   PtLiKwuBndReq,        /* 3 - light weight loosely coupled, portable */
+#endif
+};
+
+PUBLIC KwuUbndReq pjLiKwuUbndReqMt [] =
+{
+#ifdef LCKWUIKWU 
+   cmPkKwuUbndReq,        /* 0 - loosely coupled */
+#else
+   PtLiKwuUbndReq,        /* 0 - loosely coupled, portable */
+#endif
+#ifdef KW
+   KwUiKwuUbndReq,        /* 1 - tightly coupled, stub layer */
+#else
+   PtLiKwuUbndReq,        /* 1 - tightly coupled, portable */
+#endif
+#ifdef LWLCKWUIKWU 
+   cmPkKwuUbndReq,        /* 3 - light weight loosely coupled */
+#else
+   PtLiKwuUbndReq,        /* 3 - light weight loosely coupled, portable */
+#endif
+};
+
+PUBLIC KwuDatReq pjLiKwuDatReqMt [] =
+{
+#ifdef LCKWUIKWU
+   cmPkKwuDatReq,        /* 0 - loosely coupled */
+#else
+   PtLiKwuDatReq,        /* 0 - loosely coupled, portable */
+#endif
+#ifdef KW
+   KwUiKwuDatReq,        /* 1 - tightly coupled, stub layer */
+#else
+   PtLiKwuDatReq,        /* 1 - tightly coupled, portable */
+#endif
+#ifdef LWLCKWUIKWU
+   cmPkKwuDatReq,        /* 3 - light weight loosely coupled */
+#else
+   PtLiKwuDatReq,        /* 3 - light weight loosely coupled, portable */
+#endif
+};
+
+PUBLIC KwuDiscSduReq pjLiKwuDiscSduReqMt [] =
+{
+#ifdef LCKWUIKWU
+   cmPkKwuDiscSduReq,        /* 0 - loosely coupled */
+#else
+   PtLiKwuDiscSduReq,        /* 0 - loosely coupled, portable */
+#endif
+#ifdef KW
+   KwUiKwuDiscSduReq,        /* 1 - tightly coupled, stub layer */
+#else
+   PtLiKwuDiscSduReq,        /* 1 - tightly coupled, portable */
+#endif
+#ifdef LWLCKWUIKWU
+   cmPkKwuDiscSduReq,        /* 3 - light weight loosely coupled */
+#else
+   PtLiKwuDiscSduReq,        /* 3 - light weight loosely coupled, portable */
+#endif
+};
+
+\f
+/****************************************************************************
+ *                         KWU Interface Mt functions
+ ***************************************************************************/
+/**
+ *
+ * @brief 
+ *
+ *        PjLiKwuBndReq - KWU SAP bind Request
+ *
+ *  @param[in] pst   - Post structure  
+ *  @param[in] suId  - Service user SAP ID 
+ *  @param[in] spId  - Service provider ID
+ *
+ *  @return  S16
+ *      -# ROK 
+ */
+#ifdef ANSI
+PUBLIC S16 PjLiKwuBndReq
+(
+Pst *pst,                       /* post structure */
+SuId suId,                      /* Service User Id */
+SpId spId                       /* Service Provider Id */
+)
+#else
+PUBLIC S16 PjLiKwuBndReq(pst, suId, spId)
+Pst *pst;                       /* post structure */
+SuId suId;                      /* Service User Id */
+SpId spId;                      /* Service Provider Id */
+#endif
+{
+   TRC3(PjLiKwuBndReq)
+
+   /* jump to specific primitive depending on configured selector */
+   (*pjLiKwuBndReqMt[pst->selector])(pst, suId, spId);
+
+   RETVALUE(ROK);
+
+} /* end of PjLiKwuBndReq */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        PjLiKwuUbndReq - KWU SAP unbind Request
+ *
+ *  @param[in] pst     - Post structure  
+ *  @param[in] spId    - Service provider SAP ID 
+ *  @param[in] reason  - Reason
+ *
+ *  @return  S16
+ *      -# ROK 
+ */
+#ifdef ANSI
+PUBLIC S16 PjLiKwuUbndReq
+(
+Pst         *pst,
+SpId        spId,
+Reason      reason
+)
+#else
+PUBLIC S16 PjLiKwuUbndReq(pst, spId, reason)
+Pst         *pst;
+SpId        spId;
+Reason      reason;
+#endif
+{
+   TRC3(PjLiKwuUbndReq)
+
+   /* jump to specific primitive depending on configured selector */
+   (*pjLiKwuUbndReqMt[pst->selector])(pst, spId, reason);
+
+   RETVALUE(ROK);
+
+} /* end of PjLiKwuUbndReq */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        PjLiKwuDatReq - KWU Data Request
+ *
+ *  @param[in] pst     - Post structure  
+ *  @param[in] spId    - Service provider SAP ID 
+ *  @param[in] datReq  - Data Request
+ *
+ *  @return  S16
+ *      -# ROK 
+ */
+#ifdef ANSI
+PUBLIC S16 PjLiKwuDatReq
+(
+Pst            *pst,
+SpId           spId,
+KwuDatReqInfo  *datReq,
+Buffer         *mBuf
+)
+#else
+PUBLIC S16 PjLiKwuDatReq(pst, spId, datReq, mBuf)
+Pst            *pst;
+SpId           spId;
+KwuDatReqInfo  *datReq;
+Buffer         *mBuf;
+#endif
+{
+   S16 ret = ROK;
+
+   TRC3(PjLiKwuDatReq)
+#if defined(PDCP_RLC_DL_RBUF) && !defined(SS_RBUF)
+   if(datReq->lcType == CM_LTE_LCH_DTCH)
+   {
+      if((pjKwuRbufDatReq(pst,spId, datReq, mBuf)) != ROK)
+      {
+         /* Posting the message as ring buffer write failure */
+         ret = RFAILED;
+      }
+   }
+   else
+#endif
+   {   
+      /* jump to specific primitive depending on configured selector */
+      ret = (*pjLiKwuDatReqMt[pst->selector])(pst, spId, datReq, mBuf);
+   }
+   RETVALUE(ret);
+
+} /* end of PjLiKwuDatReq */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        PjLiKwuDiscSduReq - KWU Discard SDU Request
+ *
+ *  @param[in] pst     - Post structure  
+ *  @param[in] spId    - Service provider SAP ID 
+ *  @param[in] datReq  - Data Request
+ *
+ *  @return  S16
+ *      -# ROK 
+ */
+#ifdef ANSI
+PUBLIC S16 PjLiKwuDiscSduReq
+(
+Pst               *pst,
+SpId              spId,
+KwuDiscSduInfo    *discSdu
+)
+#else
+PUBLIC S16 PjLiKwuDiscSduReq(pst, spId, discSdu)
+Pst               *pst;
+SpId              spId;
+KwuDiscSduInfo    *discSdu;
+#endif
+{
+   TRC3(PjLiKwuDiscSduReq)
+
+   /* jump to specific primitive depending on configured selector */
+   (*pjLiKwuDiscSduReqMt[pst->selector])(pst, spId, discSdu);
+
+   RETVALUE(ROK);
+
+} /* end of PjLiKwuDiscSduReq */
+
+/****************************************************************************
+ *                         Porting Functions
+ ***************************************************************************/
+/**
+ *
+ * @brief 
+ *
+ *        PtLiKwuBndReq - portable bind request
+ *
+ *  @param[in] pst   - Post structure  
+ *  @param[in] suId  - Service user SAP ID 
+ *  @param[in] spId  - Service provider ID
+ *
+ *  @return  S16
+ *      -# ROK 
+ */
+
+#ifdef ANSI
+PUBLIC S16 PtLiKwuBndReq
+(
+Pst         *post,
+SuId        suId,
+SpId        spId
+)
+#else
+PUBLIC S16 PtLiKwuBndReq(post, suId, spId)
+Pst         *post;
+SuId        suId;
+SpId        spId;
+#endif /* ANSI */
+{
+   TRC3(PtLiKwuBndReq)
+#if (ERRCLASS & ERRCLS_DEBUG)
+ /*  S16 ret1;    */
+   SLogError(post->srcEnt, post->srcInst, post->srcProcId,
+        __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
+         (ErrVal)EPJXXX, (ErrVal)ERRZERO, "Improper selector for NhLiKwuBndReq\n");
+   RETVALUE( RFAILED );
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+   UNUSED(post);
+   UNUSED(suId);
+   UNUSED(spId);
+
+   RETVALUE(ROK);
+} /* end of PtLiKwuBndReq() */
+
+\f  
+/**
+ *
+ * @brief 
+ *
+ *        PtLiKwuUbndReq - portable unbind request
+ *
+ *  @param[in] pst     - Post structure  
+ *  @param[in] suId    - Service provider SAP ID 
+ *  @param[in] reason  - Reason
+ *
+ *  @return  S16
+ *      -# ROK 
+ */
+#ifdef ANSI
+PUBLIC S16 PtLiKwuUbndReq
+(
+Pst         *post,
+SpId        spId,
+Reason      reason
+)
+#else
+PUBLIC S16 PtLiKwuUbndReq(post, spId, reason)
+Pst         *post;
+SpId        spId;
+Reason      reason;
+#endif /* ANSI */
+{
+   TRC3(PtLiKwuUbndReq)
+#if (ERRCLASS & ERRCLS_DEBUG)
+  /* S16 ret1; */
+   SLogError(post->srcEnt, post->srcInst, post->srcProcId,
+        __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
+         (ErrVal)EPJXXX, (ErrVal)ERRZERO, "Improper selector for NhLiKwuUbndReq\n");
+   RETVALUE( RFAILED );
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+   UNUSED(post);
+   UNUSED(spId);
+   UNUSED(reason);
+   
+   RETVALUE(ROK);
+} /* end of PtLiKwuUbndReq() */
+
+/**
+ *
+ * @brief 
+ *
+ *        PtLiKwuDiscSduReq - portable discard SDU request
+ *
+ *  @param[in] pst     - Post structure  
+ *  @param[in] spId    - Service provider SAP ID 
+ *  @param[in] datReq  - Data Request
+ *
+ *  @return  S16
+ *      -# ROK 
+ */
+#ifdef ANSI
+PUBLIC S16 PtLiKwuDiscSduReq
+(
+Pst               *post,
+SpId              spId,
+KwuDiscSduInfo    *discSdu
+)
+#else
+PUBLIC S16 PtLiKwuDiscSduReq(post, spId, discSdu)
+Pst               *post;
+SpId              spId;
+KwuDiscSduInfo    *discSdu;
+#endif /* ANSI */
+{
+   TRC3(PtLiKwuDiscSduReq)
+#if (ERRCLASS & ERRCLS_DEBUG)
+  /* S16 ret1; */
+   SLogError(post->srcEnt, post->srcInst, post->srcProcId,
+        __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
+         (ErrVal)EKWU010, (ErrVal)ERRZERO, "Improper selector for NhLiKwuDiscSduReq\n");
+   RETVALUE( RFAILED );
+
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+   UNUSED(post);
+   UNUSED(spId);
+   UNUSED(discSdu);
+
+   RETVALUE(ROK);
+} /* end of PtLiKwuDiscSduReq() */
+
+/**
+ *
+ * @brief 
+ *
+ *        PtLiKwuDatReq - portable data request
+ *
+ *  @param[in] pst     - Post structure  
+ *  @param[in] spId    - Service provider SAP ID 
+ *  @param[in] datReq  - Data Request
+ *
+ *  @return  S16
+ *      -# ROK 
+ */
+#ifdef ANSI
+PUBLIC S16 PtLiKwuDatReq
+(
+Pst            *pst,
+SpId           spId,
+KwuDatReqInfo  *datReq,
+Buffer         *mBuf
+)
+#else
+PUBLIC S16 PtLiKwuDatReq(pst, spId, datReq, mBuf)
+Pst            *pst;
+SpId           spId;
+KwuDatReqInfo  *datReq;
+Buffer         *mBuf;
+#endif /* ANSI */
+{
+   TRC3(PtLiKwuDatReq)
+#if (ERRCLASS & ERRCLS_DEBUG)
+  /* S16 ret1; */
+   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+        __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
+         (ErrVal)EPJXXX, (ErrVal)ERRZERO, "Improper selector for NhLiKwuDatReq\n");
+   RETVALUE( RFAILED );
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+   UNUSED(pst);
+   UNUSED(spId);
+   UNUSED(datReq);
+   UNUSED(mBuf);
+
+   RETVALUE(ROK);
+} /* end of PtLiKwuDatReq() */
+/*
+*
+*       Fun:   SUpdMbufMemInfo
+*
+*       Desc:  This function is used to get the mem region info of a task.
+*
+*       Ret:   ROK      - ok
+*              RFAILED  - failed, general (optional)
+*
+*
+*       File:  ss_task.c
+*
+*/
+#ifdef TENB_T2K3K_SPECIFIC_CHANGES
+#ifdef ANSI
+PUBLIC U8 SUpdMbufMemInfo 
+(
+Pst    *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC U8 SUpdMbufMemInfo(pst,mBuf)
+Pst    *pst;
+Buffer *mBuf;
+#endif
+{
+   SsMsgInfo *minfo;
+   SsTTskEntry *tTsk;
+   SsIdx       dstIdx;
+
+
+   minfo = (SsMsgInfo*) mBuf->b_rptr;
+
+   dstIdx = osCp.tTskIds[pst->dstEnt][pst->dstInst];
+   tTsk = &osCp.tTskTbl[dstIdx];
+#ifdef SS_MULTICORE_SUPPORT
+   minfo->region = tTsk->sTsk->region;
+#endif /* SS_MULTICORE_SUPPORT */
+   RETVALUE(ROK);
+}
+#endif
+
+#if defined(PDCP_RLC_DL_RBUF) && !defined(SS_RBUF)
+#ifdef ANSI
+PUBLIC S16 pjKwuRbufDatReq
+(
+Pst * pst,
+SpId spId,
+KwuDatReqInfo* datReq,
+Buffer * mBuf
+)
+#else
+PUBLIC S16 pjKwuRbufDatReq(pst, spId, datReq, mBuf)
+Pst * pst;
+SpId spId;
+KwuDatReqInfo* datReq;
+Buffer * mBuf;
+#endif
+{
+   S16 ret1 = ROK;
+   
+   Void *elem = NULLP;
+   KwuDatReqDetl *kwuDatReqDetl = NULLP;
+
+   elem = SRngGetWIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
+   if (NULLP != elem)
+   {
+      kwuDatReqDetl = (KwuDatReqDetl *) elem;
+      kwuDatReqDetl->spId = spId;
+      kwuDatReqDetl->lcType = datReq->lcType;
+      kwuDatReqDetl->sduId = datReq->sduId;
+      kwuDatReqDetl->rlcId = datReq->rlcId;
+      kwuDatReqDetl->mBuf = mBuf;
+      /* Commenting below function because memory region mapped with threadId*/
+      /* SUpdMbufMemInfo(pst, mBuf);*/
+      SRngIncrWIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
+      SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].pktRate++;
+   }   
+   else
+   {
+#if (ERRCLASS & ERRCLS_DEBUG)
+       SLogError(ENTPJ, 0, SFndProcId(),
+               __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
+               (ErrVal)EPJXXX, (ErrVal)ERRZERO, "PDCP-DL RBUF is FULL!!!\n");
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+      SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].pktDrop++;
+      ret1 = RFAILED;
+   }
+   RETVALUE(ret1);
+} /* cmPkKwuDatReq */
+
+#endif /* PDCP_RLC_DL_RBUF */
+
+\f  
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_ptlib.c b/src/5gnrpdcp/pj_ptlib.c
new file mode 100755 (executable)
index 0000000..f75e23a
--- /dev/null
@@ -0,0 +1,2343 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    RLC service user (PDCP) lower interface
+    
+        Type:    C file
+  
+        Desc:    This file Contains the RLC service user lower interface
+                  primitive implementain
+        File:    pj_ptlib.c
+  
+*********************************************************************21*/
+
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "kwu.h"           /* KWU defines */
+#include "pju.h"           /* PJU defines */
+/*#include "rgu.h"*/           /* RGU defines */
+#include "cpj.h"           /* CPJ defines */
+#include "lpj.h"           /* LPJ defines */
+#include "pju.h"           /* PJU defines */
+#include "pj_env.h"        /* RLC environment options */
+#include "pj.h"            /* RLC defines */
+#include "pj_dl.h"
+#include "pj_ptsec.h"
+#ifdef INTEL_NATIVE_SPACC
+#include "elpspaccusr.h"
+#endif
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
+#include "ss_rbuf.h"
+#include "ss_rbuf.x"
+#include "kwu.h"                /* PJU */
+#include "ss_queue.h"
+#include "ss_queue.x"
+#include "ss_task.h"
+#include "ss_task.x"
+#include "ss_timer.x"           /* System services */
+#include "ss_msg.h"           /* System services */
+#include "ss_msg.x"           /* System services */
+#include "ss_mem.h"           /* System services */
+#include "ss_mem.x"           /* System services */
+#include "ss_drvr.x"
+#include "ss_gen.h"
+#include "ss_gen.x"
+#endif
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#ifdef TENB_AS_SECURITY
+#include "mt_plat_t33.h"
+#include "mt_plat_t33.x"
+#endif
+#include "kwu.x"           /* KWU */
+#include "pju.x"           /* PJU */
+/*#include "rgu.x" */          /* RGU */
+#include "cpj.x"           /* CPJ */
+#include "lpj.x"           /* LPJ */
+#include "pju.x"           /* PJU */
+#include "pj.x"
+#include "pj_udx.h"          /* LIB */
+#include "pj_udx.x"          /* LIB */
+#include "pj_dl.x"
+#include "pj_ul.x"
+#include "pj_ptsec.x"
+#include "pj_lib.x"     /* LIB */
+
+#ifdef TENB_AS_SECURITY
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_FILE_ID=293;
+static int RLOG_MODULE_ID=1024;
+#endif
+
+#ifdef TENB_T2K3K_SPECIFIC_CHANGES
+extern U32 isMemThreshReached(Region region);
+#endif
+#ifdef TENB_AS_SECURITY
+PUBLIC U32 pjMsSpaccHdlOpenReq(PTR *fd);
+PUBLIC U32 pjMsSpaccHdlCloseReq(PTR *fd);
+PUBLIC U32 pjMsSpaccCipherPkt(PjMsSecInfo *pSec, Buffer *mBuf);
+PUBLIC U32 pjMsSpaccIntegProtPkt(PjLibTrans *libTrans, Buffer **mBuf);
+
+PRIVATE S16 pjExtractTxEntRbCbUsingSpaccMappingInfo ARGS ((
+PjMsSPACCOutputMapInfo *spaccInfo,
+PjCb   **gCb,
+PjDlRbCb **pjRbCb,
+PjTxEnt  **txEnt
+));
+
+
+
+PRIVATE Void pjMsSpaccProcessDlBatchOutput ARGS ((Void));
+PRIVATE Void pjMsSpaccProcessUlBatchOutput ARGS((Void));
+PUBLIC U32 pjMsCheckSpaccQueue(Bool isUl);
+PUBLIC Void pjSpaccDeInitCiphQ(Void);
+PUBLIC Void pjSpaccDeInitDeCipherQ(Void);
+#endif
+
+#ifdef PTPJLIB
+#ifdef PJ_CMP_ASYNC
+/************************************************************************
+                             PJU Interface Matrices
+************************************************************************/
+\f
+/****************************************************************************
+ *                         PJU Interface Mt functions
+ ***************************************************************************/
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdCmpInitReq
+(
+Pst * pst,
+PjCmpCxt cmpCxt,
+PjRohc rohc
+)
+#else
+PUBLIC S16 PjLibObdCmpInitReq(pst, cmpCxt, rohc)
+Pst * pst;
+PjCmpCxt cmpCxt;
+PjRohc rohc;
+#endif
+{
+
+   TRC3(PjLibObdCmpInitReq)
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdCmpReq
+(
+Pst * pst,
+PTR cmpCxtId,
+PjLibTrans libTrans,
+Buffer * mBuf
+)
+#else
+PUBLIC S16 PjLibObdCmpReq(pst, cmpCxtId, libTrans, mBuf)
+Pst * pst;
+PTR cmpCxtId;
+PjLibTrans libTrans;
+Buffer * mBuf;
+#endif
+{
+
+   TRC3(PjLibObdCmpReq)
+
+   RETVALUE(ROK);
+
+}
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdDecmpReq
+(
+Pst * pst,
+PTR cmpCxtId,
+PjLibTrans libTrans,
+Buffer * mBuf
+)
+#else
+PUBLIC S16 PjLibObdDecmpReq(pst, cmpCxtId, libTrans, mBuf)
+Pst * pst;
+PTR cmpCxtId;
+PjLibTrans libTrans;
+Buffer * mBuf;
+#endif
+{
+
+   TRC3(PjLibObdDecmpReq)
+
+   RETVALUE(ROK);
+
+}
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdCmpCloseReq
+(
+Pst * pst,
+PTR cmpCxtId
+)
+#else
+PUBLIC S16 PjLibObdCmpCloseReq(pst, cmpCxtId)
+Pst * pst;
+PTR cmpCxtId;
+#endif
+{
+
+   TRC3(PjLibObdCmpCloseReq)
+
+   RETVALUE(ROK);
+
+}
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdCmpResetReq
+(
+Pst * pst,
+PTR cmpCxtId
+)
+#else
+PUBLIC S16 PjLibObdCmpResetReq(pst, cmpCxtId)
+Pst * pst;
+PTR cmpCxtId;
+#endif
+{
+
+   TRC3(PjLibObdCmpResetReq)
+
+   RETVALUE(ROK);
+
+}
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdCmpFbReq
+(
+Pst * pst,
+PTR cmpCxtId,
+PjLibTrans libTrans,
+Buffer *feedback
+)
+#else
+PUBLIC S16 PjLibObdCmpFbReq(pst, cmpCxtId, libTrans, feedback)
+Pst * pst;
+PTR cmpCxtId;
+PjLibTrans libTrans;
+Buffer *feedback;
+#endif
+{
+
+   TRC3(PjLibObdCmpFbReq)
+
+   RETVALUE(ROK);
+
+}
+
+#else
+#ifdef ANSI
+PUBLIC S16 PjLibObdCipherCloseReq
+(
+Void *cpCxtId
+)
+#else
+PUBLIC S16 PjLibObdCipherCloseReq(cpCxtId)
+Void *cpCxtId
+#endif
+{
+   TRC3(PjLibObdCipherCloseReq)
+
+#ifdef INTEL_SPACC_IV_OPTIMIZATION
+   pjNSpaccReturnStreamIdToPool(cpCxtId);
+#endif
+   RETVALUE(ROK);
+
+}
+
+#ifdef ANSI
+PUBLIC S16 pjLibCmpInitReq 
+(
+PjCmpCxt cmpCxt,                  /* Context for ROHC */
+PjRohc   rohc,                    /* ROHC Config Info */
+PTR      *cmpCxtId                /* Compression Context ID */
+)
+#else
+PUBLIC S16 pjLibCmpInitReq(cmpCxt, rohc, cmpCxtId)
+PjCmpCxt cmpCxt;                  /* Context for ROHC */
+PjRohc   rohc;                    /* ROHC Config Info */
+PTR      *cmpCxtId;               /* Compression Context ID */
+#endif
+{
+   TRC3(pjLibCmpInitReq)
+
+   RETVALUE(ROK);
+
+} /* end of pjLibCmpInitReq */
+
+#ifdef ANSI
+PUBLIC S16 pjLibCmpReq 
+(
+PTR      cmpCxtId,                /* Context Id for compression */
+Buffer   *mBuf,                   /* SDU to be compressed */
+Buffer   **opSdu                  /* Compressed SDU */
+)
+#else
+PUBLIC S16 pjLibCmpReq(cmpCxtId, mBuf, opSdu)
+PTR      cmpCxtId;                /* Context Id for compression */
+Buffer   *mBuf;                   /* SDU to be compressed */
+Buffer   **opSdu;                 /* Compressed SDU */
+#endif
+{
+   TRC3(pjLibCmpReq)
+
+   RETVALUE(ROK);
+
+} /* end of pjLibCmpReq */
+
+#ifdef ANSI
+PUBLIC S16 pjLibDecmpReq 
+(
+PTR      cmpCxtId,                /* Context Id for compression */
+Buffer   *mBuf,                   /* SDU to be decompressed */
+Buffer   **feedback,                 /* Decompressed SDU */
+Buffer   **opSdu               /* ROHC feedback buffer */
+)
+#else
+PUBLIC S16 pjLibDecmpReq(cmpCxtId, mBuf, feedback, opSdu)
+PTR      cmpCxtId;                /* Context Id for compression */
+Buffer   *mBuf;                   /* SDU to be decompressed */
+Buffer   **feedback;                 /* Decompressed SDU */
+Buffer   **opSdu;              /* ROHC feedback buffer */
+#endif
+{
+   TRC3(pjLibDecmpReq)
+
+   RETVALUE(ROK);
+
+} /* end of pjLibDecmpReq */
+
+#ifdef ANSI
+PUBLIC S16 pjLibCmpCloseReq
+(
+PTR      cmpCxtId                 /* ROHC Context to be closed */
+)
+#else
+PUBLIC S16 pjLibCmpCloseReq(cmpCxtId)
+PTR      cmpCxtId;                /* ROHC Context to be closed */
+#endif
+{
+   TRC3(pjLibCmpCloseReq)
+
+   RETVALUE(ROK);
+
+} /* end of pjLibCmpCloseReq */
+
+#ifdef ANSI
+PUBLIC S16 pjLibCmpResetReq
+(
+PTR      cmpCxtId                 /* ROHC Context to be closed */
+)
+#else
+PUBLIC S16 pjLibCmpResetReq(cmpCxtId)
+PTR      cmpCxtId;                /* ROHC Context to be closed */
+#endif
+{
+   TRC3(pjLibCmpResetReq)
+
+   RETVALUE(ROK);
+
+} /* end of pjLibCmpResetReq */
+
+#ifdef ANSI
+PUBLIC S16 pjLibCmpFbReq
+(
+PTR      cmpCxtId,                /* ROHC Context to be closed */
+Buffer   *feedback                /* Feed back */
+)
+#else
+PUBLIC S16 pjLibCmpFbReq(cmpCxtId, feedback)
+PTR      cmpCxtId;                /* ROHC Context to be closed */
+Buffer   *feedback;               /* Feed back */
+#endif
+{
+   TRC3(pjLibCmpFbReq)
+
+   RETVALUE(ROK);
+
+} /* end of pjLibCmpFbReq */
+
+#endif /* PJ_CMP_ASYNC */
+
+#ifdef ANSI
+PUBLIC S16 pjLibIntInitReq 
+(
+PjSecCxt secCxt,                  /* Context for Intg protection/verification */
+PjIntInfo intInfo,                /* Integrity Cfg Info */
+Void      **cxtId                 /* FD */
+)
+#else
+PUBLIC S16 pjLibIntInitReq(secCxt, intInfo, cxtId)
+PjSecCxt secCxt;                  /* Context for Intg protection/verification */
+PjIntInfo intInfo;                /* Integrity Cfg Info */
+Void      **cxtId;                /* FD */
+#endif
+{
+   S16   ret = ROK;
+
+   TRC3(pjLibIntInitReq)
+
+   RETVALUE(ret);
+
+} /* end of pjLibIntInitReq */
+
+#ifdef ANSI
+PUBLIC S16 pjLibCpInitReq
+(
+PjSecCxt secCxt,                  /* Context for Intg protection/verificatino */
+U8       algoType,                /* Type of the algorithm */
+U8       *cpKey,                  /* Control plane ciphering key */
+Void     **cxtId                  /* FD */
+)
+#else
+PUBLIC S16 pjLibCpInitReq(secCxt, algoType, cpKey, cxtId)
+PjSecCxt secCxt;                  /* Context for Intg protection/verificatino */
+U8       algoType;                /* Type of the algorithm */
+U8       *cpKey;                  /* Control plane ciphering key */
+Void     **cxtId;                 /* FD */
+#endif
+{
+   S16   ret = ROK;
+
+   TRC3(pjLibCpInitReq)
+
+   RETVALUE(ret);
+
+} /* end of pjLibCpInitReq */
+
+#ifdef ANSI
+PUBLIC S16 pjLibUpInitReq
+(
+PjSecCxt secCxt,                  /* Context for Intg protection/verificatino */
+U8       algoType,                /* Type of the algorithm */
+U8       *upKey,                  /* User plane ciphering key */
+Void     **cxtId                  /* FD */
+)
+#else
+PUBLIC S16 pjLibUpInitReq(secCxt, algoType, upKey, cxtId)
+PjSecCxt secCxt;                  /* Context for Intg protection/verificatino */
+U8       algoType;                /* Type of the algorithm */
+U8       *upKey;                  /* User plane ciphering key */
+Void     **cxtId;                 /* FD */
+#endif
+{
+   TRC3(pjLibUpInitReq)
+
+#ifdef INTEL_SPACC_IV_OPTIMIZATION
+   if(PJ_SEC_DIR_DL == secCxt.dir)
+   {
+      pjMsNSpaccIVPrepStreamIdForDl(cxtId);
+   }
+   else
+   {
+      pjMsNSpaccIVPrepStreamIdForUl(cxtId);
+   }   
+#endif
+   RETVALUE(ROK);
+
+} /* end of pjLibUpInitReq */
+
+
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdCpInitReq
+(
+PjSec *secInp
+)
+#else
+PUBLIC S16 PjLibObdCpInitReq(*secInp)
+PjSec *secInp;
+#endif
+{
+   TRC3(PjLibObdCpInitReq)
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdUpInitReq
+(
+PjSec *secInp
+)
+#else
+PUBLIC S16 PjLibObdUpInitReq(*secInp)
+PjSec *secInp
+#endif
+{
+   TRC3(PjLibObdUpInitReq)
+   RETVALUE(ROK);
+}
+
+#ifdef TENB_AS_SECURITY
+
+/**
+ *
+ * @brief Extracting gCb, rbCb, txEnt from SPAcc Mapping Information.
+ *       
+ *
+ * @b Description: This function extracts gCb, rbCb, txEnt from SPAcc mapping
+ * info which is passed as one of the input params.
+ *
+ *
+ *  @param[in] spaccInfo : Information required to map o/p PDU from SPACc to
+ *  PDCP TxEnt.
+ *  @param[in] gCb       : PDCP Control Block
+ *  @param[in] pjRbCb    : PDCP rbCb
+ *  @param[in] txEnt     : PDCP TxEnt
+ *
+ * 
+ *  @return  Void
+ */
+
+#ifdef ANSI
+PRIVATE S16 pjExtractTxEntRbCbUsingSpaccMappingInfo 
+(
+PjMsSPACCOutputMapInfo *spaccInfo,
+PjCb   **gCb,
+PjDlRbCb **pjRbCb,
+PjTxEnt  **txEnt
+)
+#else
+PRIVATE S16 pjExtractTxEntRbCbUsingSpaccMappingInfo(spaccInfo, gCb, pjRbCb, txEnt)
+PjMsSPACCOutputMapInfo *spaccInfo;
+PjCb   **gCb;
+PjDlRbCb **pjRbCb;
+PjTxEnt  **txEnt;
+#endif
+{
+   PjDlUeCb   *ueCb = NULLP;
+
+   *gCb = PJ_GET_PJCB(spaccInfo->pdcpInstance);
+
+   pjDbmFetchDlUeCb(*gCb, spaccInfo->pdcpId.ueId,spaccInfo->pdcpId.cellId, &ueCb);
+
+   if(ueCb  == NULLP)
+   {
+      RLOG_ARG0(L_ERROR,DBG_UEID,spaccInfo->pdcpId.ueId,"UECB not found !!!! ");
+      RETVALUE(RFAILED);
+   }
+
+
+   pjDbmFetchPjDlRbCb(ueCb, spaccInfo->pdcpId.rbId, spaccInfo->pdcpId.rbType, pjRbCb);
+   if(*pjRbCb  == NULLP)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,spaccInfo->pdcpId.ueId, 
+            "CellId[%u]:RbId[%d] not found",
+            spaccInfo->pdcpId.cellId, spaccInfo->pdcpId.rbId);
+      RETVALUE(RFAILED);
+   }
+
+   *txEnt = (PjTxEnt *)pjDbmGetTxEnt(*gCb, &((*pjRbCb)->dlCb.txBuf),
+         spaccInfo->count);
+
+   if(*txEnt == NULLP)
+   {
+      RLOG_ARG0(L_ERROR,DBG_UEID,spaccInfo->pdcpId.ueId,"!!!!rxEnt is NULL!!!!");
+      RETVALUE(RFAILED);
+   }
+
+   RETVALUE(ROK);
+}
+
+
+/**
+ *
+ * @brief Handler for Processing Ciphered PDU's from SPAcc.
+ *       
+ *
+ * @b Description: This function processes and extracts the required control
+ * blocks for the ciphered PDU  and calls the function for to be processed
+ * further.
+ *
+ *  @param[in] spaccOpInfo : Information required to process PDU
+ *  @param[in] opSdu    : Ciphered buffer
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjProcCiphPdu 
+(
+Buffer *opSdu,
+PjMsSPACCOutputMapInfo *spaccOpInfo
+)
+#else
+PUBLIC S16 pjProcCiphPdu(opSdu, spaccOpInfo)
+Buffer *opSdu;
+PjMsSPACCOutputMapInfo *spaccOpInfo;
+#endif
+{
+   U32 ret;
+   PjCb   *gCb = NULLP;
+   PjDlRbCb *pjRbCb = NULLP;
+   PjTxEnt  *txEnt = NULLP;
+
+   /* Extract gCb, rbCb and txEnt for further processing */
+   ret = pjExtractTxEntRbCbUsingSpaccMappingInfo(spaccOpInfo, &gCb, &pjRbCb, &txEnt);
+
+   if(ret != ROK)
+   {
+      RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,
+            "pjExtractTxEntRbCbUsingSpaccMappingInfo: returned failure ");
+      PJ_FREE_BUF(opSdu);
+      RETVALUE(RFAILED);
+   }
+   else
+   {
+      if(pjRbCb->rbType == PJ_SRB)
+      {
+        if(txEnt->pdu != NULLP)
+        {
+            PJ_FREE_BUF(txEnt->pdu);
+        }
+      }
+      /* In case of Reestablish/HO , dropping the ciphered packets. These packets
+       * are processed again when events EVTCPJDATRESUMEREQ/EVTPJUDATFWDREQ are 
+       * received from upper layer */ 
+      if((pjRbCb->ueCb->libInfo.state != PJ_STATE_NORMAL) && (pjRbCb->rbType != PJ_SRB))
+      {
+             RLOG_ARG0(L_INFO,DBG_UEID,spaccOpInfo->pdcpId.ueId,
+               "Dropping the packet in reestablish state "); 
+             PJ_FREE_BUF(opSdu);
+             RETVALUE(RFAILED);
+      }
+      txEnt->pdu = opSdu;
+
+      /* Call to deliver PDU to RLC */
+      ret = pjDlmDeliverPdu(gCb, pjRbCb, txEnt);
+      if(ret != ROK)
+      {
+         RETVALUE(RFAILED);
+         RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,
+               "pjProcCiphPdu: pjDlmDeliverPdu failed !!!!");   
+      }
+   }
+
+   RETVALUE(ROK);
+}
+
+
+/**
+ *
+ * @brief Handler for Ciphering failure 
+ *       
+ *
+ * @b Description: This function handles the steps to be taken on failure of
+ *                 ciphering 
+ *
+ *
+ *  @param[in] procInfo : Information required to process PDU
+ *
+ * 
+ *  @return  Void
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjHndlCiphFail 
+(
+PjMsSPACCOutputMapInfo *spaccInfo
+)
+#else
+PUBLIC S16 pjHndlCiphFail(spaccInfo)
+PjMsSPACCOutputMapInfo *spaccInfo;
+#endif
+{
+   PjCb   *gCb = NULLP;
+   PjDlRbCb *pjRbCb = NULLP;
+   PjTxEnt  *txEnt = NULLP;
+
+   /* Extract gCb, rbCb and txEnt for further processing */
+   if((pjExtractTxEntRbCbUsingSpaccMappingInfo(spaccInfo, &gCb, &pjRbCb, &txEnt)) != ROK)
+   {
+      RETVALUE(RFAILED);
+   }
+   else
+   {
+       PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count);
+       if ( pjRbCb->dlCb.cfmReqd)
+       {
+          PJ_SND_CFM(gCb,pjRbCb, txEnt,
+                     PJU_CIPHER_FAILED);
+       }
+       else
+       {
+          pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count);   
+       }
+       gCb->pjGenSts.numCiphFails++;
+   }
+
+   RETVALUE(ROK);
+}
+#ifdef SPACC_THREADED
+PRIVATE U32 globPollCount = 50;
+
+/**
+ *
+ * @brief Handler for SPACC Reset 
+ *       
+ *
+ * @b Description: This is triggeres when the processing of batch at SPACC
+ *                 is delayed
+ *
+ *
+ * 
+ *  @return  Void
+ */
+
+
+#ifdef ANSI
+PRIVATE Void pjMsSpaccReset(Void)
+#else
+PRIVATE Void pjMsSpaccReset()
+#endif
+{
+   U32 ret=ROK;
+   U32 jobNum=1;
+   Buffer *opSdu=NULLP;
+   PjMsSPACCOutputMapInfo spaccInfo;
+
+   RLOG0(L_DEBUG,"Restarting SPACC");
+//   PjLibObdDlCloseReq();
+   pjMsSPAccRestart();
+   RLOG0(L_DEBUG,"SPACC Restarted");
+
+   for(;;)
+   {
+      ret = pjMsSpaccFetchDlPduInfo(&spaccInfo, &opSdu, jobNum, RFAILED);
+      if(ret == ROKDNA)
+      {
+         RLOG1(L_ERROR, "NUM DL jobs at failure:%ld",jobNum);
+         break;
+      }
+      pjHndlCiphFail(&spaccInfo);
+      jobNum++;
+   }
+
+   pjMsSetQFreeDl();
+
+   jobNum = 1;
+
+   for(;;)
+   {
+      ret = pjMsSpaccFetchUlPduInfo(&spaccInfo, &opSdu, jobNum, RFAILED);
+      if(ret == ROKDNA)
+      {
+         RLOG1(L_ERROR,"NUM UL jobs at failure:%ld",jobNum);
+         break;
+      }
+      pjHdlDecipherFailure(&spaccInfo);
+      jobNum++;
+   }
+
+   pjMsSetQFreeUl();
+
+   //RLOG0(L_DEBUG, "pjMsSetQFreeUl done");
+   //RLOG0(L_DEBUG, "Reopening SPACC DL");
+   //pjMsSpaccHdlDlfdOpenReq();
+  // RLOG0(L_DEBUG, "Reopened SPACC DL");
+
+   RETVOID;
+}
+#endif
+/**
+ *
+ * @brief Handler for NRT TTI Indication to PDCP for DL batch processing 
+ *       
+ *
+ * @b Description: Triggers batch processing to SPAcc. Fetches the ciphered PDUs
+ *                 from SPAcc and triggers sending the PDU's RLC.
+ *
+ *
+ * 
+ *  @return  Void
+ */
+
+
+#ifdef ANSI
+PUBLIC Void PjDlSpaccTrigger(Void)
+#else
+PUBLIC Void PjDlSpaccTrigger()
+#endif
+{
+
+   U32 ret=ROK;
+   U32 jobNum=1;
+   Buffer *opSdu=NULLP;
+   PjMsSPACCOutputMapInfo spaccInfo;
+
+#ifdef SPACC_NONBLOCKING
+   static U32 dlPollCount = 0;
+
+   S32 pollop;
+   pollop = pjMsSpaccPollDlQueue();
+   if(PJ_MS_POLL_NOT_REQUIRED == pollop)
+   {
+      ret = pjMsSpaccBatchAndCipherPackets();
+//      pjMsSpaccSetResetDlQueueFree(0);  /* Set to FALSE */
+   }
+   else
+   {
+      if(PJ_MS_POLL_COMPLETE == pollop)
+      {
+         dlPollCount = 0;
+         /* Process the o/p from SPAcc */
+         pjMsSpaccProcessDlBatchOutput();
+//         pjMsSpaccSetResetDlQueueFree(1);  /* Set to TRUE */
+
+         /* Send next set of data to SPAcc after processing */
+         ret = pjMsSpaccBatchAndCipherPackets();
+//         pjMsSpaccSetResetDlQueueFree(0);  /* Set to FALSE */
+      }
+      else
+      {
+#ifdef SPACC_THREADED
+         /*Workaround for the SPACC issue of "unexpected job"*/
+         dlPollCount++;
+         if(dlPollCount >= globPollCount)
+         {
+            U32 numUnexpJobs = 0;
+            dlPollCount = 0;
+            numUnexpJobs = pjMsCheckUnExpJobs();
+            if(numUnexpJobs != 0)
+            {
+               pjMsSpaccReset();
+            }
+         }
+#endif 
+         /* Do nothing as SPAcc is not done with processing */
+      }
+   }
+
+   /* This condition is executed when SPAcc returns failure for whatever
+   * reason.So once failure is returned, we fetch all the PDU's we had sent
+   * for ciphering and process them as failure */
+   if(ret != ROK)
+   {
+      RLOG0(L_ERROR,"Error leg in DL Spacc trigger hit ");
+      for(;;)
+      {
+         ret = pjMsSpaccFetchDlPduInfo(&spaccInfo, &opSdu, jobNum, ret);
+         if(ret == ROKDNA)
+         {
+            break;
+         }
+         pjHndlCiphFail(&spaccInfo);
+         jobNum++;
+      }
+   }
+
+#else
+
+   ret = pjMsSpaccBatchAndCipherPackets();
+
+   /* This condition is executed when SPAcc returns failure for whatever
+    * reason.So once failure is returned, we fetch all the PDU's we had sent
+    * for ciphering and process them as failure */
+   if(ret != ROK)
+   {
+      for(;;)
+      {
+         ret = pjMsSpaccFetchDlPduInfo(&spaccInfo, &opSdu, jobNum, ret);
+         if(ret == ROKDNA)
+         {
+            break;
+         }
+         pjHndlCiphFail(&spaccInfo);
+         RETVOID;
+      }
+   }
+
+   pjMsSpaccProcessDlBatchOutput();
+
+#endif
+
+   RETVOID;
+}
+
+/**
+ *
+ * @brief Handler for processing of Decipher Failure
+ *       
+ *
+ * @b Description: This function handles decipher failures by deleting the
+ * RxEnt,  send STA_IND to upper layer and updation of general statistics.
+ *
+ *
+ *  @param[in] spaccOpInfo : Information required to process PDU
+ *
+ * 
+ *  @return  Void
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjHdlDecipherFailure 
+(
+PjMsSPACCOutputMapInfo *spaccOpInfo
+)
+#else
+PUBLIC S16 pjHdlDecipherFailure()
+PjMsSPACCOutputMapInfo *spaccOpInfo;
+#endif
+{
+   PjCb   *gCb;
+   PjUlUeCb   *ueCb = NULLP;
+   PjUlRbCb *pjRbCb = NULLP;
+   PjRxEnt  *rxEnt = NULLP; 
+
+   gCb = PJ_GET_PJCB(spaccOpInfo->pdcpInstance);
+
+   pjDbmFetchUlUeCb(gCb, 
+                    spaccOpInfo->pdcpId.ueId,
+                    spaccOpInfo->pdcpId.cellId, 
+                    &ueCb);
+
+   if(ueCb  == NULLP)
+   {
+      RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"UECB not found !!!! ");
+      RETVALUE(RFAILED);
+   }
+
+   /*     RLOG_ARG4(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,
+    *     "At PDCP: : RBTYPE:%d, CELLID:%d, RBID:%d, 
+         COUNT:%d", spaccOpInfo->pdcpId.rbType, spaccOpInfo->pdcpId.cellId,  
+         spaccOpInfo->pdcpId.rbId, spaccOpInfo->count);*/
+   /*   RLOG_ARG2(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,
+          "SNLEN:%d, numjobs %d "spaccOpInfo->pdcpId.ueId,  \
+          spaccOpInfo->snLen,  numJobs); */
+
+   pjDbmFetchPjUlRbCb(ueCb, spaccOpInfo->pdcpId.rbId, spaccOpInfo->pdcpId.rbType, &pjRbCb);
+   if(pjRbCb  == NULLP)
+   {
+      RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"RBCB not found !!!!");
+      RETVALUE(RFAILED);
+   }
+
+   rxEnt = (PjRxEnt *)pjDbmGetRxEnt(gCb, 
+                                    &(pjRbCb->ulCb.recBuf),
+                                    spaccOpInfo->count);
+
+   if(rxEnt == NULLP)
+   {
+      RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"!!!!rxEnt is NULL!!!!");
+      RETVALUE(RFAILED);
+   }
+
+   PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt);
+   pjDbmDelRxEnt(gCb, &(pjRbCb->ulCb.recBuf), rxEnt->count);
+   PJ_STS_INC_GEN_CNT(gCb,numDeciphFails);
+
+   RETVALUE(ROK);
+}
+
+/**
+ *
+ * @brief Handler for processing deciphered PDU 
+ *       
+ *
+ * @b Description: This function processes and sends the ciphered PDU to RLC
+ *
+ *
+ *  @param[in] spaccOpInfo : Information required to process PDU
+ *  @param[in] opSdu    : Deciphered buffer
+ *
+ * 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjProcDeCipherPdu 
+(
+PjMsSPACCOutputMapInfo *spaccOpInfo,
+Buffer *opSdu
+)
+#else
+PUBLIC S16 pjProcDeCipherPdu()
+PjMsSPACCOutputMapInfo *spaccOpInfo;
+Buffer *opSdu;
+#endif
+{
+   U32 ret;
+   PjCb   *gCb;
+   PjUlUeCb   *ueCb = NULLP;
+   PjUlRbCb *pjRbCb = NULLP;
+   PjRxEnt  *rxEnt = NULLP; 
+
+   gCb = PJ_GET_PJCB(spaccOpInfo->pdcpInstance);
+
+   pjDbmFetchUlUeCb(gCb, 
+                    spaccOpInfo->pdcpId.ueId,
+                    spaccOpInfo->pdcpId.cellId, 
+                    &ueCb);
+   
+   if(ueCb  == NULLP)
+   {
+      RLOG_ARG0(L_WARNING,DBG_UEID,spaccOpInfo->pdcpId.ueId,"UECB not found !!!! ");
+      RETVALUE(RFAILED);
+   }
+
+/*     RLOG_ARG4(L_ERROR, DBG_UEID,spaccOpInfo->pdcpId.ueId,
+       "UDAY: At PDCP: : RBTYPE:%d, CELLID:%d, RBID:%d,  COUNT:%d", 
+       spaccOpInfo->pdcpId.rbType, spaccOpInfo->pdcpId.cellId, 
+       spaccOpInfo->pdcpId.rbId, spaccOpInfo->count,);*/
+/*     RLOG_ARG2(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,
+       " SNLEN:%d, numjobs %d ",spaccOpInfo->snLen,  numJobs); */
+
+   pjDbmFetchPjUlRbCb(ueCb, spaccOpInfo->pdcpId.rbId, spaccOpInfo->pdcpId.rbType, &pjRbCb);
+   if(pjRbCb  == NULLP)
+   {
+      RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"RBCB not found !!!! ");
+      RETVALUE(RFAILED);
+   }
+
+   rxEnt = (PjRxEnt *)pjDbmGetRxEnt(gCb, &(pjRbCb->ulCb.recBuf),
+         spaccOpInfo->count);
+
+/* To be used for debugging. Will be removed once verified */
+
+   if(rxEnt == NULLP)
+   {
+      RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"!!!!rxEnt is NULL!!!!");
+      RETVALUE(RFAILED);
+   }  
+
+   /*Free the source buffer here*/
+   if(rxEnt->mBuf)
+   {
+      PJ_FREE_BUF(rxEnt->mBuf);
+   }
+   rxEnt->mBuf = opSdu;
+
+
+   if(pjRbCb->rbType == PJ_DRB)
+   {
+      rxEnt->state   =  PJ_RDY_TO_DCOMP;
+      ret = pjUlmHdlDeCmp(gCb, pjRbCb, rxEnt);
+   }
+   else
+   {
+      rxEnt->state   =  PJ_RDY_TO_INTVER;
+      ret = pjUlmHdlIntVer(gCb, pjRbCb, rxEnt);
+   }   
+
+   if(rxEnt->dupEntry == TRUE)
+   {
+      RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId," 3. Deleting RxEnt");
+      /* duplicate entry */
+      PJ_FREE_BUF(rxEnt->mBuf);
+      PJ_FREE(gCb,rxEnt, sizeof(PjRxEnt));
+   }
+   else if(rxEnt->discFlag == TRUE)
+   {
+      RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"4. Deleting RxEnt");
+      /* duplicate entry */
+      pjDbmDelRxEnt(gCb, &pjRbCb->ulCb.recBuf, rxEnt->count);
+   }   
+   RETVALUE(ROK);
+
+}
+
+/**
+ *
+ * @brief Handler for NRT TTI Indication to PDCP for UL batch processing 
+ *       
+ *
+ * @b Description: Triggers batch processing of packets lined up for 
+ *                 deciphering. Fetches the ciphered PDUs
+ *                 and triggers further processing at PDCP. 
+ *
+ *
+ * 
+ *  @return  Void
+ */
+
+
+#ifdef ANSI
+PUBLIC Void PjUlSpaccTrigger(Void)
+#else
+PUBLIC Void PjUlSpaccTrigger(Void)
+#endif
+{
+
+   U32 ret=ROK;
+   U32 jobNum=1;
+   Buffer *opSdu=NULLP;
+   PjMsSPACCOutputMapInfo spaccInfo;
+
+#ifdef SPACC_NONBLOCKING
+   static U32 ulPollCount = 0;
+
+   S32 pollop;
+   pollop = pjMsSpaccPollUlQueue();
+   if(PJ_MS_POLL_NOT_REQUIRED == pollop)
+   {
+      ret = pjMsSpaccBatchAndDeCipherPackets();
+   }
+   else
+   {
+      if(PJ_MS_POLL_COMPLETE == pollop)
+      {
+         ulPollCount = 0;
+         /* Process the o/p from SPAcc */
+         pjMsSpaccProcessUlBatchOutput();
+         pjMsSpaccSetResetUlQueueFree(1);  /* Set to TRUE */
+
+         /* Send next set of data to SPAcc after processing */
+         ret = pjMsSpaccBatchAndDeCipherPackets();
+      }
+      else
+      {
+#ifdef SPACC_THREADED
+         /*SPACC Workaround when SPACC is not able to complete BATCH*/
+         ulPollCount++;
+         if(ulPollCount >= globPollCount)
+         {
+            U32 numUnexpJobs = 0;
+            ulPollCount = 0;
+            numUnexpJobs = pjMsCheckUnExpJobs();
+            if(numUnexpJobs != 0)
+            {
+               pjMsSpaccReset();
+            }
+         }
+#endif 
+      }
+   }
+
+   /* This condition is executed when SPAcc returns failure for whatever
+    * reason.So once failure is returned, we fetch all the PDU's we had sent
+    * for Deciphering and process them as failure */
+   if(ret != ROK)
+   {
+      RLOG0(L_ERROR, "Error leg in uL Spacc trigger hit ");
+      for(;;)
+      {
+         ret = pjMsSpaccFetchUlPduInfo(&spaccInfo, &opSdu, jobNum, ret);
+         if(ret == ROKDNA)
+         {
+            break;
+         }
+         pjHdlDecipherFailure(&spaccInfo);
+         jobNum++;
+      }
+   }
+
+#else
+
+   ret = pjMsSpaccBatchAndDeCipherPackets();
+
+   /* This condition is executed when SPAcc returns failure for whatever
+    * reason.So once failure is returned, we fetch all the PDU's we had sent
+    * for Deciphering and process them as failure */
+   if(ret != ROK)
+   {
+      for(;;)
+      {
+         ret = pjMsSpaccFetchUlPduInfo(&spaccInfo, &opSdu, jobNum, ret);
+         if(ret == ROKDNA)
+         {
+            break;
+         }
+         pjHdlDecipherFailure(&spaccInfo);
+      }
+
+      RETVOID;
+   }
+
+   pjMsSpaccProcessUlBatchOutput();
+
+
+#endif
+
+   RETVOID;
+}
+
+
+
+/**
+*@brief
+* This function calls the function which interfaces with SPAcc
+* for opening of the fd. Also, it initializes the SPAcc DL Queues.
+*
+*@inparam[in] gCb  PDCP Instance Control Block
+*@return S16
+*/
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdDlInitReq
+(
+PjCb    *gCb
+)
+#else
+PUBLIC S16 PjLibObdDlInitReq(gCb)
+PjCb    *gCb;
+#endif
+{
+   TRC3(PjLibObdDlInitReq)
+
+#ifdef INTEL_NATIVE_SPACC
+   S32 ret = RFAILED;
+   ret = pjMsSpaccRegIccDlHndl();
+   if(ret != ROK)
+   {
+      printf("Registration of ICC DL handle has failed\n");
+      RETVALUE(ret);
+   }
+   printf("Registration of ICC DL handle has succeeded\n");
+   ret = pjMsSpaccThreadActivation(appContext.hUAII_Dl);
+   if(ret != 0)
+   {
+      printf("Spacc thread activation has failed\n");
+      RETVALUE(ret);
+   }
+   printf("Spacc thread activation is done again\n");
+   /* Init Mem region and Pool */
+   pjMsSPAccInitDlMemRegionPool(gCb->init.region, gCb->init.pool);
+#ifdef INTEL_SPACC_IV_OPTIMIZATION
+   pjMsNSpaccDlInitForSpaccIV(gCb);
+#endif
+#else
+   /*Call to open file descriptors for interfacing with SPACC*/
+   if(pjMsSpaccHdlDlfdOpenReq() != ROK)
+   {
+      RETVALUE(RFAILED);
+   }
+
+   /*Call to initialise the DL/UL SPAcc queues*/
+   pjMsSPAccInitDlQue();
+
+   /* Init Mem region and Pool */
+   pjMsSPAccInitDlMemRegionPool(gCb->init.region, gCb->init.pool);
+#endif
+   RETVALUE(ROK);
+}
+
+/**
+*@brief
+* This function calls the function which interfaces with SPAcc
+* for opening of the fd. Also, it initializes the SPAcc UL Queues.
+*
+*@inparam[in] gCb  PDCP Instance Control Block
+*@return S16
+*
+*/
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdUlInitReq
+(
+PjCb    *gCb
+)
+#else
+PUBLIC S16 PjLibObdUlInitReq(gCb)
+PjCb    *gCb;
+#endif
+{
+   TRC3(PjLibObdUlInitReq)
+
+#ifdef INTEL_NATIVE_SPACC
+   S32 ret = RFAILED;
+   ret = pjMsSpaccRegIccUlHndl();
+   if(ret != ROK)
+   {
+      printf("Registration of ICC UL handle has failed\n");
+      RETVALUE(ret);
+   }
+   printf("Registration of ICC UL handle has succeeded\n");
+   ret = pjMsSpaccThreadActivation(appContext.hUAII_Ul);
+   if(ret != 0)
+   {
+      printf("Spacc thread activation has failed\n");
+      RETVALUE(ret);
+   }
+   printf("Spacc thread activation is done\n");
+   /* Init Mem region and Pool */
+   pjMsSPAccInitUlMemRegionPool(gCb->init.region, gCb->init.pool);
+#ifdef INTEL_SPACC_IV_OPTIMIZATION
+   pjMsNSpaccUlInitForSpaccIV(gCb);
+#endif
+#else
+   /*Call to open file descriptors for interfacing with SPACC*/
+   if(pjMsSpaccHdlUlfdOpenReq() != ROK)
+   {
+      RETVALUE(RFAILED);
+   }
+
+   /*Call to initialise the UL SPAcc queues*/
+   pjMsSPAccInitUlQue();
+
+   /* Init Mem region and Pool */
+   pjMsSPAccInitUlMemRegionPool(gCb->init.region, gCb->init.pool);
+#endif
+   RETVALUE(ROK);
+}
+
+
+/**
+ *
+ * @brief Handler for invoking key derivation function for KeNB*. This is used
+ * for Handover cases.
+ *       
+ *
+ * @Description: When the eNB decides to perform an intra-eNB handover it
+ * shall derive KeNB* using target PCI, its frequency EARFCN-DL, and 
+ * either NH or the current KeNB.
+ *
+ * @input: gCb  - Control Block
+ *         kenbInf - Input structure for KeNB* derivation.
+ *         kdfCfm  - Output filled into this structure after derivation.
+ *
+ *  @return  S16
+ */
+#ifdef ANSI
+PUBLIC S16 pjLibObdPrcKenbStarCfg
+(
+PjCb                   *gCb,
+CpjKenbStarInfo*       kenbInf,
+CpjKenbStarCfmInfo     *kdfCfm
+)
+#else
+PUBLIC S16 pjLibObdPrcKenbStarCfg(gCb, kenbInf, kdfCfm)
+PjCb                   *gCb;
+CpjKenbStarInfo*       kenbInf;
+CpjKenbStarCfmInfo     *kdfCfm;
+#endif
+{
+   PjMsSecInfo  *pSecInfo;
+   U32 ret=ROK;
+
+   TRC2(pjLibObdPrcKenbStarCfg)
+
+   PJ_ALLOC(gCb, pSecInfo , sizeof(PjMsSecInfo));
+   if(pSecInfo == NULLP)
+   {
+      RLOG1(L_ERROR, "YsMsUlmPrcKenbStarCfg failed line %d ", __LINE__);
+      RETVALUE(RFAILED);
+   }
+
+
+   cmMemcpy(pSecInfo->hash_key, kenbInf->secKey, CPJ_SEC_KEY_LEN);
+
+   /* Building the String S = FC || P0 || L0 || P1 || L1 */
+
+   /*Values are initialized as per section A7 33.401*/
+   pSecInfo->strS[0] = 0x13; 
+   pSecInfo->strS[3] = 0x00;
+   pSecInfo->strS[4] = 0x02;
+   pSecInfo->strS[7] = 0x00;
+   pSecInfo->strS[8] = 0x02;
+
+
+   RLOG2(L_DEBUG,"Value of Cellid, dl Freq is %d %d ", 
+         kenbInf->physCellId, kenbInf->dlCarrFreq);
+   /*******************************************
+    *************kENB* from kENB*************
+    *******************************************/
+
+   /*PCI*/
+   pSecInfo->strS[1] = kenbInf->physCellId >> 8;
+   pSecInfo->strS[2] = (U8)kenbInf->physCellId;
+
+   /*DL frequency*/
+   pSecInfo->strS[5] = kenbInf->dlCarrFreq >> 8;
+   pSecInfo->strS[6] = (U8)kenbInf->dlCarrFreq;
+
+   pSecInfo->strSlen = 9;
+
+   if((pjSendToKeyDeriveFunc(pSecInfo, kdfCfm->secKey)) != ROK)
+   {
+      RLOG0(L_ERROR, "In pjLibObdPrcKenbStarCfg: pjMsKDF failed");
+      ret = RFAILED;
+   }/*End of if(ret!=ROK)*/
+
+   PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo));
+
+   RETVALUE(ret);
+}/*End of function*/
+
+/**
+ *
+ * @brief Handler for invoking key derivation function for KeNB. KeNB is Key
+ * derivation funtion. This is normal Ciphering/Integrity Key derivation at
+ * eNB.
+ *       
+ *
+ * @Description: For Security to be enabled, Integrity and Ciphering keys need
+ * to be derived. These are applied on SRB/DRB data and the Ciphered/Integrity
+ * protected PDU are sent to UE.
+ *
+ * @input: gCb  - Control Block
+ *         kenbInf - Input structure for KeNB* derivation.
+ *         kdfCfm  - Output filled into this structure after derivation.
+ *
+ *  @return  S16
+ */
+#ifdef ANSI
+PUBLIC S16 pjLibObdPrcKenbCfg
+(
+PjCb                   *gCb,
+CpjAsKeyInfo*       kenbInf,
+CpjAskeyCfmInfo     *kdfCfm
+)
+#else
+PUBLIC S16 pjLibObdPrcKenbCfg(kenbInf)
+PjCb                   *gCb;
+CpjAsKeyInfo*       kenbInf;
+CpjAskeyCfmInfo     *kdfCfm;
+#endif
+{
+
+   S16       ret;
+   PjMsSecInfo  *pSecInfo;
+
+
+   TRC2(pjLibObdPrcKenbCfg)
+   ret = ROK;
+
+   PJ_ALLOC(gCb, pSecInfo, sizeof(PjMsSecInfo));
+   if(pSecInfo == NULLP)
+   {
+      RLOG1(L_ERROR, "YsMsUlmPrcKenbCfg failed line %d ", __LINE__);
+      RETVALUE(RFAILED);
+   }
+
+
+   cmMemcpy(pSecInfo->hash_key, kenbInf->secKey, CPJ_SEC_KEY_LEN);
+
+   /* Building the String S = FC || P0 || L0 || P1 || L1 */
+
+   /*Values are initialized as per section A7 33.401*/
+   pSecInfo->strS[0] = 0x15;  
+   pSecInfo->strS[2] = 0x00; 
+   pSecInfo->strS[3] = 0x01;
+   pSecInfo->strS[5] = 0x00; 
+   pSecInfo->strS[6] = 0x01;
+
+   pSecInfo->strSlen = 7;
+
+   /*******************************************
+    *************CP Ciphering key*************
+    *******************************************/
+   pSecInfo->strS[1] = 0x3;
+   pSecInfo->strS[4] = kenbInf->ciphAlgoType;
+
+   ret = pjSendToKeyDeriveFunc(pSecInfo, kdfCfm->cpCiphKey);
+   if(ret!=ROK)
+   {
+      RLOG0(L_ERROR, "Control Plane Cipher Key derivation failed");
+      PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo));
+      RETVALUE(RFAILED);
+   }/*End of if(ret!=ROK)*/
+
+
+   /*******************************************
+    *************UP Ciphering key*************
+    *******************************************/
+   pSecInfo->strS[1] = 0x5;
+   pSecInfo->strS[4] = kenbInf->ciphAlgoType;
+
+   ret = pjSendToKeyDeriveFunc(pSecInfo, kdfCfm->upCiphKey);
+   if(ret!=ROK)
+   {
+      RLOG0(L_ERROR, "User Plane Cipher Key derivation failed");
+      PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo));
+      RETVALUE(RFAILED);
+   }/*End of if(ret!=ROK)*/
+
+   RLOG0(L_DEBUG, "Ciphering Key (UP) Derived");
+
+   /*******************************************
+    ************RRC Integrity key*************
+    *******************************************/
+   pSecInfo->strS[1] = 0x4;
+   pSecInfo->strS[4] = kenbInf->intgAlgoType;
+
+   ret = pjSendToKeyDeriveFunc(pSecInfo, kdfCfm->intKey);
+   if(ret!=ROK)
+   {
+      RLOG0(L_ERROR, "Integrity Key derivation failed");
+      PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo));
+      RETVALUE(RFAILED);
+   }/*End of if(ret!=ROK)*/
+
+   RLOG0(L_DEBUG, "Integrity Key Derived");
+
+   PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo));
+
+
+   RETVALUE(ROK);
+}/*End of function*/
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Provides input params like Keys, RbId, direction which would be used
+ *        as input for creation of SPAcc i/p structure..
+ *
+ * @b Description:
+ *
+ *        This function sends Intergrity protection request with elevant input parameters.
+ *
+ *  @param[in]   pjRbCb       PDCP RbCb 
+ *  @param[in]   intCxtId       Input parameters for integrity 
+ *  @param[in]   mBuf         SDU to be compressed 
+ *  @param[out]  libTrans      Input to integrity algo (RbId, Count, Direction) 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdIntProtReq
+(
+PjLibTrans  *libTrans,
+Buffer      **mBuf
+)
+#else
+PUBLIC S16 PjLibObdIntProtReq(libTrans, mBuf)
+PjLibTrans  *libTrans;
+Buffer      **mBuf;
+#endif
+{
+
+   U32 ret = ROK;
+   U32 dummyMacI =0 ;
+   TRC3(PjLibObdIntProtReq)
+
+   if(libTrans->intAlgoType == PJ_SPACC_EIA1)
+   {
+      ret = pjMsSpaccIntegProtPkt(libTrans, mBuf);
+   }
+   else if (libTrans->intAlgoType == PJ_SPACC_EIA2)
+   {
+      ret = pjMsSpaccAesIntegProtPkt(libTrans, mBuf);
+   }
+   else if (libTrans->intAlgoType == PJ_SPACC_EIA3)
+   {
+      ret = pjMsSpaccIntegProtPkt(libTrans, mBuf);
+   }
+   else
+   {
+      /* NULL Algorithm */
+      PJ_PACK_MACI(*mBuf, dummyMacI);
+   }
+
+   RETVALUE(ret);
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for redirecing Integration request to SPAcc module.
+ *
+ * @b Description:
+ *
+ *        This function sends Intergrity verification request along with relevant input parameters.
+ *
+ *  @param[in]   PjCb        PDCP Cb 
+ *  @param[in]   PTR        Handle for Integrity verification (handle opened during spacc_dev_open)  
+ *  @param[in]   PjLibTrans        Input parameters for integrity 
+ *  @param[in]   mBuf          SDU to be compressed 
+ *  @param[out]  macI        MAC-I 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLibObdIntVerReq
+(
+PjLibTrans  *libTrans,
+Buffer      *mBuf,
+U32         macI
+)
+#else
+PUBLIC S16 PjLibObdIntVerReq(libTrans, mBuf, macI)
+PjLibTrans  *libTrans;
+Buffer      *mBuf;
+U32         macI;
+#endif
+{
+   U32 ret = ROK;
+   TRC3(PjLibObdIntVerReq)
+
+   if(libTrans->intAlgoType != 0)
+   {
+      ret = pjMsSpaccIntegVerifyPkt(libTrans, &mBuf, macI);
+   }
+   else
+   {
+     RLOG_ARG0(L_ERROR,DBG_UEID,libTrans->ueId,"Integrity protection Algo type is == 0 ");
+   }
+
+   RETVALUE(ret);
+}
+
+
+/**
+*@brief
+* This function calls the function which interfaces with SPAcc
+* for closing the DL fd. 
+*
+*@return S16
+*        -ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 PjLibObdDlCloseReq(Void)
+#else
+PUBLIC S16 PjLibObdDlCloseReq(Void)
+#endif
+{
+
+   TRC3(PjLibObdDlCloseReq)
+   pjSpaccDeInitCiphQ();
+   pjMsSPAccDlfdCloseReq();
+   RETVALUE(ROK);
+
+}
+
+/**
+*@brief
+* This function calls the function which interfaces with SPAcc
+* for closing the UL fd. 
+*
+*@return S16
+*        -ROK
+*
+*/
+#ifdef ANSI
+PUBLIC S16 PjLibObdUlCloseReq(Void)
+#else
+PUBLIC S16 PjLibObdUlCloseReq(Void)
+#endif
+{
+
+   TRC3(PjLibObdUlCloseReq)
+   pjSpaccDeInitDeCipherQ();
+   pjMsSPAccUlfdCloseReq();
+   RETVALUE(ROK);
+
+}
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for redirecing ciphering request to SPAcc Module.
+ *
+ * @b Description:
+ *
+ *        This function sends ciphering protection request along with relevant input parameters.
+ *
+ *  @param[in]   PjCb           PDCP Cb 
+ *  @param[in]   PjLibTrans      libTrans( Input parameters for deciphering )
+ *  @param[in]   mBuf             Data to be deciphered 
+ *  @param[in]   opSdu            Deciphered SDU 
+ *  @param[in]   cxtId          Handle for ciphering either for User/Control plane.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdCipherReq
+(
+PjLibTrans  *libTrans,
+Buffer      *mBuf,
+Buffer      **opSdu
+)
+#else
+PUBLIC S16 PjLibObdCipherReq(libTrans, mBuf, opSdu)
+PjLibTrans  *libTrans;
+Buffer      *mBuf;
+Buffer      **opSdu;
+#endif
+{
+   U32 ret = ROK;
+
+   TRC3(PjLibObdCipherReq)
+
+   ret = pjSendToCipher(libTrans, mBuf);
+
+   RETVALUE(ret);
+}
+
+
+#ifdef FLAT_BUFFER_OPT
+/**
+ *
+ * @brief 
+ *
+ *        Handler for redirecing ciphering request to SPAcc Module.
+ *
+ * @b Description:
+ *
+ *        This function sends ciphering protection request along with relevant input parameters.
+ *
+ *  @param[in]   PjCb           PDCP Cb 
+ *  @param[in]   PjLibTrans     libTrans( Input parameters for deciphering )
+ *  @param[in]   mBuf           Flat Buffer to be deciphered 
+ *  @param[in]   opSdu          Deciphered SDU 
+ *  @param[in]   cxtId          Handle for ciphering either for User/Control plane.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdCipherReqFB
+(
+PjLibTrans  *libTrans,
+FlatBuffer  *mBuf,
+Buffer      **opSdu
+)
+#else
+PUBLIC S16 PjLibObdCipherReqFB(libTrans, mBuf, opSdu)
+PjLibTrans  *libTrans;
+FlatBuffer  *mBuf;
+Buffer      **opSdu;
+#endif
+{
+
+   U32 ret = ROK;
+
+   TRC3(PjLibObdCipherReqFB)
+
+   ret = pjSendToCipherFB(libTrans, mBuf);
+
+   RETVALUE(ret);
+}
+#endif
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for redirecing deciphering request to SPAcc module.
+ *
+ * @b Description:
+ *
+ *        This function sends deciphering request along with relevant input parameters.
+ *
+ *  @param[in]   PjCb           PDCP Cb 
+ *  @param[in]   PTR            Handle for Deciphering (stored during spacc_dev_open) 
+ *  @param[in]   PjLibTrans           Input parameters for deciphering 
+ *  @param[in]   mBuf             Data to be deciphered 
+ *  @param[in]   opSdu            Deciphered SDU 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLibObdDecipherReq
+(
+PjLibTrans  *libTrans,
+Buffer      *mBuf,
+Buffer      **opSdu
+)
+#else
+PUBLIC S16 PjLibObdDecipherReq(libTrans, mBuf, opSdu)
+PjLibTrans  *libTrans;
+Buffer      *mBuf;
+Buffer      **opSdu;
+#endif
+{
+   U32 ret = ROK;
+
+   TRC3(PjLibObdDecipherReq)
+
+   ret = pjSendToDeCipher(libTrans, mBuf);
+
+   RETVALUE(ret);
+
+}
+#else
+
+#ifdef ANSI
+PUBLIC S16 pjLibObdPrcKenbCfg
+(
+PjCb                   *gCb,
+CpjAsKeyInfo*       kenbInf,
+CpjAskeyCfmInfo     *kdfCfm
+)
+#else
+PUBLIC S16 pjLibObdPrcKenbCfg(gCb, kenbInf, kdfCfm)
+PjCb                   *gCb;
+CpjAsKeyInfo*       kenbInf;
+CpjAskeyCfmInfo     *kdfCfm;
+#endif
+{
+   TRC2(pjLibObdPrcKenbCfg);
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 pjLibObdPrcKenbStarCfg
+(
+PjCb                   *gCb,
+CpjKenbStarInfo*       kenbInf,
+CpjKenbStarCfmInfo     *kdfCfm
+)
+#else
+PUBLIC S16 pjLibObdPrcKenbStarCfg(gCb, kenbInf, kdfCfm)
+PjCb                   *gCb;
+CpjKenbStarInfo*       kenbInf;
+CpjKenbStarCfmInfo     *kdfCfm;
+#endif
+{
+
+   TRC2(pjLibObdPrcKenbStarCfg);
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 pjLibDecipherReq
+(
+PTR         intCxtId,           /* Context Id for compression */
+PjSecInp    secInp,             /* Input for Deciphering */
+Buffer      *mBuf,              /* SDU to be deciphered */
+Buffer      **opSdu             /* deciphered SDU */
+)
+#else
+PUBLIC S16 pjLibDecipherReq(intCxtId, secInp, mBuf, opSdu)
+PTR         intCxtId;           /* Context Id for Deciphering */
+PjSecInp    secInp;             /* Input for Deciphering */
+Buffer      *mBuf;              /* SDU to be Deciphering */
+Buffer      **opSdu;            /* Deciphering SDU */
+#endif
+{
+   TRC3(pjLibDecipherReq)
+#ifdef LTE_PAL_ENB
+   *opSdu = mBuf;
+#endif
+   RETVALUE(ROK);
+
+} /* end of pjLibDecipherReq */
+
+
+#ifdef ANSI
+PUBLIC S16 pjLibIntVerReq 
+(
+PTR        intCxtId,                /* Context Id for compression */
+PjSecInp   secInp,                  /* Input for Integrity protection */                  
+Buffer     *mBuf,                   /* SDU to be compressed */
+U32        macI,                    /* Message authentication code for the SDU */
+Status     *status                  /* Status of the Integrity verification */
+)
+#else
+PUBLIC S16 pjLibIntVerReq(intCxtId, secInp, mBuf, macI, status)
+PTR        intCxtId;                /* Context Id for compression */
+PjSecInp   secInp;                  /* Input for Integrity protection */
+Buffer     *mBuf;                   /* SDU to be compressed */
+U32        macI;                    /* Message authentication code for the SDU */
+Status     *status;                 /* Status of the Integrity verification */
+#endif
+{
+   TRC3(pjLibIntVerReq)
+   RETVALUE(ROK);
+
+} /* end of pjLibIntVerReq */
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdIntProtReq
+(
+PjLibTrans  *libTrans,
+Buffer      **mBuf
+)
+#else
+PUBLIC S16 PjLibObdIntProtReq(libTrans, mBuf)
+PjLibTrans  *libTrans;
+Buffer      **mBuf;
+#endif
+{
+#ifdef LTE_PAL_ENB
+   Buffer *mBuf1;
+#endif
+   TRC3(PjLibObdIntProtReq);
+#ifdef LTE_PAL_ENB
+   SAddMsgRef(*mBuf, 0,0, &mBuf1);
+
+   *mBuf = mBuf1;
+#endif
+   RETVALUE(ROK);
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdCipherReq
+(
+PjLibTrans  *libTrans,
+Buffer      *mBuf,
+Buffer      **opSdu
+)
+#else
+PUBLIC S16 PjLibObdCipherReq(libTrans, mBuf, opSdu)
+PjLibTrans  *libTrans;
+Buffer      *mBuf;
+Buffer      **opSdu;
+#endif
+{
+
+   TRC3(PjLibObdCipherReq);
+#ifdef LTE_PAL_ENB
+   SAddMsgRef(mBuf, 0,0, opSdu);
+
+#endif
+   RETVALUE(ROK);
+
+}
+#endif
+
+#ifdef TENB_T2K3K_SPECIFIC_CHANGES
+#define PJ_MAX_SDUS_TO_WAIT_FOR_ACK  1200 
+PRIVATE U32 gMemoryAlarm;
+/* 384MB => 768M total 
+cat /sys/devices/virtual/icc/iccserv/mm
+============
+Partition_7f1c7890 - type: LOCAL PART
+Split logic is currently disabled
+Part start address_9a200000, end address_ca1fffff
+Size ...................... 786432 KiB
+nBlocks ................... 304085
+Number of pools ........... 4
+GAP (between sectors) ..... 128 Bytes
+Pools info:
+Pool_0: BlkSize_(useful_384, total_512), BlkCnt_104856, FreeBlkCnt_97177
+Pool_1: BlkSize_(useful_1920, total_2048), BlkCnt_157285, FreeBlkCnt_130668
+Pool_2: BlkSize_(useful_3968, total_4096), BlkCnt_20970, FreeBlkCnt_11245
+Pool_3: BlkSize_(useful_16256, total_16384), BlkCnt_20970, FreeBlkCnt_12122
+============*/
+#endif
+
+PUBLIC U32 dbgSpaccThreshHoldDropCnt = 0;
+PUBLIC U32 dbgPdcpQSizeThreshHoldDropCnt = 0;
+PUBLIC U32 dbgPdcpMemCount = 0;
+PUBLIC U32 pdcpDropMemTh = 0;
+PUBLIC U32 dbgICCMemThreshHoldDropCnt = 0;
+PUBLIC U32 dbgSSIMemThreshHoldDropCnt = 0;
+PUBLIC U32 dbgICCMemAlarm;
+PUBLIC U32 dbgPdcpQMsSpaccQFull = 0;
+PUBLIC U32 dbgPdcpRbOverload = 0;
+/* kw003.201 This function is for admission control at packet level */
+#ifdef ANSI
+PUBLIC S16 pjLibPktAdmCtrl
+(
+PjDlRbCb        *pjRbCb,
+Buffer        *pkt
+) 
+#else
+PUBLIC S16 pjLibPktAdmCtrl(pjRbCb, pkt)
+PjDlRbCb        *pjRbCb;
+Buffer        *pkt;
+#endif 
+{
+   TRC3(pjLibPktAdmCtrl)
+   /* Patch kw004.201 */
+#ifdef SS_CAVIUM
+      if(pjRbCb->dlCb.txBuf.numEntries > 450)
+      {
+         RETVALUE(RFAILED);
+      }
+#endif
+#ifdef LTE_PAL_ENB
+      if(pjRbCb->dlCb.txBuf.numEntries > 1200)
+      {
+         RETVALUE(RFAILED);
+      }
+#endif
+#ifdef TENB_T2K3K_SPECIFIC_CHANGES
+   if(pjRbCb->dlCb.txBuf.numEntries > PJ_MAX_SDUS_TO_WAIT_FOR_ACK)
+   {
+      dbgPdcpQSizeThreshHoldDropCnt++;
+      /*This is for AM bearers only.  FC for UDP on AM will also
+        be taken care here. */
+#ifdef TENB_STATS
+      if (pjRbCb->ueCb->tenbStats)
+      {
+         pjRbCb->ueCb->tenbStats->stats.nonPersistent.pdcp.dlPdcpAckWaitDropCnt++;
+      }
+#endif
+      RETVALUE(RFAILED);
+   }
+
+   /* Check the SPAcc queue too as we need to start dropping the PDUs in case
+    * if SPAcc queue is waiting more number of PDUs
+    */
+   if(FALSE == (pjMsCheckSpaccQueue(FALSE)))
+   {
+      dbgSpaccThreshHoldDropCnt++;
+      dbgPdcpQMsSpaccQFull++;
+      RETVALUE(RFAILED);
+   }
+   /* Memory threshold is reached then drop the packet  */
+   if(isMemThreshReached(pjCb[1]->init.region) != ROK)
+   {
+      {
+         extern U32 pdcpdrop;
+         pdcpdrop++;
+         //MSPD_LOG("at PDCPdrop %d new %d\n",pdcpdrop);
+      }
+      RETVALUE(RFAILED);
+   }
+
+      dbgICCMemAlarm=gMemoryAlarm;
+#endif
+   if (pjRbCb->dropOnlyOne)
+   {
+#ifdef TENB_STATS
+      /*FC for AM bearers*/
+      if (pjRbCb->ueCb->tenbStats)
+      {
+         pjRbCb->ueCb->tenbStats->stats.nonPersistent.pdcp.dlPdcpDropCnt++;
+      }
+
+#endif
+
+      dbgPdcpMemCount++;
+      pjRbCb->dropOnlyOne = 0;
+      RETVALUE(RFAILED);
+   }
+   if ((pjRbCb->pktAdmitCnt) && (pjRbCb->pktCnt > pjRbCb->pktAdmitCnt))
+   {
+     /* FC for UM bearers */
+#ifdef TENB_STATS
+      /*FC for AM bearers*/
+      if (pjRbCb->ueCb->tenbStats)
+      {
+         pjRbCb->ueCb->tenbStats->stats.nonPersistent.pdcp.dlPdcpDropCnt++;
+      }
+#endif
+      RETVALUE(RFAILED);
+   }
+   /* Pkt admitted. Counting it in.*/
+   pjRbCb->pktCnt++;
+   RETVALUE(ROK);
+
+} /* end of pjLibPktAdmCtrl */
+
+#ifdef TENB_AS_SECURITY
+/**
+ * @brief This function is used to Process the o/p from SPAcc.
+ *
+ * @details This function is used to Process ciphered PDU's from SPAcc. We
+ * check if SPAcc has ciphered all PDU's successfully or not. If success we
+ * pass it to lower layers. If Failure, we initimate failure.
+ *
+ * @param[in]         - Void
+
+ *
+ * @return            - Void
+ */
+#ifdef ANSI
+PUBLIC Void pjMsSpaccProcessDlBatchOutput(Void)
+#else
+PUBLIC Void pjMsSpaccProcessDlBatchOutput(Void)
+#endif
+{
+   U32 ret=ROK;
+   U32 jobNum=1;
+   Buffer *opSdu=NULLP;
+   PjMsSPACCOutputMapInfo spaccInfo;
+
+
+   for(;;)
+   {
+      /* Fetch Ciphered PDU's one by one from SPAcc */
+      ret = pjMsSpaccFetchDlPduInfo(&spaccInfo, &opSdu, jobNum, ROK);
+
+      /*No further packets for processing so break from here*/
+      if(ret == ROKDNA)
+      {
+         break;
+      }
+
+      if(ret == RFAILED)
+      {
+         /* Handling of failure of any of the Deciphered PDU's */
+         if((pjHndlCiphFail(&spaccInfo)) != ROK)
+         {
+            /* We get to this scenario when ueCb/RbCb/TxEnt is deleted already
+           due to either re-establishment or any other scenario. So we just
+           drop the packets for these */
+           PJ_FREE_BUF(opSdu);
+         }
+      }
+      else
+      {
+         /*Send the packet to RLC*/
+         pjProcCiphPdu(opSdu, &spaccInfo);
+      }
+
+      jobNum++;
+
+      /* Num PDU's sent to SPAcc cant be greater than the below condition.
+       * Hence break */
+      if(jobNum > (PJ_MS_MAX_JOBS_IN_QUEUE + 2))
+      {
+         RLOG1(L_ERROR, "Num Jobs in pjMsSpaccProcessDlBatchOutput "
+               "exceeds %ld, hence exiting!!!!", jobNum);
+         break;
+      }   
+   }
+}
+
+/**
+ * @brief This function is used to Process the o/p from SPAcc.
+ *
+ * @details This function is used to Process Deciphered PDU's from SPAcc. We
+ * check if SPAcc has deciphered all PDU's successfully or not. If success we
+ * pass it to lower layers. If Failure, we initimate failure.
+ *
+ * @param[in]         - Void
+
+ *
+ * @return            - Void
+ */
+#ifdef ANSI
+PUBLIC Void pjMsSpaccProcessUlBatchOutput(Void)
+#else
+PUBLIC Void pjMsSpaccProcessUlBatchOutput(Void)
+#endif
+{
+   U32 ret=ROK;
+   U32 retval = ROK;
+   U32 jobNum=1;
+   Buffer *opSdu=NULLP;
+   PjMsSPACCOutputMapInfo spaccInfo;
+
+   for(;;)
+   {
+      ret = pjMsSpaccFetchUlPduInfo(&spaccInfo, &opSdu, jobNum, ROK);
+      if(ret == ROKDNA)
+      {
+         break;
+      }
+
+      if(ret == RFAILED)
+      {
+         /* If one of the packets sent to SPAcc returns a failure, trigger
+         * handling of this failure scenario */
+         retval = pjHdlDecipherFailure(&spaccInfo);
+      }
+      else
+      {
+         /* Success case */
+         retval = pjProcDeCipherPdu(&spaccInfo, opSdu);
+      }
+
+      if(retval != ROK)
+      {
+         /* Drop o/p pdu's as either ueCb/RbCb/RxEnt is already deleted
+         due to reestablishment or other scenario */
+         PJ_FREE_BUF(opSdu);
+      }
+
+      jobNum++;
+
+      if(jobNum > (PJ_MS_MAX_JOBS_IN_QUEUE + 2))
+      {
+         RLOG1(L_ERROR, "Num Jobs in PjUlSpaccTrigger exceeds %ld,"
+               " hence aborting!!!!", jobNum);
+         break;
+      }   
+   }
+}
+
+
+/**
+ * @brief This function is used to deInit the CipherQ
+ *
+ * @details 
+ *
+ * @param[in]         - Void
+
+ *
+ * @return            - Void
+ */
+#ifdef ANSI
+PUBLIC Void pjSpaccDeInitCiphQ(Void)
+#else
+PUBLIC Void pjSpaccDeInitCiphQ(Void)
+#endif
+{
+#ifdef INTEL_NATIVE_SPACC
+   pjMsNativeSpaccDeInitCiphQ();
+#else
+   pjMsSpaccDeInitCiphQ();
+#endif
+   RETVOID;
+}
+
+/**
+ * @brief This function is used to deInit the DeCipherQ
+ *
+ * @details 
+ *
+ * @param[in]         - Void
+
+ *
+ * @return            - Void
+ */
+#ifdef ANSI
+PUBLIC Void pjSpaccDeInitDeCipherQ(Void)
+#else
+PUBLIC Void pjSpaccDeInitDeCipherQ(Void)
+#endif
+{
+#ifdef INTEL_NATIVE_SPACC
+   pjMsNativeSpaccDeInitDeCiphQ();
+#else
+   /*pjMsSpaccDeInitCiphQ();*/
+   pjMsSpaccDeInitDeCipherQ();
+#endif
+   RETVOID;
+}
+
+#endif
+
+/**
+ *
+ * @brief 
+ *
+ *        pjUlBatchProcSplit- Process rbuf messages
+ *
+ *  @return  S16
+ *      -# ROK 
+ */
+#if defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF)
+#ifdef ANSI
+PUBLIC S16 pjUlBatchProcSplit 
+(
+Void
+)
+#else
+PUBLIC S16 pjUlBatchProcSplit()
+Void;
+#endif
+{
+  S16 ret1;
+/* Read from Ring Buffer and process PDCP packets */
+   Void *elmIndx = NULLP;
+   RxmBufReq *datInd = NULLP;
+   elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_ULPDCP);
+   while(NULLP != elmIndx)
+   {
+      datInd = (RxmBufReq *)elmIndx;
+      if(datInd->mBuf != NULLP)
+      {
+          ret1 = cmUnpkKwuDatInd(PjLiKwuDatInd, &datInd->pst, datInd->mBuf);
+          if(ret1 != ROK)
+          {
+#if (ERRCLASS & ERRCLS_DEBUG)
+              SLogError(ENTPJ, 0, SFndProcId(),
+                      __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
+                      (ErrVal)EPJXXX, (ErrVal)ERRZERO, "UNPACK ERROR\n");
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+          }
+      }
+      else
+      {
+#if (ERRCLASS & ERRCLS_DEBUG)
+          SLogError(ENTPJ, 0, SFndProcId(),
+                  __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
+                  (ErrVal)EPJXXX, (ErrVal)ERRZERO, "pjUlBatchProcSplit: mBuf NULL\n");
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+          if(datInd->mBuf)
+              cmUnpkKwuDatInd(PjLiKwuDatInd, &datInd->pst, datInd->mBuf);
+      }
+      
+      SsRngInfoTbl[SS_RNG_BUF_RX_TO_ULPDCP].nPktProc++;;//Number of pkt processed in tti
+      datInd->mBuf = NULLP;
+      SRngIncrRIndx(SS_RNG_BUF_RX_TO_ULPDCP);
+
+      if((elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_ULPDCP)) == NULLP)
+      break;
+   }
+
+   RETVALUE(ROK);
+}
+#endif
+
+#endif /* PTPJLIB */
+
+
+#ifdef ANSI
+PUBLIC S16 PjLibObdIntCloseReq
+(
+Void *intCxtId
+)
+#else
+PUBLIC S16 PjLibObdIntCloseReq(*intCxtId)
+Void *intCxtId;
+#endif
+{
+   TRC3(PjLibObdIntCloseReq)
+   RETVALUE(ROK);
+}
+
+
+
+\f  
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_ptmi.c b/src/5gnrpdcp/pj_ptmi.c
new file mode 100755 (executable)
index 0000000..9ec0be9
--- /dev/null
@@ -0,0 +1,607 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+
+        Name:     PDCP Layer Management interface
+
+        Type:     C source file
+
+        Desc:     This file contains source code for RLC layer management
+                  interface primitives. It includes the definition of the
+                  following functions and their portable function
+                  definitions.
+                     -- PjMiLpjCfgCfm
+                     -- PjMiLpjCntrlCfm
+                     -- PjMiLpjStaInd
+
+
+        File:     pj_ptmi.c
+
+*********************************************************************21*/
+
+\f
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "lpj.h"           /* LPJ defines */
+
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "lpj.x"           /* LPJ */
+
+
+/* local defines */
+#ifndef LCPJMILPJ
+#define PTPJLPJ
+#endif
+
+#ifndef SM
+#define PTPJLPJ
+#endif
+
+
+#ifdef PTPJLPJ
+
+EXTERN S16 PtMiLpjCfgCfm ARGS((Pst * pst, PjMngmt * cfgCfm));
+
+EXTERN S16 PtMiLpjCntrlCfm ARGS((Pst * pst, PjMngmt * cntlCfm));
+
+EXTERN S16 PtMiLpjStaInd ARGS((Pst * pst, PjMngmt * staInd));
+
+EXTERN S16 PtMiLpjStaCfm ARGS((Pst * pst, PjMngmt * staCfm));
+
+EXTERN S16 PtMiLpjStsCfm ARGS((Pst * pst, Action actn, PjMngmt * stsCfm));
+
+EXTERN S16 PtMiLpjTrcInd ARGS((Pst * pst, PjMngmt * trc, Buffer * mBuf));
+
+/* kw005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+EXTERN S16 PtMiLpjL2MeasCfm   ARGS((Pst *pst, PjL2MeasCfmEvt *measEvt));
+PRIVATE S16 PtMiLpjL2MeasStopCfm   ARGS((Pst *pst, U16 measType,U8 status));
+#endif /*  LTE_L2_MEAS */
+
+#endif /*--#ifdef PTPJLPJ--*/
+
+/*********************************************************************
+ *             Primitives for LPJ interface 
+ ********************************************************************/
+PRIVATE CONSTANT LpjCfgCfm PjMiLpjCfgCfmMt[] =
+{
+#ifdef LCPJMILPJ
+   cmPkLpjCfgCfm,
+#else
+   PtMiLpjCfgCfm,
+#endif
+#ifdef SM
+   SmMiLpjCfgCfm,
+#else
+   PtMiLpjCfgCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT LpjCntrlCfm PjMiLpjCntrlCfmMt[] =
+{
+#ifdef LCPJMILPJ
+   cmPkLpjCntrlCfm,
+#else
+   PtMiLpjCntrlCfm,
+#endif
+#ifdef SM
+   SmMiLpjCntrlCfm,
+#else
+   PtMiLpjCntrlCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT LpjStaInd PjMiLpjStaIndMt[] =
+{
+#ifdef LCPJMILPJ
+   cmPkLpjStaInd,
+#else
+   PtMiLpjStaInd,
+#endif
+#ifdef SM
+   SmMiLpjStaInd,
+#else
+   PtMiLpjStaInd,
+#endif
+};
+
+
+PRIVATE CONSTANT LpjStaCfm PjMiLpjStaCfmMt[] =
+{
+#ifdef LCPJMILPJ
+   cmPkLpjStaCfm,
+#else
+   PtMiLpjStaCfm,
+#endif
+#ifdef SM
+   SmMiLpjStaCfm,
+#else
+   PtMiLpjStaCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT LpjStsCfm PjMiLpjStsCfmMt[] =
+{
+#ifdef LCPJMILPJ
+   cmPkLpjStsCfm,
+#else
+   PtMiLpjStsCfm,
+#endif
+#ifdef SM
+   SmMiLpjStsCfm,
+#else
+   PtMiLpjStsCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT LpjTrcInd PjMiLpjTrcIndMt[] =
+{
+#ifdef LCPJMILPJ
+   cmPkLpjTrcInd,
+#else
+   PtMiLpjTrcInd,
+#endif
+#ifdef SM
+   SmMiLpjTrcInd,
+#else
+   PtMiLpjTrcInd,
+#endif
+};
+
+/* kw005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+PRIVATE CONSTANT LpjL2MeasCfm PjMiLpjL2MeasCfmMt[] =
+{
+#ifdef LCPJMILPJ
+   cmPkLpjL2MeasCfm,
+#else
+   PtMiLpjL2MeasCfm,
+#endif
+#ifdef SM
+   SmMiLpjL2MeasCfm,
+#else
+   PtMiLpjL2MeasCfm,
+#endif
+};
+PRIVATE CONSTANT LpjL2MeasStopCfm PjMiLpjL2MeasStopCfmMt[] =
+{
+#ifdef LCPJMILPJ
+   cmPkLpjL2MeasStopCfm,
+#else
+   PtMiLpjL2MeasStopCfm,
+#endif
+#ifdef SM
+   SmMiLpjL2MeasStopCfm,
+#else
+   PtMiLpjL2MeasStopCfm,
+#endif
+};
+#endif /*  LTE_L2_MEAS */
+
+/****************************************************************************
+ *                         LPJ Interface Mt functions
+ ***************************************************************************/
+#ifdef ANSI
+PUBLIC S16 PjMiLpjCfgCfm
+(
+Pst * pst,
+PjMngmt * cfgCfm
+)
+#else
+PUBLIC S16 PjMiLpjCfgCfm(pst, cfgCfm)
+Pst * pst;
+PjMngmt * cfgCfm;
+#endif
+{
+
+   TRC3(PjMiLpjCfgCfm)
+
+   (*PjMiLpjCfgCfmMt[pst->selector])(pst, cfgCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PjMiLpjCntrlCfm
+(
+Pst * pst,
+PjMngmt * cntlCfm
+)
+#else
+PUBLIC S16 PjMiLpjCntrlCfm(pst, cntlCfm)
+Pst * pst;
+PjMngmt * cntlCfm;
+#endif
+{
+
+   TRC3(PjMiLpjCntrlCfm)
+
+   (*PjMiLpjCntrlCfmMt[pst->selector])(pst, cntlCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PjMiLpjStaInd
+(
+Pst * pst,
+PjMngmt * staInd
+)
+#else
+PUBLIC S16 PjMiLpjStaInd(pst, staInd)
+Pst * pst;
+PjMngmt * staInd;
+#endif
+{
+
+   TRC3(PjMiLpjStaInd)
+
+   (*PjMiLpjStaIndMt[pst->selector])(pst, staInd);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PjMiLpjStaCfm
+(
+Pst * pst,
+PjMngmt * staCfm
+)
+#else
+PUBLIC S16 PjMiLpjStaCfm(pst, staCfm)
+Pst * pst;
+PjMngmt * staCfm;
+#endif
+{
+
+   TRC3(PjMiLpjStaCfm)
+
+   (*PjMiLpjStaCfmMt[pst->selector])(pst, staCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PjMiLpjStsCfm
+(
+Pst * pst,
+Action actn,
+PjMngmt * stsCfm
+)
+#else
+PUBLIC S16 PjMiLpjStsCfm(pst, actn, stsCfm)
+Pst * pst;
+Action actn;
+PjMngmt * stsCfm;
+#endif
+{
+
+   TRC3(PjMiLpjStsCfm)
+
+   (*PjMiLpjStsCfmMt[pst->selector])(pst, actn, stsCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PjMiLpjTrcInd
+(
+Pst * pst,
+PjMngmt * trc,
+Buffer * mBuf
+)
+#else
+PUBLIC S16 PjMiLpjTrcInd(pst, trc, mBuf)
+Pst * pst;
+PjMngmt * trc;
+Buffer * mBuf;
+#endif
+{
+
+   TRC3(PjMiLpjTrcInd)
+
+   (*PjMiLpjTrcIndMt[pst->selector])(pst, trc, mBuf);
+
+   RETVALUE(ROK);
+
+}
+
+/* kw005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+#ifdef ANSI
+PUBLIC S16 PjMiLpjL2MeasCfm
+(
+Pst * pst,
+PjL2MeasCfmEvt *measEvt
+)
+#else
+PUBLIC S16 PjMiLpjL2MeasCfm(pst, trc, mBuf)
+Pst * pst;
+PjL2MeasCfmEvt *measEvt;
+#endif
+{
+
+   TRC3(PjMiLpjL2MeasCfm)
+
+   (*PjMiLpjL2MeasCfmMt[pst->selector])(pst, measEvt);
+
+   RETVALUE(ROK);
+
+}
+#ifdef ANSI
+PUBLIC S16 PjMiLpjL2MeasStopCfm
+(  
+Pst *pst,
+U16  measType,
+U8  status
+)
+#else
+PUBLIC S16 PjMiLpjL2MeasStopCfm(pst, measType,status)
+Pst *pst;
+U16  measType;
+U8  status;
+#endif
+{
+
+   TRC3(PjMiLpjL2MeasStopCfm)
+
+   (*PjMiLpjL2MeasStopCfmMt[pst->selector])(pst, measType,status);
+
+   RETVALUE(ROK);
+
+}
+#endif /*  LTE_L2_MEAS */
+
+
+#ifdef PTPJLPJ
+
+
+#ifdef ANSI
+PUBLIC S16 PtMiLpjCfgCfm
+(
+Pst * pst,
+PjMngmt * cfgCfm
+)
+#else
+PUBLIC S16 PtMiLpjCfgCfm(pst, cfgCfm)
+Pst * pst;
+PjMngmt * cfgCfm;
+#endif
+{
+
+   TRC3(PtMiLpjCfgCfm)
+
+   UNUSED(pst);
+   UNUSED(cfgCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtMiLpjCntrlCfm
+(
+Pst * pst,
+PjMngmt * cntlCfm
+)
+#else
+PUBLIC S16 PtMiLpjCntrlCfm(pst, cntlCfm)
+Pst * pst;
+PjMngmt * cntlCfm;
+#endif
+{
+
+   TRC3(PtMiLpjCntrlCfm)
+
+   UNUSED(pst);
+   UNUSED(cntlCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtMiLpjStaInd
+(
+Pst * pst,
+PjMngmt * staInd
+)
+#else
+PUBLIC S16 PtMiLpjStaInd(pst, staInd)
+Pst * pst;
+PjMngmt * staInd;
+#endif
+{
+
+   TRC3(PtMiLpjStaInd)
+
+   UNUSED(pst);
+   UNUSED(staInd);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtMiLpjStaCfm
+(
+Pst * pst,
+PjMngmt * staCfm
+)
+#else
+PUBLIC S16 PtMiLpjStaCfm(pst, staCfm)
+Pst * pst;
+PjMngmt * staCfm;
+#endif
+{
+
+   TRC3(PtMiLpjStaCfm)
+
+   UNUSED(pst);
+   UNUSED(staCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtMiLpjStsCfm
+(
+Pst * pst,
+Action actn,
+PjMngmt * stsCfm
+)
+#else
+PUBLIC S16 PtMiLpjStsCfm(pst, actn, stsCfm)
+Pst * pst;
+Action actn;
+PjMngmt * stsCfm;
+#endif
+{
+
+   TRC3(PtMiLpjStsCfm)
+
+   UNUSED(pst);
+   UNUSED(actn);
+   UNUSED(stsCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtMiLpjTrcInd
+(
+Pst * pst,
+PjMngmt * trc,
+Buffer * mBuf
+)
+#else
+PUBLIC S16 PtMiLpjTrcInd(pst, trc, mBuf)
+Pst * pst;
+PjMngmt * trc;
+Buffer * mBuf;
+#endif
+{
+
+   TRC3(PtMiLpjTrcInd)
+
+   UNUSED(pst);
+   UNUSED(trc);
+   UNUSED(mBuf);
+
+   RETVALUE(ROK);
+
+}
+
+/* kw005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+#ifdef ANSI
+PUBLIC S16 PtMiLpjL2MeasCfm
+(
+Pst * pst,
+PjL2MeasCfmEvt * measEvt
+)
+#else
+PUBLIC S16 PtMiLpjL2MeasCfm(pst, measEvt)
+Pst * pst;
+PjL2MeasCfmEvt * measEvt;
+#endif
+{
+
+   TRC3(PtMiLpjL2MeasCfm)
+
+   UNUSED(pst);
+   UNUSED(measEvt);
+
+   RETVALUE(ROK);
+
+}
+#ifdef ANSI
+PRIVATE S16 PtMiLpjL2MeasStopCfm
+(
+Pst * pst,
+U16 measType,
+U8 status
+)
+#else
+PRIVATE S16 PtMiLpjL2MeasStopCfm(pst, measType,status)
+Pst * pst;
+U16  measType;
+U8  status;
+#endif
+{
+
+   TRC3(PtMiLpjL2MeasStopCfm)
+
+   UNUSED(pst);
+   UNUSED(measType);
+   UNUSED(status);
+
+   RETVALUE(ROK);
+
+}
+#endif /*  LTE_L2_MEAS */
+#endif /*--ifdef PTPJLPJ--*/
+
+/********************************************************************30**
+
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_ptsec.h b/src/5gnrpdcp/pj_ptsec.h
new file mode 100755 (executable)
index 0000000..bcfef97
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/**********************************************************************
+
+    Name:    LTE PDCP PAL INTERFACE 
+
+    Type:    C include file
+
+    Desc:   Defines required by LTE PDCP SPACC INTERFACE 
+
+    File:   pj_ptsec.h 
+
+**********************************************************************/
+
+#ifndef __PJ_PTSEC_PAL_H__
+#define __PJ_PTSEC_PAL_H__
+
+
+#define PJ_QUE_CHECK_FOR_MS(_rxEnt,_ulCb,_gCb);
+
+
+
+#endif/* __pj_ptsec_pal.h_*/
+/********************************************************************30**
+
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_ptsec.x b/src/5gnrpdcp/pj_ptsec.x
new file mode 100755 (executable)
index 0000000..b47bee5
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE PDCP-PAL Interface file 
+    
+        Type:    C include file
+  
+        Desc:    This file contains all the data structures and 
+                 prototypes for LTE PDCP.
+        File:    pj_ptsec.x
+  
+*********************************************************************21*/
+/** @file pj_ptsec.x
+@brief PDCP Product Structures, prototypes
+*/
+
+#ifndef __PJPTSECPALX__
+#define __PJPTSECPALX__
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+EXTERN S16 pjUtlChekTxEnqReq ARGS ((PjCb *gCb, PjDlRbCb *pjRbCb, PjTxEnt *txEnt));
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __PJPTSECPALX__ */
+
+\f  
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_ptui.c b/src/5gnrpdcp/pj_ptui.c
new file mode 100755 (executable)
index 0000000..8be4a74
--- /dev/null
@@ -0,0 +1,1189 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE-PDCP Layer - Upper Interface
+    
+        Type:    C file
+  
+        Desc:    C source code for the upper interface of LTE-PDCP
+        File:    pj_ptui.c
+  
+*********************************************************************21*/
+
+/** @file pj_ptui.c
+@brief PDCP Upper Interface
+*/
+
+\f
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "cpj.h"           /* CPJ defines */
+#include "pju.h"           /* PJU defines */
+#include "lpj.h"
+
+#include "pj_err.h"
+#include "pj_env.h"        /* RLC environment options */
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "cpj.x"           /* CPJ defines */
+#include "pju.x"           /* PJU defines */
+#include "lpj.x"           /* LPJ defines */
+
+
+#if !(defined(LCPJUICPJ)  && defined(NH))
+#define PTPJCPJ
+#endif
+
+#if !(defined(LCPJUIPJU) && (defined(PX))) || !(defined(NH))
+#define PTPJPJU
+#endif
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif /* __cplusplus */
+
+\f  
+/*********************************************************************
+ *             Forward Declartion for CPJ Porting Functions
+ ********************************************************************/
+#ifdef PTPJCPJ
+
+EXTERN S16 PtUiCpjBndCfm ARGS((Pst * pst, SuId suId, U8 status));
+
+EXTERN S16 PtUiCpjCfgCfm ARGS((Pst * pst, SuId suId, CpjCfgCfmInfo * cfgCfm));
+
+EXTERN S16 PtUiCpjReEstCfm ARGS((Pst * pst, SuId suId, CpjReEstCfmInfo * reEstCfm));
+
+EXTERN S16 PtUiCpjSecCfgCfm ARGS((Pst * pst, SuId suId, CpjSecCfgCfmInfo * secCfgCfm));
+
+EXTERN S16 PtUiCpjUeIdChgCfm ARGS((Pst * pst, SuId suId, U32 transId, CpjUeInfo  * ueInfo, CmStatus status));
+
+EXTERN S16 PtUiCpjCountCfm ARGS((Pst * pst, SuId suId, CpjCountCfmInfo * countCfm));
+
+EXTERN S16 PtUiCpjSduStaCfm ARGS((Pst * pst, SuId suId, CpjSduStaCfmInfo * staCfm));
+EXTERN S16 PtUiCpjKdfCfm ARGS((Pst* pst, SuId suId, CpjCfgTransId transId, CpjKdfCfmInfo *kdfCfmInf,
+U8 status
+));
+EXTERN S16 PtUiCpjDatResumeCfm ARGS(( Pst *pst, SuId suId, CpjDatResumeCfmInfo *datResumeCfm));
+#endif /* PTPJCPJ */
+
+\f  
+/*********************************************************************
+ *             Forward Declartion for PJU Porting Functions
+ ********************************************************************/
+#ifdef PTPJPJU
+
+EXTERN S16 PtUiPjuBndReq ARGS((Pst* pst, SpId spId, SuId suId));
+
+EXTERN S16 PtUiPjuBndCfm ARGS((Pst* pst, SuId suId, U8 status));
+
+EXTERN S16 PtUiPjuDatCfm ARGS((Pst* pst, SuId suId, CmLtePdcpId * pdcpId, PjuDatCfmInfo * datCfm));
+
+EXTERN S16 PtUiPjuDatInd ARGS((Pst* pst, SuId suId, CmLtePdcpId * pdcpId, Buffer * mBuf));
+
+EXTERN S16 PtUiPjuStaInd ARGS((Pst* pst, SuId suId, CmLtePdcpId * pdcpId, PjuStaIndInfo * staInd, Buffer *mBuf));
+
+EXTERN S16 PtUiPjuDatFwdInd ARGS((Pst* pst, SuId suId, CmLtePdcpId * pdcpId, PjuDatFwdIndInfo * datFwdInd));
+#endif /*--#ifdef PTPJPJU--*/
+
+\f  
+/*********************************************************************
+ *                         Primitives for CPJ interface 
+ ********************************************************************/
+PRIVATE CONSTANT CpjBndCfm PjUiCpjBndCfmMt[] =
+{
+#ifdef LCPJUICPJ
+   cmPkCpjBndCfm,
+#else
+   PtUiCpjBndCfm,
+#endif
+#ifdef NH
+   NhLiCpjBndCfm,
+#else
+   PtUiCpjBndCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT CpjCfgCfm PjUiCpjCfgCfmMt[] =
+{
+#ifdef LCPJUICPJ
+   cmPkCpjCfgCfm,
+#else
+   PtUiCpjCfgCfm,
+#endif
+#ifdef NH
+   NhLiCpjCfgCfm,
+#else
+   PtUiCpjCfgCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT CpjReEstCfm PjUiCpjReEstCfmMt[] =
+{
+#ifdef LCPJUICPJ
+   cmPkCpjReEstCfm,
+#else
+   PtUiCpjReEstCfm,
+#endif
+#ifdef NH
+   NhLiCpjReEstCfm,
+#else
+   PtUiCpjReEstCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT CpjSecCfgCfm PjUiCpjSecCfgCfmMt[] =
+{
+#ifdef LCPJUICPJ
+   cmPkCpjSecCfgCfm,
+#else
+   PtUiCpjSecCfgCfm,
+#endif
+#ifdef NH
+   NhLiCpjSecCfgCfm,
+#else
+   PtUiCpjSecCfgCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT CpjUeIdChgCfm PjUiCpjUeIdChgCfmMt[] =
+{
+#ifdef LCPJUICPJ
+   cmPkCpjUeIdChgCfm,
+#else
+   PtUiCpjUeIdChgCfm,
+#endif
+#ifdef NH
+   NhLiCpjUeIdChgCfm,
+#else
+   PtUiCpjUeIdChgCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT CpjCountCfm PjUiCpjCountCfmMt[] =
+{
+#ifdef LCPJUICPJ
+   cmPkCpjCountCfm,
+#else
+   PtUiCpjCountCfm,
+#endif
+#ifdef NH
+   NhLiCpjCountCfm,
+#else
+   PtUiCpjCountCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT CpjSduStaCfm PjUiCpjSduStaCfmMt[] =
+{
+#ifdef LCPJUICPJ
+   cmPkCpjSduStaCfm,
+#else
+   PtUiCpjSduStaCfm,
+#endif
+#ifdef NH
+   NhLiCpjSduStaCfm,
+#else
+   PtUiCpjSduStaCfm,
+#endif
+};
+
+PRIVATE CONSTANT CpjDatResumeCfm PjUiCpjDatResumeCfmMt[] =
+{
+#ifdef LCPJUICPJ
+   cmPkCpjDatResumeCfm,
+#else
+   PtUiCpjDatResumeCfm,
+#endif
+#ifdef NH
+   NhLiCpjDatResumeCfm,
+#else
+   PtUiCpjDatResumeCfm,
+#endif
+};
+
+/** @brief This API is used to receive a Config confirm from PDCP to
+ * Application.
+ */
+PRIVATE CONSTANT CpjKdfCfm PjUiCpjKdfCfmMt[] =
+{
+#ifdef LCPJUICPJ
+   cmPkCpjKdfCfm,
+#else
+   PtUiCpjKdfCfm,
+#endif
+#ifdef NH
+   PtUiCpjKdfCfm
+#else
+   PtUiCpjKdfCfm
+#endif
+
+};
+
+\f  
+/****************************************************************************
+ *                         CPJ Interface Mt functions
+ ***************************************************************************/\f
+#ifdef PJ
+#ifdef ANSI
+PUBLIC S16 PjUiCpjBndCfm
+(
+Pst * pst,
+SuId suId,
+U8 status
+)
+#else
+PUBLIC S16 PjUiCpjBndCfm(pst, suId, status)
+Pst * pst;
+SuId suId;
+U8 status;
+#endif
+{
+
+   TRC3(PjUiCpjBndCfm)
+
+   (*PjUiCpjBndCfmMt[pst->selector])(pst, suId, status);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjUiCpjCfgCfm
+(
+Pst * pst,
+SuId suId,
+CpjCfgCfmInfo * cfgCfm
+)
+#else
+PUBLIC S16 PjUiCpjCfgCfm(pst, suId, cfgCfm)
+Pst * pst;
+SuId suId;
+CpjCfgCfmInfo * cfgCfm;
+#endif
+{
+
+   TRC3(PjUiCpjCfgCfm)
+
+   (*PjUiCpjCfgCfmMt[pst->selector])(pst, suId, cfgCfm);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjUiCpjReEstCfm
+(
+Pst * pst,
+SuId suId,
+CpjReEstCfmInfo * reEstCfm
+)
+#else
+PUBLIC S16 PjUiCpjReEstCfm(pst, suId, reEstCfm)
+Pst * pst;
+SuId suId;
+CpjReEstCfmInfo * reEstCfm;
+#endif
+{
+
+   TRC3(PjUiCpjReEstCfm)
+
+   (*PjUiCpjReEstCfmMt[pst->selector])(pst, suId, reEstCfm);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjUiCpjSecCfgCfm
+(
+Pst * pst,
+SuId suId,
+CpjSecCfgCfmInfo * secCfgCfm
+)
+#else
+PUBLIC S16 PjUiCpjSecCfgCfm(pst, suId, secCfgCfm)
+Pst * pst;
+SuId suId;
+CpjSecCfgCfmInfo * secCfgCfm;
+#endif
+{
+
+   TRC3(PjUiCpjSecCfgCfm)
+
+   (*PjUiCpjSecCfgCfmMt[pst->selector])(pst, suId, secCfgCfm);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjUiCpjUeIdChgCfm
+(
+Pst * pst,
+SuId suId,
+U32 transId,
+CpjUeInfo  * ueInfo,
+CmStatus status
+)
+#else
+PUBLIC S16 PjUiCpjUeIdChgCfm(pst, suId, transId, ueInfo, status)
+Pst * pst;
+SuId suId;
+U32 transId;
+CpjUeInfo  * ueInfo;
+CmStatus status;
+#endif
+{
+
+   TRC3(PjUiCpjUeIdChgCfm)
+
+   (*PjUiCpjUeIdChgCfmMt[pst->selector])(pst, suId, transId, ueInfo, status);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjUiCpjCountCfm
+(
+Pst * pst,
+SuId suId,
+CpjCountCfmInfo * countCfm
+)
+#else
+PUBLIC S16 PjUiCpjCountCfm(pst, suId, countCfm)
+Pst * pst;
+SuId suId;
+CpjCountCfmInfo * countCfm;
+#endif
+{
+
+   TRC3(PjUiCpjCountCfm)
+
+   (*PjUiCpjCountCfmMt[pst->selector])(pst, suId, countCfm);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjUiCpjSduStaCfm
+(
+Pst * pst,
+SuId suId,
+CpjSduStaCfmInfo * staCfm
+)
+#else
+PUBLIC S16 PjUiCpjSduStaCfm(pst, suId, staCfm)
+Pst * pst;
+SuId suId;
+CpjSduStaCfmInfo * staCfm;
+#endif
+{
+
+   TRC3(PjUiCpjSduStaCfm)
+
+   (*PjUiCpjSduStaCfmMt[pst->selector])(pst, suId, staCfm);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjUiCpjDatResumeCfm
+(
+Pst                   *pst,
+SuId                  suId,
+CpjDatResumeCfmInfo   *datResCfm
+)
+#else
+PUBLIC S16 PjUiCpjDatResumeCfm(pst, suId, datResCfm)
+Pst                   *pst;
+SuId                  suId;
+CpjDatResumeCfmInfo   *datResCfm;
+#endif
+{
+
+   TRC3(PjUiCpjDataResumeCfm)
+
+   (*PjUiCpjDatResumeCfmMt[pst->selector])(pst, suId, datResCfm);
+
+   RETVALUE(ROK);
+}
+/**
+* @brief This API is used to receive a Bind confirm from PDCP to Application.
+*
+* @details
+*
+*     Function : PjUiCpjKdfCfm
+*
+*  @param[in]   pst - Post structure
+*  @param[in]   suId - Service User Id
+*  @param[in]   transId - Transaction Id
+*  @param[in]   kdfCfmInf - Generated keys
+*  @param[in]   status - status of KDF request
+*  @return   S16
+*      -# ROK
+**/
+#ifdef ANSI
+PUBLIC S16 PjUiCpjKdfCfm
+(
+Pst* pst,
+SuId suId,
+CpjCfgTransId transId,
+CpjKdfCfmInfo *kdfCfmInf,
+U8 status
+)
+#else
+PUBLIC S16 PjUiCpjKdfCfm(pst, suId, transId, status)
+Pst* pst;
+SuId suId;
+CpjCfgTransId transId;
+CpjKdfCfmInfo *kdfCfmInf;
+U8 status;
+#endif
+{
+
+   TRC3(PtUiCpjCfgCfm);
+
+   (*PjUiCpjKdfCfmMt[pst->selector])(pst, suId, transId,kdfCfmInf, status);
+
+   RETVALUE(ROK);
+}
+#endif /*--ifdef PJ--*/
+
+\f  
+/*************************************************************************
+ *                         CPJ Porting Functions
+ ************************************************************************/
+#ifdef PTPJCPJ
+
+#ifdef ANSI
+PUBLIC S16 PtUiCpjBndCfm
+(
+Pst * pst,
+SuId suId,
+U8 status
+)
+#else
+PUBLIC S16 PtUiCpjBndCfm(pst, suId, status)
+Pst * pst;
+SuId suId;
+U8 status;
+#endif
+{
+
+   TRC3(PtUiCpjBndCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(status);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtUiCpjCfgCfm
+(
+Pst * pst,
+SuId suId,
+CpjCfgCfmInfo * cfgCfm
+)
+#else
+PUBLIC S16 PtUiCpjCfgCfm(pst, suId, cfgCfm)
+Pst * pst;
+SuId suId;
+CpjCfgCfmInfo * cfgCfm;
+#endif
+{
+
+   TRC3(PtUiCpjCfgCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(cfgCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtUiCpjReEstCfm
+(
+Pst * pst,
+SuId suId,
+CpjReEstCfmInfo * reEstCfm
+)
+#else
+PUBLIC S16 PtUiCpjReEstCfm(pst, suId, reEstCfm)
+Pst * pst;
+SuId suId;
+CpjReEstCfmInfo *reEstCfm;
+#endif
+{
+
+   TRC3(PtUiCpjReEstCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(reEstCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtUiCpjSecCfgCfm
+(
+Pst * pst,
+SuId suId,
+CpjSecCfgCfmInfo * secCfgCfm
+)
+#else
+PUBLIC S16 PtUiCpjSecCfgCfm(pst, suId, secCfgCfm)
+Pst * pst;
+SuId suId;
+CpjSecCfgCfmInfo * secCfgCfm;
+#endif
+{
+
+   TRC3(PtUiCpjSecCfgCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(secCfgCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtUiCpjUeIdChgCfm
+(
+Pst * pst,
+SuId suId,
+U32 transId,
+CpjUeInfo  * ueInfo,
+CmStatus status
+)
+#else
+PUBLIC S16 PtUiCpjUeIdChgCfm(pst, suId, transId, ueInfo, status)
+Pst * pst;
+SuId suId;
+U32 transId;
+CpjUeInfo  * ueInfo;
+CmStatus status;
+#endif
+{
+
+   TRC3(PtUiCpjUeIdChgCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(transId);
+   UNUSED(ueInfo);
+   UNUSED(status);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtUiCpjCountCfm
+(
+Pst * pst,
+SuId suId,
+CpjCountCfmInfo * countCfm
+)
+#else
+PUBLIC S16 PtUiCpjCountCfm(pst, suId, countCfm)
+Pst * pst;
+SuId suId;
+CpjCountCfmInfo * countCfm;
+#endif
+{
+
+   TRC3(PtUiCpjCountCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(countCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtUiCpjSduStaCfm
+(
+Pst * pst,
+SuId suId,
+CpjSduStaCfmInfo * staCfm
+)
+#else
+PUBLIC S16 PtUiCpjSduStaCfm(pst, suId, staCfm)
+Pst * pst;
+SuId suId;
+CpjSduStaCfmInfo * staCfm;
+#endif
+{
+
+   TRC3(PtUiCpjSduStaCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(staCfm);
+
+   RETVALUE(ROK);
+
+}
+
+#ifdef ANSI
+PUBLIC S16 PtUiCpjDatResumeCfm
+(
+Pst                   *pst,
+SuId                  suId,
+CpjDatResumeCfmInfo   *datResumeCfm
+)
+#else
+PUBLIC S16 PtUiCpjDatResumeCfm(pst, suId, dataResCfm)
+Pst                    *pst;
+SuId                   suId;
+CpjDataResumeCfmInfo   *datResumeCfm;
+#endif
+{
+
+   TRC3(PtUiCpjDataResCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(datResumeCfm);
+
+   RETVALUE(ROK);
+
+}
+
+/**
+* @brief This is a portable API for KDF function 
+*
+* @details
+*
+*     Function : PtUiCpjKdfCfm
+*
+*  @param[in]   pst - Post structure
+*  @param[in]   suId - Service User Id
+*  @param[in]   transId - Transaction Id
+*  @param[in]   kdfCfmInf - Generated keys
+*  @param[in]   status - status of KDF request
+*  @return   S16
+*      -# ROK
+**/
+#ifdef ANSI
+PUBLIC S16 PtUiCpjKdfCfm
+(
+Pst* pst,
+SuId suId,
+CpjCfgTransId transId,
+CpjKdfCfmInfo *kdfCfmInf,
+U8 status
+)
+#else
+PUBLIC S16 PtUiCpjKdfCfm(pst, suId, transId, status)
+Pst* pst;
+SuId suId;
+CpjCfgTransId transId;
+CpjKdfCfmInfo *kdfCfmInf;
+U8 status;
+#endif
+{
+
+   TRC3(PtUiCpjKdfCfm);
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(transId);
+   UNUSED(kdfCfmInf);
+   UNUSED(status);
+
+   RETVALUE(ROK);
+}
+#endif /*--ifdef PTPJCPJ--*/
+
+\f  
+/*********************************************************************
+ *                         Primitives for PJU interface 
+ ********************************************************************/
+
+PRIVATE CONSTANT PjuBndCfm PjUiPjuBndCfmMt[] =
+{
+#ifdef LCPJUIPJU
+   cmPkPjuBndCfm,
+#else
+   PtUiPjuBndCfm,
+#endif
+#ifdef NH
+   NhLiPjuBndCfm,
+#else
+   PtUiPjuBndCfm,
+#endif
+#ifdef PX
+   PxLiPjuBndCfm,
+#else
+   PtUiPjuBndCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT PjuDatCfm PjUiPjuDatCfmMt[] =
+{
+#ifdef LCPJUIPJU
+   cmPkPjuDatCfm,
+#else
+   PtUiPjuDatCfm,
+#endif
+#ifdef NH
+   NhLiPjuDatCfm,
+#else
+   PtUiPjuDatCfm,
+#endif
+#ifdef PX
+   PxLiPjuDatCfm,
+#else
+   PtUiPjuDatCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT PjuDatInd PjUiPjuDatIndMt[] =
+{
+#ifdef SS_RBUF
+#ifndef TENB_ACC 
+#ifdef LCPJUIPJU
+   cmPkFpPjuDatInd,
+#else
+   PtUiPjuDatInd,
+#endif
+#endif
+#else
+#ifdef LCPJUIPJU
+   cmPkPjuDatInd,
+#else
+   PtUiPjuDatInd,
+#endif
+#endif
+#ifdef NH
+   NhLiPjuDatInd,
+#else
+   PtUiPjuDatInd,
+#endif
+#ifdef PX
+   PxLiPjuDatInd,
+#else
+   PtUiPjuDatInd,
+#endif
+};
+
+
+PRIVATE CONSTANT PjuStaInd PjUiPjuStaIndMt[] =
+{
+#ifdef LCPJUIPJU
+   cmPkPjuStaInd,
+#else
+   PtUiPjuStaInd,
+#endif
+#ifdef NH
+   NhLiPjuStaInd,
+#else
+   PtUiPjuStaInd,
+#endif
+#ifdef PX
+   PxLiPjuStaInd,
+#else
+   PtUiPjuStaInd,
+#endif
+};
+
+
+PRIVATE CONSTANT PjuDatFwdInd PjUiPjuDatFwdIndMt[] =
+{
+#ifdef LCPJUIPJU
+   cmPkPjuDatFwdInd,
+#else
+   PtUiPjuDatFwdInd,
+#endif
+#ifdef NH
+   NhLiPjuDatFwdInd,
+#else
+   PtUiPjuDatFwdInd,
+#endif
+#ifdef PX
+   PxLiPjuDatFwdInd,
+#else
+   PtUiPjuDatFwdInd,
+#endif
+};
+
+\f  
+/****************************************************************************
+ *                         PJU Interface Mt functions
+ ***************************************************************************/\f
+#ifdef PJ
+
+#ifdef ANSI
+PUBLIC S16 PjUiPjuBndCfm
+(
+Pst* pst,
+SuId suId,
+U8 status
+)
+#else
+PUBLIC S16 PjUiPjuBndCfm(pst, suId, status)
+Pst* pst;
+SuId suId;
+U8 status;
+#endif
+{
+
+   TRC3(PjUiPjuBndCfm)
+
+   (*PjUiPjuBndCfmMt[pst->selector])(pst, suId, status);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PjUiPjuDatCfm
+(
+Pst* pst,
+SuId suId,
+CmLtePdcpId * pdcpId,
+PjuDatCfmInfo * datCfm
+)
+#else
+PUBLIC S16 PjUiPjuDatCfm(pst, suId, pdcpId, datCfm)
+Pst* pst;
+SuId suId;
+CmLtePdcpId * pdcpId;
+PjuDatCfmInfo * datCfm;
+#endif
+{
+
+   TRC3(PjUiPjuDatCfm)
+
+   (*PjUiPjuDatCfmMt[pst->selector])(pst, suId, pdcpId, datCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PjUiPjuDatInd
+(
+Pst* pst,
+SuId suId,
+CmLtePdcpId * pdcpId,
+Buffer * mBuf
+)
+#else
+PUBLIC S16 PjUiPjuDatInd(pst, suId, pdcpId, mBuf)
+Pst* pst;
+SuId suId;
+CmLtePdcpId * pdcpId;
+Buffer * mBuf;
+#endif
+{
+
+   TRC3(PjUiPjuDatInd)
+
+   (*PjUiPjuDatIndMt[pst->selector])(pst, suId, pdcpId, mBuf);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PjUiPjuStaInd
+(
+Pst * pst,
+SuId suId,
+CmLtePdcpId * pdcpId,
+PjuStaIndInfo * staInd,
+Buffer    *mBuf
+)
+#else
+PUBLIC S16 PjUiPjuStaInd(pst, suId, pdcpId, staInd, mBuf)
+Pst * pst;
+SuId suId;
+CmLtePdcpId * pdcpId;
+PjuStaIndInfo * staInd;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(PjUiPjuStaInd)
+
+   (*PjUiPjuStaIndMt[pst->selector])(pst, suId, pdcpId, staInd, mBuf);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PjUiPjuDatFwdInd
+(
+Pst* pst,
+SuId suId,
+CmLtePdcpId * pdcpId,
+PjuDatFwdIndInfo * datFwdInd
+)
+#else
+PUBLIC S16 PjUiPjuDatFwdInd(pst, suId, pdcpId, datFwdInd)
+Pst* pst;
+SuId suId;
+CmLtePdcpId * pdcpId;
+PjuDatFwdIndInfo * datFwdInd;
+#endif
+{
+
+   TRC3(PjUiPjuDatFwdInd)
+
+   (*PjUiPjuDatFwdIndMt[pst->selector])(pst, suId, pdcpId, datFwdInd);
+
+   RETVALUE(ROK);
+
+}
+#endif /*--ifdef PJ--*/
+
+\f  
+/*************************************************************************
+ *                         PJU Porting Functions
+ ************************************************************************/
+#ifdef PTPJPJU
+
+#ifdef ANSI
+PUBLIC S16 PtUiPjuBndReq
+(
+Pst* pst,
+SpId spId,
+SuId suId
+)
+#else
+PUBLIC S16 PtUiPjuBndReq(pst, spId, suId)
+Pst* pst;
+SpId spId;
+SuId suId;
+#endif
+{
+
+   TRC3(PtUiPjuBndReq)
+
+   UNUSED(pst);
+   UNUSED(spId);
+   UNUSED(suId);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtUiPjuBndCfm
+(
+Pst* pst,
+SuId suId,
+U8 status
+)
+#else
+PUBLIC S16 PtUiPjuBndCfm(pst, suId, status)
+Pst* pst;
+SuId suId;
+U8 status;
+#endif
+{
+
+   TRC3(PtUiPjuBndCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(status);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtUiPjuDatCfm
+(
+Pst* pst,
+SuId suId,
+CmLtePdcpId * pdcpId,
+PjuDatCfmInfo * datCfm
+)
+#else
+PUBLIC S16 PtUiPjuDatCfm(pst, suId, pdcpId, datCfm)
+Pst* pst;
+SuId suId;
+CmLtePdcpId * pdcpId;
+PjuDatCfmInfo * datCfm;
+#endif
+{
+
+   TRC3(PtUiPjuDatCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(pdcpId);
+   UNUSED(datCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtUiPjuDatInd
+(
+Pst* pst,
+SuId suId,
+CmLtePdcpId * pdcpId,
+Buffer * mBuf
+)
+#else
+PUBLIC S16 PtUiPjuDatInd(pst, suId, pdcpId, mBuf)
+Pst* pst;
+SuId suId;
+CmLtePdcpId * pdcpId;
+Buffer * mBuf;
+#endif
+{
+
+   TRC3(PtUiPjuDatInd)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(pdcpId);
+   UNUSED(mBuf);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtUiPjuStaInd
+(
+Pst* pst,
+SuId suId,
+CmLtePdcpId * pdcpId,
+PjuStaIndInfo * staInd,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 PtUiPjuStaInd(pst, suId, pdcpId, staInd, mBuf)
+Pst* pst;
+SuId suId;
+CmLtePdcpId * pdcpId;
+PjuStaIndInfo * staInd;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(PtUiPjuStaInd)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(pdcpId);
+   UNUSED(staInd);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtUiPjuDatFwdInd
+(
+Pst* pst,
+SuId suId,
+CmLtePdcpId * pdcpId,
+PjuDatFwdIndInfo * datFwdInd
+)
+#else
+PUBLIC S16 PtUiPjuDatFwdInd(pst, suId, pdcpId, datFwdInd)
+Pst* pst;
+SuId suId;
+CmLtePdcpId * pdcpId;
+PjuDatFwdIndInfo * datFwdInd;
+#endif
+{
+
+   TRC3(PtUiPjuDatFwdInd)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(pdcpId);
+   UNUSED(datFwdInd);
+
+   RETVALUE(ROK);
+
+}
+#endif /*--ifdef PTPJPJU--*/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_sec.h b/src/5gnrpdcp/pj_sec.h
new file mode 100755 (executable)
index 0000000..159476a
--- /dev/null
@@ -0,0 +1,248 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+ #include "prc_types.h"
+/* lenghth of the pointer variable */
+#define BC_ICPU_MSG_LEN  sizeof(BcIcpuMsg)
+#define BC_LOCAL_REG     0
+#define BC_SHARED_REG    1
+#define BC_ICPU_MSG_NOR  0
+#define BC_ICPU_MSG_FREE 1
+
+#define BC_MAX_PDU_CIPHER_REQ 1
+#define BC_MAX_PDU_INTPROT_REQ 1
+#define BC_MAX_CPU 2
+
+
+#define PJ_SEC_ALLOC(_cb, _buf, _size)                         \
+{                                                          \
+ if (SGetSBuf(1,0, (Data **)&_buf,\
+                (Size) _size) == ROK)                      \
+   {                                                       \
+      cmMemset((U8 *)(_buf), 0, _size);                    \
+   }                                                       \
+   else                                                    \
+   {                                                       \
+      (_buf) = NULLP;                                      \
+   }                                                       \
+}
+typedef struct intProtCallBkParams
+{
+   PRC_SNOW_INTEGRITY_PARAMS *intgrtyParams;
+   U32                       numPdu;
+   PRC_SNOW_INTEGRITY_DATA   *pdu_list;
+   PjLibTrans                libTrans; 
+   Pst                    *pst;
+   Buffer                 *pduInfoBuffer;
+   Buffer                 *pduListBuffer;
+}IntProtCallBkParams;
+typedef struct intVerCallBkParams
+{
+   PRC_SNOW_INTEGRITY_PARAMS *intgrtyParams;
+   U32                       numPdu;
+   PRC_SNOW_INTEGRITY_DATA   *pdu_list;
+   PjLibTrans                libTrans; 
+   Pst                    *pst;
+   Buffer                 *pduInfoBuffer;
+   Buffer                 *pduListBuffer;
+   U32                    recvMacI;
+}IntVerCallBkParams;
+
+#ifdef CIPH_BATCH_PROC
+typedef struct pjTxEntDtl {
+  void   *txEnt;
+  void  *rbCb;
+}PjTxEntDtl;
+
+typedef struct pjRxEntDtl {
+  void   *rxEnt;
+  void  *rbCb;
+}PjRxEntDtl;
+#endif
+typedef struct cipherCallBkParams
+{
+#ifdef CIPH_BATCH_PROC
+   Data                  *cipheredBuf[32];
+   PjTxEnt                *txEntLst[32];      
+   PjRxEnt                *rxEntLst[32];      
+   PRC_SNOW_CIPHER_DATA *pduList;
+#else
+   PRC_SNOW_CIPHER_DATA   *pdu_list;
+   PjLibTrans             libTrans; 
+   Buffer                 *mBuf[10];
+   Buffer                 *pduInfoBuffer;
+   Buffer                 *pduListBuffer;
+   Pst                    *pst;
+#endif
+   U32                    numTxPdu;
+   U32                    numRxPdu;
+   PRC_SNOW_CIPHER_PARAMS *cipherParams;
+}CipherCallBkParams;
+
+/* ZUC_ALGO start */
+typedef struct zucIntProtCallBkParams
+{
+   PRC_ZUC_INTEGRITY_PARAMS *intgrtyParams;
+   U32                       numPdu;
+   PRC_ZUC_INTEGRITY_DATA   *pdu_list;
+   PjLibTrans                libTrans; 
+   Pst                    *pst;
+   Buffer                 *pduInfoBuffer;
+   Buffer                 *pduListBuffer;
+}ZucIntProtCallBkParams;
+
+typedef struct zucIntVerCallBkParams
+{
+   PRC_ZUC_INTEGRITY_PARAMS *intgrtyParams;
+   U32                       numPdu;
+   PRC_ZUC_INTEGRITY_DATA   *pdu_list;
+   PjLibTrans                libTrans; 
+   Pst                    *pst;
+   Buffer                 *pduInfoBuffer;
+   Buffer                 *pduListBuffer;
+   U32                    recvMacI;
+}ZucIntVerCallBkParams;
+
+typedef struct zucEncryptCallBkParams
+{
+#ifdef CIPH_BATCH_PROC
+   Data                  *encryptBuf[32];
+   PjTxEnt                *txEntLst[32];      
+   PjRxEnt                *rxEntLst[32];
+   PRC_ZUC_ENCRYPTION_DATA  *pduList;      
+#else
+   PRC_ZUC_ENCRYPTION_DATA   *pdu_list;
+   PjLibTrans             libTrans; 
+   Buffer                 *mBuf[10];
+   Buffer                 *pduInfoBuffer;
+   Buffer                 *pduListBuffer;
+   Pst                    *pst;
+#endif
+   U32                    numTxPdu;
+   U32                    numRxPdu;
+   PRC_ZUC_ENCRYPTION_PARAMS *encryptParams;
+}ZucEncryptCallBkParams;
+/* ZUC_ALGO - end */
+
+#ifdef AES
+typedef struct aesIntProtCallBkParams
+{
+   PRC_AES_INTEGRITY_PARAMS *intgrtyParams;
+   U32                       numPdu;
+   PRC_AES_INTEGRITY_DATA   *pdu_list;
+   PjLibTrans                libTrans; 
+   Pst                    *pst;
+   Buffer                 *pduInfoBuffer;
+   Buffer                 *pduListBuffer;
+}AesIntProtCallBkParams;
+
+typedef struct aesIntVerCallBkParams
+{
+   PRC_AES_INTEGRITY_PARAMS *intgrtyParams;
+   U32                       numPdu;
+   PRC_AES_INTEGRITY_DATA   *pdu_list;
+   PjLibTrans                libTrans; 
+   Pst                    *pst;
+   Buffer                 *pduInfoBuffer;
+   Buffer                 *pduListBuffer;
+   U32                    recvMacI;
+}AesIntVerCallBkParams;
+
+typedef struct aesEncryptCallBkParams
+{
+#ifdef CIPH_BATCH_PROC
+   Data                  *encryptBuf[32];
+   PjTxEnt                *txEntLst[32];      
+   PjRxEnt                *rxEntLst[32];
+   PRC_AES_ENCRYPTION_DATA  *pduList;      
+#else
+   PRC_AES_ENCRYPTION_DATA   *pdu_list;
+   PjLibTrans             libTrans; 
+   Buffer                 *mBuf[10];
+   Buffer                 *pduInfoBuffer;
+   Buffer                 *pduListBuffer;
+   Pst                    *pst;
+#endif
+   U32                    numTxPdu;
+   U32                    numRxPdu;
+   PRC_AES_ENCRYPTION_PARAMS *encryptParams;
+}AesEncryptCallBkParams;
+#endif /* AES */
+
+#ifdef CIPH_BATCH_PROC
+typedef struct deCipherCallBkParams
+{
+   U32                    numPdu;
+   PjRxEnt                *rxEntLst[32];      
+   //Buffer                 *deCipheredBuf[16];
+   PRC_SNOW_CIPHER_DATA *pduList;
+   PRC_SNOW_CIPHER_PARAMS *deCipherParams;
+}DecipherCallBkParams;
+
+typedef struct decryptCallBkParams
+{
+   U32                    numPdu;
+   PjRxEnt                *rxEntLst[32];      
+   //Buffer                 *deCipheredBuf[16];
+   PRC_ZUC_ENCRYPTION_DATA *pduList;
+   PRC_ZUC_ENCRYPTION_PARAMS *decryptParams;
+}DecryptCallBkParams;
+
+#ifdef AES
+typedef struct decryptAesCallBkParams
+{
+   U32                    numPdu;
+   PjRxEnt                *rxEntLst[32];      
+   //Buffer                 *deCipheredBuf[16];
+   PRC_AES_ENCRYPTION_DATA *pduList;
+   PRC_AES_ENCRYPTION_PARAMS *decryptParams;
+}DecryptAesCallBkParams;
+#endif
+#endif
+
+#ifdef PJ_INT_ASYNC
+extern  S16 pjUtlIntProtCallBk ARGS((
+U32 rc, 
+Void* callback_params
+));
+extern  S16 pjUtlIntVerCallBk ARGS((
+U32 rc, 
+Void* callback_params
+));
+
+
+extern S16 bcIntProtReq ARGS((
+Pst       *pst,
+PjSecInp   secInp,                  /* Input for Integrity protection */
+PjLibTrans libTrans,
+Buffer     *mBuf                  /* SDU to be compressed */
+));
+#else
+extern S16 bcIntProtReq ARGS((
+PjSecInp   secInp,                  /* Input for Integrity protection */
+PjDlUeCb *ueCb,
+Buffer     *mBuf,                  /* SDU to be compressed */
+U32        *macI                   /* Message authentication code for the SDU */
+));
+#endif
+
+extern S16 pjUtlCipherCallBk ARGS((U32 rc, Void* callback_params));
+#ifdef CIPH_BATCH_PROC
+extern S16 pjUtlBatchCipherCallBk ARGS((U32 rc, Void* callback_params));
+#endif
+
diff --git a/src/5gnrpdcp/pj_tenb_stats.c b/src/5gnrpdcp/pj_tenb_stats.c
new file mode 100755 (executable)
index 0000000..336237c
--- /dev/null
@@ -0,0 +1,340 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/**********************************************************************
+    Name:  
+    Type:   C include file
+    Desc:   
+    File:  pj_tenb_stats.c
+**********************************************************************/
+/* header include files (.h) */
+  
+#include "envopt.h"             /* Environment options */  
+#include "envdep.h"             /* Environment dependent */
+#include "envind.h"             /* Environment independent */
+#include "gen.h"                /* General */
+#include "ssi.h"                /* System services interface */
+#include "cm_llist.h"           /* Linked list header file */
+#include "cm_tkns.h"            /* Common tokens header file */
+
+
+/* header/extern include files (.x) */
+
+#include "gen.x"                /* General */
+#include "ssi.x"                /* System services interface */
+#include "cm_lib.x"             /* Common lib header file */
+#include "cm_llist.x"           /* Linked list header file */
+#include "cm_tkns.x"            /* Common tokens header file */
+#include "ss_queue.h"
+#include "ss_queue.x"
+#include "ss_task.x"
+#include "ss_msg.x"
+#include "l2_tenb_stats.x"    /* Total EnodeB Stats declarations */
+
+#ifdef TENB_STATS
+PUBLIC TSL2CellStatsCb* l2CellStats[L2_STATS_MAX_CELLS];
+PUBLIC TSL2UeStatsCb*   l2UeStats[L2_STATS_MAX_UES];
+PUBLIC CmLListCp        freeL2UeStatsLst; /*!< Free Pool of UE stats Blocks */
+PUBLIC CmLListCp        inUseL2UeStatsLst;/*!< In Use Pool of UE stats Blocks */
+
+/*
+*
+*       Fun:   TSL2AllocStatsMem
+*
+*       Desc:  Pre-Allocate Memory for L2 stats BLOCKs 
+*
+*       Ret:   
+*
+*       Notes: None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC Void TSL2AllocStatsMem 
+(
+ Region region,
+ Pool   pool 
+)
+#else
+PUBLIC Void TSL2AllocStatsMem(region, pool)
+ Region region;
+ Pool   pool;
+#endif
+{
+   U32 cnt=0;
+
+   TRC2(TSL2AllocStatsMem)
+
+   cmLListInit(&inUseL2UeStatsLst);     
+   cmLListInit(&freeL2UeStatsLst);      
+   for (cnt=0; cnt < L2_STATS_MAX_CELLS; cnt++)
+   {
+                 if(NULL == l2CellStats[cnt])
+                 {
+                if (SGetSBuf(region, pool, (Data **)&l2CellStats[cnt],
+                                                (Size)sizeof (TSL2CellStatsCb)) != ROK)
+                {
+                               printf("\n STATS Unexpected MEM Alloc Failure\n");
+                }
+         }
+        cmMemset((U8 *)l2CellStats[cnt], 0x00, (Size)sizeof(TSL2CellStatsCb));
+   }
+
+   for (cnt=0; cnt < L2_STATS_MAX_UES; cnt++)
+   {
+        TSL2UeStatsCb *statsCb = l2UeStats[cnt];
+                 if(NULL == statsCb)
+                 {
+                if (SGetSBuf(region, pool, (Data **)&statsCb,
+                                                (Size)sizeof (TSL2UeStatsCb)) != ROK)
+                {
+                               printf("\n STATS Unexpected MEM Alloc Failure at %d\n", (int)cnt);
+                }
+                 }
+        cmMemset((U8 *)statsCb, 0x00, (Size)sizeof(TSL2UeStatsCb));
+        statsCb->lnk.node = (PTR)statsCb;
+        cmLListAdd2Tail(&freeL2UeStatsLst, &statsCb->lnk);
+        l2UeStats[cnt] = statsCb;
+   }
+
+   RETVOID;
+}
+
+/*
+*
+*       Fun:   TSL2AllocUeStatsBlk
+*
+*       Desc:  Assign Stats Block for this UE[RNTI] 
+*
+*       Ret:   
+*
+*       Notes: None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC TSL2UeStatsCb* TSL2AllocUeStatsBlk 
+(
+ U16   rnti
+)
+#else
+PUBLIC TSL2UeStatsCb* TSL2AllocUeStatsBlk(rnti)
+ U16   rnti;
+#endif
+{
+   CmLList          *tmp = NULLP;
+   TSL2UeStatsCb  *statsCb = NULLP;
+
+   TRC2(TSL2AllocUeStatsBlk)
+
+   tmp = freeL2UeStatsLst.first;
+   if (tmp == NULLP)
+   {
+      printf("\n STATS Unexpected Mem BLK unavailable for UE %d\n", rnti);
+   }
+   cmLListDelFrm(&freeL2UeStatsLst, tmp);
+   statsCb = (TSL2UeStatsCb *)(tmp->node);
+   cmLListAdd2Tail(&inUseL2UeStatsLst, tmp);
+
+   statsCb->stats.rnti = (U32)rnti;
+   statsCb->inUse = TRUE;
+
+   RETVALUE(statsCb);
+}
+
+/*
+*
+*       Fun:   TSL2DeallocUeStatsBlk
+*
+*       Desc:  Deassign Stats Block for this UE[RNTI] 
+*
+*       Ret:   
+*
+*       Notes: None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC Void TSL2DeallocUeStatsBlk 
+(
+ U16              rnti,
+ TSL2UeStatsCb  *statsCb
+)
+#else
+PUBLIC Void TSL2DeallocUeStatsBlk(rnti, statsCb)
+ U16              rnti;
+ TSL2UeStatsCb  *statsCb;
+#endif
+{
+   TRC2(TSL2DeallocUeStatsBlk)
+
+   statsCb->inUse = FALSE;
+   cmLListDelFrm(&inUseL2UeStatsLst, &statsCb->lnk);
+   freeL2UeStatsLst.crnt = freeL2UeStatsLst.first;
+   cmLListInsAfterCrnt(&freeL2UeStatsLst, &statsCb->lnk);
+
+   RETVOID;
+}
+
+/*
+*
+*       Fun:   TSL2AllocCellStatsBlk
+*
+*       Desc:  Assign Stats Block for this CELL[CELLID] 
+*
+*       Ret:   
+*
+*       Notes: None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC TSL2CellStatsCb* TSL2AllocCellStatsBlk 
+(
+ U32 cellId
+)
+#else
+PUBLIC TSL2CellStatsCb* TSL2AllocCellStatsBlk(cellId)
+ U32 cellId;
+#endif
+{
+   TRC2(TSL2AllocCellStatsBlk)
+
+   if (cellId != 1)
+   {
+      printf("\n STATS Unexpected CellID = %d\n", (int)cellId);
+   }
+
+   RETVALUE(l2CellStats[cellId-1]);
+}
+
+/*
+*
+*       Fun:   TSL2DeallocCellStatsBlk
+*
+*       Desc:  Deassign Stats Block for this CELL[CELLID] 
+*
+*       Ret:   
+*
+*       Notes: None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC Void TSL2DeallocCellStatsBlk 
+(
+ U32 cellId
+)
+#else
+PUBLIC Void TSL2DeallocCellStatsBlk(cellId)
+ U32 cellId;
+#endif
+{
+   TRC2(TSL2DeallocCellStatsBlk)
+
+   RETVOID;
+}
+
+/*
+*
+*       Fun:   TSL2SendStatsToApp
+*
+*       Desc:  Collates and Sends STATS to Application 
+*              Send UE STATS first. 10 UEs are grouped in one message.
+*              Followed by CELL Stats. All CELLS are grouped in one msg.
+*              At Reception of CELL stats APP assumes STATS reception cycle is complete.
+*
+*       Ret:   
+*
+*       Notes: None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC Void TSL2SendStatsToApp
+(
+ Pst    *pst,
+ SuId   suId
+ )
+#else
+PUBLIC Void TSL2SendStatsToApp(pst, suId)
+ Pst    *pst;
+ SuId   suId;
+#endif
+{
+   U32 idx;
+
+   TRC2(TSL2SendStatsToApp)
+
+   for (idx = 0; idx < L2_STATS_MAX_UES; idx++)
+   {
+      TSL2UeStatsCb *statsCb = l2UeStats[idx];
+      U32 rnti;
+      if (statsCb->inUse != TRUE)
+      {
+         continue;
+      }
+      if (pst->selector == 0)
+      {
+         /* Loose Coupling */
+         TSInfPkSndL2UeStats(pst, suId, &statsCb->stats);
+      }
+      else
+      {
+#ifdef PX
+         /* Tight Coupling */
+         TSInfHdlL2UeStatsInd(pst, suId, &statsCb->stats);
+#endif
+      }
+      rnti = statsCb->stats.rnti;
+      cmMemset((U8 *)&statsCb->stats, 0x00, (Size)sizeof(TSInfL2UeStats));
+      statsCb->stats.rnti = rnti;
+   }
+
+   /* Allocate mBuf for CELLSTATS */
+   for (idx = 0; idx < L2_STATS_MAX_CELLS; idx++)
+   {
+      U16 cellId;
+      if (pst->selector == 0)
+      {
+         /* Loose Coupling */
+         TSInfPkSndL2CellStats(pst, suId, l2CellStats[idx]);
+      }
+      else
+      {
+#ifdef PX
+         /* Tight Coupling */
+         TSInfHdlL2CellStatsInd(pst, suId, l2CellStats[idx]);
+#endif
+      }
+      cellId = l2CellStats[idx]->cellId;
+      cmMemset((U8 *)l2CellStats[idx], 0x00, (Size)sizeof(TSInfL2CellStats));
+      l2CellStats[idx]->cellId = cellId;
+   }
+
+   RETVOID;
+}
+#endif /* TENB_STATS */
+/**********************************************************************
+         End of file:     pj_tenb_stats.c@@/main/tenb_5.0_RIB/3 - Tue Oct 27 14:21:16 2015
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_tmr.c b/src/5gnrpdcp/pj_tmr.c
new file mode 100755 (executable)
index 0000000..0377b33
--- /dev/null
@@ -0,0 +1,870 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    PDCP - TMR module file
+    
+        Type:    C source file
+  
+        Desc:    Source code for timer functions such as, 
+
+                 - pjStartTmr
+                 - pjStopTmr
+                 - pjTmrExpiry
+                 - pjHdlDiscTmrExp
+                 - pjHdlInitObdTmrExp 
+                 - pjHdlUeDelWaitTmrExp
+                  
+        File:    pj_tmr.c
+  
+*********************************************************************21*/
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=223;
+
+
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "cpj.h"           /* RRC layer */
+#include "pju.h"           /* PDCP service user */
+#include "kwu.h"
+#include "lpj.h"           /* LPJ defines */
+#include "pj_env.h"        /* RLC environment options */
+#include "pj.h"            /* RLC defines */
+#include "pj_err.h"        /* Error defines */
+#include "pj_udx.h"
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "cpj.x"           /* RRC layer */
+#include "kwu.x"
+#include "pju.x"           /* PDCP service user */
+#include "lpj.x"           /* LPJ */
+#include "pj.x"
+#include "pj_udx.h"
+#include "pj_udx.x"
+#include "pj_ul.x"
+#include "pj_dl.x"
+
+/* local defines */
+
+/* local externs */
+
+/* forward references */
+PRIVATE Void pjBndTmrExpiry ARGS ((S16 tmrEvnt, PTR cb));
+/* public variable declarations */
+
+/* This structure holds all the global structs we need. */
+
+/* private variable declarations */
+
+/* private function declarations */
+/** @file gp_pj_tmr.c
+@brief PDCP Timer Module
+**/
+
+/**
+ * @def PJ_TMR_CALCUATE_WAIT
+ *
+ *    This macro calculates and assigns wait time based on the value of the 
+ *    timer and the timer resolution. Timer value of 0 signifies that the
+ *    timer is not configured
+ *
+ * @param[out] _wait   Time for which to arm the timer changed to proper 
+ *                     value according to the resolution
+ * @param[in] _tmrVal   Value of the timer
+ * @param[in] _timerRes   Resolution of the timer
+ *
+ */
+#define PJ_TMR_CALCUATE_WAIT(_wait, _tmrVal, _timerRes)       \
+{                                                             \
+      (_wait) = ((_tmrVal) * SS_TICKS_SEC)/((_timerRes) * 1000); \
+      if((0 != (_tmrVal)) && (0 == (_wait)))                     \
+      {                                                          \
+               (_wait) = 1;                                            \
+            }                                                          \
+}
+
+/**
+ *
+ * @brief Handler to start timer
+ *       
+ *
+ * @b Description
+ *        This function is invoked by DLM modules to start the discard timer for SDUs.
+ *
+ *
+ *  @param[in] cb      Transmission Buffer control block 
+ *  @param[in] tmrEvnt Timer event to be started
+ *
+ * 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+*/
+#ifdef ANSI
+PUBLIC S16 pjStartTmr
+(
+PjCb      *gCb,
+PTR       cb,           /* Parent control block */
+S16       tmrEvnt       /* Timer event */
+)
+#else
+PUBLIC S16 pjStartTmr (gCb, cb, tmrEvnt) 
+PjCb      *gCb;
+PTR       cb;           /* Parent control block */
+S16       tmrEvnt;      /* Timer event */
+#endif
+{
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+   PjDlRbCb   *dlRbCb;
+   PjTxEnt  *txEnt;
+#endif
+   U16      wait;
+   CmTimer  *tmr;
+   U8       maxTmrs;
+   CmTmrArg arg;
+   /* kw005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS_COMMENT
+   PjL2MeasEvtCb *measEvtCb;
+#endif
+
+#ifdef LTE_L2_MEAS
+    PjL2Cb *pjL2Cb = NULLP;
+    PjCb   *tPjMeasCb = NULLP;
+#endif
+   PjUlRbCb   *ulRbCb;
+
+   TRC2(pjStartTmr)
+
+   RLOG1(L_DEBUG, "pjStartTmr(cb, tmrEvnt (%d)) ", tmrEvnt);
+
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+   ulRbCb  = NULLP; 
+   dlRbCb  = NULLP;
+   txEnt   = NULLP;
+
+
+#endif
+   wait    = 0;
+   tmr     = NULLP;
+   maxTmrs = 0;
+
+   switch (tmrEvnt)
+   {
+      case PJ_EVT_WAIT_KWU_BNDCFM:
+      {
+         PjKwuSapCb *kwuSap = (PjKwuSapCb *)cb;
+         wait   = (U16)((kwuSap->bndTmrInt * SS_TICKS_SEC)/(gCb->pjGenCfg.timeRes * 1000));  /*KW_FIX*/
+         if( (0 != kwuSap->bndTmrInt) && (0 == wait) )
+         {
+            wait = 1;
+         }
+         tmr    = &kwuSap->bndTmr;
+         maxTmrs = PJ_MAX_KWUSAP_TMR;
+         break;
+      }
+      case PJ_EVT_WAIT_UDX_BNDCFM:
+      {
+         PjUdxUlSapCb *udxSap = (PjUdxUlSapCb *)cb;
+         wait   = (U16)((udxSap->bndTmrInt * SS_TICKS_SEC)/(gCb->pjGenCfg.timeRes * 1000));  /*KW_FIX*/
+         if( (0 != udxSap->bndTmrInt) && (0 == wait) )
+         {
+            wait = 1;
+         }
+         tmr    = &udxSap->bndTmr;
+         maxTmrs = PJ_MAX_UDXSAP_TMR;
+         break;
+      }    
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+      case PJ_EVT_DL_OBD_TMR:
+      {
+         dlRbCb = (PjDlRbCb *)cb;
+         tmr=&(dlRbCb->dlCb.obdTmr);
+         maxTmrs = PJ_MAX_OBD_TMR;
+         txEnt = pjDbmGetTxEnt(gCb,&(dlRbCb->dlCb.txBuf), dlRbCb->dlCb.nxtToSub);
+         if ( txEnt != NULLP )
+         {
+            wait = gCb->pjGenCfg.obdTmrInt;
+            dlRbCb->dlCb.obdCount = txEnt->count;
+         }
+
+         break;
+      }
+      case PJ_EVT_UL_OBD_TMR:
+      {
+         ulRbCb = (PjUlRbCb *)cb;
+         tmr=&(ulRbCb->ulCb.obdTmr);
+         maxTmrs = PJ_MAX_OBD_TMR;
+         PJ_ULM_GET_SUBCNT(ulRbCb,(ulRbCb->ulCb.obdPdu),gCb);
+         if(pjDbmGetRxEnt(gCb,&(ulRbCb->ulCb.recBuf), ulRbCb->ulCb.obdPdu) != NULLP )
+         {
+            wait = gCb->pjGenCfg.obdTmrInt;
+         }
+
+         break;
+      } 
+      case PJ_EVT_OBD_WAIT_TMR:
+      {
+         if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_DL)
+         {
+            PjDlUeCb  *dlUeCb = (PjDlUeCb *)cb;
+            tmr=&(dlUeCb->libInfo.obdTmr);
+         }
+         else
+         {
+            PjUlUeCb  *ulUeCb = (PjUlUeCb *)cb;
+            tmr=&(ulUeCb->libInfo.obdTmr);
+         }
+         maxTmrs = PJ_MAX_OBD_TMR;
+         wait = gCb->pjGenCfg.obdWtTmrInt;
+         break;
+      }
+
+#endif
+      /* kw005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS_COMMENT
+      case PJ_EVT_L2_TMR:
+      {
+         measEvtCb = (PjL2MeasEvtCb *)cb;
+         tmr=&(measEvtCb->l2Tmr);
+         maxTmrs = PJ_L2_MAX_TIMERS;
+         wait = (measEvtCb->l2TmrCfg.val * SS_TICKS_SEC)/(pjCb.genCfg.timeRes * 1000);
+         if((measEvtCb->l2TmrCfg.val > 0) && wait == 0)
+         {
+            wait = 1;
+         }
+         break;
+      }
+#endif
+#ifdef LTE_L2_MEAS
+      case PJ_EVT_L2_MEAS_TMR:
+      {
+         tPjMeasCb = (PjCb      *)cb;
+         pjL2Cb = &tPjMeasCb->u.ulCb->pjL2Cb;
+         tmr=&(pjL2Cb->measTmr);
+         maxTmrs = PJ_L2_MAX_TIMERS;
+         wait = (pjL2Cb->measTmrCfg.val * SS_TICKS_SEC)/(gCb->pjGenCfg.timeRes * 1000);
+         wait = 500;
+         if((pjL2Cb->measTmrCfg.val > 0) && wait == 0)
+         {
+            wait = 1;
+         }
+         break;
+      }
+#endif
+     case PJ_EVT_UL_REORD_TMR:
+      {
+         ulRbCb = (PjUlRbCb *)cb;
+         tmr=&(ulRbCb->ulCb.tReordTmr);
+         maxTmrs = PJ_MAX_UL_REORD_TMRS;
+         PJ_TMR_CALCUATE_WAIT(wait, ulRbCb->reOrdrTmrVal, gCb->pjGenCfg.timeRes);
+         break;
+      }
+      default:
+      {
+         RLOG0(L_ERROR, "Invalid Start tmr Evnt");
+         RETVALUE(RFAILED);
+      }
+   } 
+
+   if(wait != 0)
+   {
+      arg.tqCp   = &gCb->pjTqCp;
+      arg.tq     = gCb->pjTq;
+      arg.cb     = cb;
+      arg.timers = tmr;
+      arg.evnt   = tmrEvnt;
+      arg.wait   = wait;
+      arg.tNum   = 0;
+      arg.max    = maxTmrs;
+
+      cmPlcCbTq(&arg);
+   }
+
+   RETVALUE(ROK);
+}
+
+/**
+ *
+ * @brief Handler to stop timer
+ *       
+ *
+ * @b Description
+ *        This function is used to stop protocol timer, based on the timer event.
+ *
+ *
+ *  @param[in] cb      Transmission Buffer control block 
+ *  @param[in] tmrEvnt Timer event to be started 
+ *
+ * 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+*/
+#ifdef ANSI
+PUBLIC S16 pjStopTmr
+(
+PjCb   *gCb,
+PTR    cb,              /* Parent control block */
+U8     tmrEvnt          /* Timer */
+)
+#else
+PUBLIC S16 pjStopTmr (gCb, cb, tmrEvnt) 
+PjCb   *gCb;
+PTR    cb;              /* Parent control block */
+U8     tmrEvnt;         /* Timer */
+#endif
+{
+   CmTmrArg     arg;
+   CmTimer      *tmr;
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+   PjDlRbCb     *pjDlRbCb;
+#endif
+   PjKwuSapCb   *kwuSap;
+   PjUdxUlSapCb   *udxSap;
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+   PjDlUeCb       *dlUeCb;
+   PjUlUeCb       *ulUeCb;
+#endif
+   /* kw005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+   PjL2Cb *pjL2Cb = NULLP;
+   PjCb   *tPjMeasCb = NULLP;
+#endif
+   U8           maxTimers;
+   PjUlRbCb     *pjUlRbCb;
+
+   TRC2(pjStopTmr)
+   
+   RLOG1(L_DEBUG, "pjStopTmr(cb, tmrEvnt(%d)) ", tmrEvnt);
+   
+   tmr = NULLP;
+   maxTimers = 0;
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+   pjUlRbCb = NULLP;
+   pjDlRbCb    = NULLP;
+   /* ueCb   = NULLP; */
+#endif
+
+   switch (tmrEvnt)
+   {
+      case PJ_EVT_WAIT_KWU_BNDCFM:
+      {
+         kwuSap = (PjKwuSapCb *)cb;
+         tmr = &kwuSap->bndTmr;
+         arg.max = PJ_MAX_KWUSAP_TMR;
+         break;
+      }
+      case PJ_EVT_WAIT_UDX_BNDCFM:
+      {
+         udxSap = (PjUdxUlSapCb *)cb;
+         tmr = &udxSap->bndTmr;
+         arg.max = PJ_MAX_UDXSAP_TMR;
+         break;
+      }
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+      case PJ_EVT_DL_OBD_TMR:
+      {
+         pjDlRbCb = (PjDlRbCb *)cb;
+         tmr = &(pjDlRbCb->dlCb.obdTmr);
+         maxTimers = PJ_MAX_OBD_TMR;
+         break;
+      }
+      case PJ_EVT_UL_OBD_TMR:
+      {
+         pjUlRbCb = (PjUlRbCb *)cb;
+         tmr = &(pjUlRbCb->ulCb.obdTmr);
+         maxTimers = PJ_MAX_OBD_TMR;
+         break;
+      }
+      case PJ_EVT_OBD_WAIT_TMR:
+      {
+         /*if (gCb->pjGenCfg.mode == LPJ_PDCP_MODE_DL)*/
+         if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_DL)
+         {
+            dlUeCb = (PjDlUeCb *)cb;
+            tmr  = &(dlUeCb->libInfo.obdTmr);
+         }
+         else
+         {
+            ulUeCb = (PjUlUeCb *)cb;
+            tmr  = &(ulUeCb->libInfo.obdTmr);
+         }
+         maxTimers = PJ_MAX_OBD_TMR;
+         break;
+      }
+
+#endif
+     /* kw005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS_COMMENT
+      case PJ_EVT_L2_TMR:
+      {
+         measEvtCb = (PjL2MeasEvtCb *)cb;
+         tmr  = &(measEvtCb->l2Tmr);
+         maxTimers = PJ_L2_MAX_TIMERS;
+         break;
+      }
+#endif
+#ifdef LTE_L2_MEAS
+      case PJ_EVT_L2_MEAS_TMR:
+      {
+         tPjMeasCb = (PjCb      *)cb;
+         pjL2Cb = &tPjMeasCb->u.ulCb->pjL2Cb;
+         tmr  = &(pjL2Cb->measTmr);
+         maxTimers = PJ_L2_MAX_TIMERS;
+         break;
+      }
+#endif
+     case PJ_EVT_UL_REORD_TMR:
+      {
+         pjUlRbCb = (PjUlRbCb *)cb;
+         tmr=&(pjUlRbCb->ulCb.tReordTmr);
+         maxTimers = PJ_MAX_UL_REORD_TMRS;
+         break;
+      }
+      default:
+      {
+         RLOG0(L_ERROR, "Invalid Stop tmr Evnt");
+         RETVALUE(RFAILED);
+      }
+   }
+   
+   
+   if (tmrEvnt != TMR0)
+   {
+      arg.tqCp    = &gCb->pjTqCp;
+      arg.tq      = gCb->pjTq;
+      arg.cb      = (PTR)cb;
+      arg.timers  = tmr;
+      arg.evnt    = tmrEvnt;
+      arg.wait    = 0;
+      arg.max     = maxTimers;
+      arg.tNum    = 0;
+      cmRmvCbTq(&arg);
+
+   }
+   
+   RETVALUE(ROK);
+}
+
+/**
+ *
+ * @brief Handler to invoke events on expiry of timer.
+ *       
+ *
+ * @b Description
+ *        This function is used to handle expiry of timer,it invokes relevant functions.
+ *
+ *
+ *  @param[in] cb        Transmission Buffer control block 
+ *  @param[in] tmrType   Type of the timer to be stopped
+ *
+ * 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+*/
+#ifdef ANSI
+PUBLIC S16 pjTmrExpiry
+(
+PTR       cb,           /* Parent control block */
+S16       tmrEvnt       /* Timer event */
+)
+#else
+PUBLIC S16 pjTmrExpiry (cb, tmrEvnt)
+PTR       cb;           /* Parent control block */
+S16       tmrEvnt;      /* Timer event */
+#endif
+{
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+   PjDlRbCb      *dlRbCb        = NULLP;
+   PjDlUeCb      *dlUeCb          = NULLP;
+   PjUlUeCb      *ulUeCb          = NULLP;
+#endif 
+   PjUlRbCb      *ulRbCb        = NULLP; 
+#ifdef LTE_L2_MEAS
+   PjL2Cb *pjL2Cb = NULLP;
+   PjCb   *tPjMeasCb = NULLP;
+#endif
+   /* pj005.201 added support for L2 Measurement */
+   TRC2(pjTmrExpiry)
+
+  switch (tmrEvnt)
+   {
+      case PJ_EVT_WAIT_KWU_BNDCFM:
+      {
+         pjBndTmrExpiry(tmrEvnt,cb);
+         /* kw005.201 added missing break statement */
+         break;
+      }
+      case PJ_EVT_WAIT_UDX_BNDCFM:
+      {
+         pjBndTmrExpiry(tmrEvnt,cb);
+         /* kw005.201 added missing break statement */
+         break;
+      }
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+      case PJ_EVT_DL_OBD_TMR:
+      {
+         PjCb *tPjCb;
+         dlRbCb = (PjDlRbCb *)cb;
+
+         if (dlRbCb->ueCb->inst >= PJ_MAX_PDCP_INSTANCES)
+         {
+            RETVALUE(RFAILED);
+         }
+         tPjCb = PJ_GET_PJCB(dlRbCb->ueCb->inst);
+
+         pjDlmObdTmrExp(tPjCb,dlRbCb);
+         break;
+      }
+      case PJ_EVT_UL_OBD_TMR:
+      {
+         PjCb *tPjCb;
+         ulRbCb = (PjUlRbCb *)cb;
+
+         if (ulRbCb->ueCb->inst >= PJ_MAX_PDCP_INSTANCES)
+         {
+            RETVALUE(RFAILED);
+         }
+         tPjCb = PJ_GET_PJCB(ulRbCb->ueCb->inst);
+          pjUlmHdlObdTmrExpiry(tPjCb,ulRbCb);
+         break;
+      }
+      case PJ_EVT_OBD_WAIT_TMR:
+      {
+         PjCb *tPjCb;
+         tPjCb = (PjCb*)cb;
+         if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+         {
+            ulUeCb = (PjUlUeCb *)cb;
+            if (ulUeCb->inst >= PJ_MAX_PDCP_INSTANCES)
+            {
+                RETVALUE(RFAILED);
+            }
+            tPjCb = PJ_GET_PJCB(ulUeCb->inst);
+            pjUtlUlHdlInitObdTmrExp(tPjCb,ulUeCb);
+            
+         }
+         else
+         {
+             dlUeCb = (PjDlUeCb *)cb;
+             if (dlUeCb->inst >= PJ_MAX_PDCP_INSTANCES)
+             {
+                 RETVALUE(RFAILED);
+             }
+             tPjCb = PJ_GET_PJCB(dlUeCb->inst);
+             pjUtlDlHdlInitObdTmrExp(tPjCb,dlUeCb);
+         }
+         break;
+      }
+
+#endif
+#ifdef LTE_L2_MEAS
+      case PJ_EVT_L2_MEAS_TMR:
+      {
+         tPjMeasCb = (PjCb      *)cb;
+         pjL2Cb = &tPjMeasCb->u.ulCb->pjL2Cb;
+         pjUtlMemCpuHdlTmrExp((PjCb *)cb,pjL2Cb);
+      }
+      break;
+#endif
+     case PJ_EVT_UL_REORD_TMR:
+      {
+         PjCb *tPjCb;
+         ulRbCb = (PjUlRbCb *)cb;
+         if (ulRbCb->ueCb->inst >= PJ_MAX_PDCP_INSTANCES)
+         {
+            RETVALUE(RFAILED);
+         }
+         tPjCb = PJ_GET_PJCB(ulRbCb->ueCb->inst);
+         pjUlmHdlReordTmrExpiry(tPjCb, ulRbCb);
+         break;
+      }
+      /* pj005.201 added support for L2 Measurement */
+      default:
+      {
+         RETVALUE(RFAILED);
+      }
+   }
+
+   RETVALUE(ROK);
+}
+
+/**
+ *
+ * @brief Handler to check if the timer is running
+ *       
+ *
+ * @b Description
+ *        This function is used to check if the timer is running at the given
+ *        moment.
+ *
+ *
+ *  @param[in] cb      Transmission Buffer control block 
+ *  @param[in] tmrType   Type of the timer to be stopped 
+ *
+ * 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ */
+#ifdef ANSI
+PUBLIC Bool pjChkTmr
+(
+PjCb      *gCb,
+PTR       cb,           /* Parent control block */
+S16       tmrEvnt       /* Timer event */
+)
+#else
+PUBLIC Bool pjChkTmr(gCb, cb, tmrEvnt) 
+PjCb      *gCb;
+PTR       cb;           /* Parent control block */
+S16       tmrEvnt;      /* Timer event */
+#endif
+{
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+   PjDlUeCb  *dlUeCb         = NULLP;
+   PjUlUeCb  *ulUeCb         = NULLP;
+#endif
+#ifdef LTE_L2_MEAS
+   PjL2Cb *pjL2Cb = NULLP;
+   PjCb   *tPjMeasCb = NULLP;
+#endif
+   Bool tmrRunning = FALSE;
+   PjUlRbCb  *ulRbCb         = NULLP;
+
+   TRC2(pjChkTmr)
+
+   RLOG1(L_UNUSED, "pjChkTmr(cb, tmrEvnt(%d)) ", tmrEvnt);
+
+   switch (tmrEvnt)
+   {
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+      case PJ_EVT_DL_OBD_TMR:
+      {
+         dlRbCb = (PjDlRbCb *)cb;
+         if (dlRbCb->dlCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR)
+         {
+            tmrRunning = TRUE;
+         }
+         break;
+      }
+      case PJ_EVT_UL_OBD_TMR:
+      {
+          ulRbCb = (PjUlRbCb *)cb;
+          if (ulRbCb->ulCb.obdTmr.tmrEvnt == PJ_EVT_UL_OBD_TMR)
+          {
+              tmrRunning = TRUE;
+          }
+          break;
+      }
+      case PJ_EVT_OBD_WAIT_TMR:
+      {
+          if(gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+          {
+              ulUeCb = (PjUlUeCb *)cb;
+              if (ulUeCb->inst >= PJ_MAX_PDCP_INSTANCES)
+              {
+                  RETVALUE(RFAILED);
+              }
+              if (ulUeCb->libInfo.obdTmr.tmrEvnt == PJ_EVT_OBD_WAIT_TMR)
+              {
+                  tmrRunning = TRUE;
+              }
+          }
+          else
+          {
+              dlUeCb = (PjDlUeCb *)cb;
+              if (dlUeCb->inst >= PJ_MAX_PDCP_INSTANCES)
+              {
+                  RETVALUE(RFAILED);
+              }
+              if (dlUeCb->libInfo.obdTmr.tmrEvnt == PJ_EVT_OBD_WAIT_TMR)
+              {
+                  tmrRunning =  TRUE;
+              }
+          }
+          break;
+      }
+#endif
+#ifdef LTE_L2_MEAS
+      case PJ_EVT_L2_MEAS_TMR:
+      {
+         tPjMeasCb = (PjCb      *)cb;
+         pjL2Cb = &tPjMeasCb->u.ulCb->pjL2Cb;
+         if (pjL2Cb->measTmr.tmrEvnt == PJ_EVT_L2_MEAS_TMR)
+         {
+             tmrRunning = TRUE;
+         }
+         break;
+      }
+#endif
+      case PJ_EVT_UL_REORD_TMR:
+      {
+         ulRbCb = (PjUlRbCb *)cb;
+         if(PJ_EVT_UL_REORD_TMR == ulRbCb->ulCb.tReordTmr.tmrEvnt)
+         {
+             tmrRunning = TRUE;
+         }
+         break;
+      }
+      default:
+      {
+
+          RLOG0(L_ERROR, "Invalid Chk tmr Evnt");
+          RETVALUE(RFAILED);
+      }
+   } 
+
+   RETVALUE(tmrRunning);
+}
+/**
+ *
+ * @brief Private handler to invoke an event for bind timer expiry
+ *       
+ *
+ * @b Description
+ *        This function processes the RLC bind timer expiry. If the number of retry is
+ *        less than the maximum retry counter, bind request is sent again, else an 
+ *        alarm is raised to the layer manager.
+ *
+ *
+ *  @param[in] cb      RB control block 
+ *
+ * 
+ *   @return Void
+ *      -# RETVOID
+*/
+#ifdef ANSI
+PRIVATE Void pjBndTmrExpiry
+(
+S16       tmrEvnt,
+PTR       cb            /* Parent control block */
+)
+#else
+PRIVATE Void pjBndTmrExpiry(tmrEvnt, cb) 
+S16       tmrEvnt;
+PTR       cb;           /* Parent control block */
+#endif
+{
+   PjCb          *tPjCb;
+   PjUdxUlSapCb  *udxSap;
+   PjKwuSapCb *kwuSapCb; 
+
+   TRC2(pjBndTmrExpiry)
+
+   if (tmrEvnt == PJ_EVT_WAIT_KWU_BNDCFM)
+   {
+      kwuSapCb = (PjKwuSapCb *) cb;
+
+      tPjCb = PJ_GET_PJCB(kwuSapCb->pst.srcInst);
+      if (kwuSapCb->state == PJ_SAP_BINDING)
+      {
+         if (kwuSapCb->retryCnt < PJ_MAX_SAP_BND_RETRY)
+         {
+            /* Send bind request */
+            kwuSapCb->retryCnt++;
+
+            /* start timer to wait for bind confirm */
+            pjStartTmr(tPjCb, (PTR)kwuSapCb, PJ_EVT_WAIT_KWU_BNDCFM);
+
+            PjLiKwuBndReq (&kwuSapCb->pst, kwuSapCb->suId, kwuSapCb->spId);
+         }
+         else
+         {
+            kwuSapCb->retryCnt = 0;
+            kwuSapCb->state = PJ_SAP_CFG;
+
+            /* Send alarm to the layer manager */
+#ifdef LTE_L2_MEAS
+            pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
+                           LCM_CAUSE_TMR_EXPIRED, 0, 0, 0);
+#else
+            pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
+                           LCM_CAUSE_TMR_EXPIRED, 0, 0);
+#endif
+         }
+      }
+   }
+   else
+   {
+      udxSap = (PjUdxUlSapCb *)cb;
+
+      tPjCb  = PJ_GET_PJCB (udxSap->pst.srcInst);
+
+      if (udxSap->state == PJ_SAP_BINDING)
+      {
+         if (udxSap->retryCnt < PJ_MAX_SAP_BND_RETRY)
+         {
+            /* Send bind request */
+            udxSap->retryCnt++;
+
+            /* start timer to wait for bind confirm */
+            pjStartTmr(tPjCb, (PTR)udxSap, PJ_EVT_WAIT_UDX_BNDCFM);
+
+            PjUlUdxBndReq (&udxSap->pst, udxSap->suId, udxSap->spId);
+         }
+         else
+         {
+            udxSap->retryCnt = 0;
+            udxSap->state = PJ_SAP_CFG;
+
+            /* Send alarm to the layer manager */
+#ifdef LTE_L2_MEAS
+            pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
+                           LCM_CAUSE_TMR_EXPIRED, 0, 0, 0);
+#else
+            pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
+                           LCM_CAUSE_TMR_EXPIRED, 0, 0);
+#endif
+         }
+      }
+
+   }
+
+   RETVOID;
+}
+
+
+\f  
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_udx.c b/src/5gnrpdcp/pj_udx.c
new file mode 100755 (executable)
index 0000000..6bffe08
--- /dev/null
@@ -0,0 +1,6225 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE PDCP Interface  
+    
+        Type:    C file
+  
+        Desc:    This file contains the pack/unpack functions for the
+                 data structures at UDX Interface.
+        File:    pj_udx.c
+  
+*********************************************************************21*/
+#if(defined(LCUDX) || defined(LWLCUDX)) 
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=224;
+#endif
+
+/* header include files (.h) */
+  
+#include "envopt.h"             /* Environment options */  
+#include "envdep.h"             /* Environment dependent */
+#include "envind.h"             /* Environment independent */
+#include "gen.h"                /* General */
+#include "ssi.h"                /* System services interface */
+#include "cm_lte.h"             /* Common LTE header file */
+#include "cm_llist.h"           /* Linked List header file */
+#include "cm_tkns.h"            /* Common tokens header file */
+#include "cm_hash.h"            /* Hash List header file */
+#include "cpj.h"                /* CPJ Interface header file */
+#include "lpj.h"
+#include "pj_udx.h"
+
+
+
+/* header/extern include files (.x) */
+
+#include "gen.x"                /* General */
+#include "ssi.x"                /* System services interface */
+#include "cm_lib.x"             /* Common lib header file */
+#include "cm_hash.x"            /* Hash List header file */
+#include "cm_llist.x"           /* Linked List header file */
+#include "cm_tkns.x"            /* Common tokens header file */
+#include "cm_lte.x"             /* Common LTE header file */
+#include "cpj.x"                /* CPJ Interface header file */
+#include "pj.h"
+#include "lpj.x"
+#include "pj_udx.x"
+
+#if(defined(LCUDX) || defined(LWLCUDX)) 
+/* Packing/Unpacking Macros */
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxBndReq
+(
+Pst * pst,
+SuId suId,
+SpId spId
+)
+#else
+PUBLIC S16 cmPkPjUdxBndReq(pst, suId, spId)
+Pst * pst;
+SuId suId;
+SpId spId;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkPjUdxBndReq)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX001, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (SPkS16(spId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX002, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (SPkS16(suId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX003, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) EVTUDXBNDREQ;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxBndReq
+(
+UdxBndReq func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxBndReq(func, pst, mBuf)
+UdxBndReq func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   SuId suId;
+   SpId spId;
+   
+   TRC3(cmUnpkPjUdxBndReq)
+
+   if (SUnpkS16(&suId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX004, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (SUnpkS16(&spId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX005, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, suId, spId));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxBndCfm
+(
+Pst * pst,
+SuId suId,
+U8 status
+)
+#else
+PUBLIC S16 cmPkPjUdxBndCfm(pst, suId, status)
+Pst * pst;
+SuId suId;
+U8 status;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkPjUdxBndCfm)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ006, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (SPkU8(status, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ007, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (SPkS16(suId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ008, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) EVTCPJBNDCFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxBndCfm
+(
+UdxBndCfm func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxBndCfm(func, pst, mBuf)
+UdxBndCfm func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   SuId suId;
+   U8 status;
+   
+   TRC3(cmUnpkPjUdxBndCfm)
+
+   if (SUnpkS16(&suId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ009, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (SUnpkU8(&status, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ010, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, suId, status));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxUbndReq
+(
+Pst * pst,
+SpId spId,
+Reason reason
+)
+#else
+PUBLIC S16 cmPkPjUdxUbndReq(pst, spId, reason)
+Pst * pst;
+SpId spId;
+Reason reason;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkPjUdxUbndReq)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX011, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+
+   if (SPkS16(reason, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX012, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (SPkS16(spId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX013, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) EVTUDXUBNDREQ;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxUbndReq
+(
+UdxUbndReq func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxUbndReq(func, pst, mBuf)
+UdxUbndReq func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   SpId spId;
+   Reason reason;
+   
+   TRC3(cmUnpkPjUdxUbndReq)
+
+   if (SUnpkS16(&spId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX014, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (SUnpkS16(&reason, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX015, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, spId, reason));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxCfgReq
+(
+Pst * pst,
+SpId spId,
+UdxCfgReqInfo * cfgReq
+)
+#else
+PUBLIC S16 cmPkPjUdxCfgReq(pst, spId, cfgReq)
+Pst * pst;
+SpId spId;
+UdxCfgReqInfo * cfgReq;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkPjUdxCfgReq)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX016, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgReq, sizeof(UdxCfgReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+      case UDX_SEL_LC:
+         {
+
+            if (cmPkPjUdxCfgReqInfo(pst, cfgReq, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                     (ErrVal)EUDX017, (ErrVal)0, "Packing failed");
+#endif
+               PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgReq, sizeof(UdxCfgReqInfo));
+               PJ_FREE_BUF(mBuf);
+               RETVALUE(RFAILED);
+            }
+
+            /* Free Request Structure after packing */
+            PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgReq, sizeof(UdxCfgReqInfo));
+
+
+            break;
+         }
+      case UDX_SEL_LWLC:
+         {
+            CMCHKPKLOG(cmPkPtr,(PTR)cfgReq,mBuf,EUDXXXX,pst);
+            break;
+         }
+#endif /* LCUDX */
+   }
+
+    if (SPkS16(spId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX019, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgReq, sizeof(UdxCfgReqInfo));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   pst->event = (Event) EVTUDXCFGREQ;
+
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxUlStaRep
+(
+Pst * pst,
+SpId spId,
+UdxUlStaRepInfo *staRep
+)
+#else
+PUBLIC S16 cmPkPjUdxUlStaRep(pst, spId, staRep)
+Pst * pst;
+SpId spId;
+UdxUlStaRepInfo *staRep;
+#endif
+{
+   S16 ret;
+   Buffer *mBuf;
+   mBuf = NULLP;
+
+   TRC3(cmPkPjUdxUlStaRep)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX016, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxUlStaRepInfo));
+
+      RETVALUE(RFAILED);
+   }
+
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+      case UDX_SEL_LC:
+         {
+            ret = cmPkPjUdxUlStaRepInfo( (staRep), pst, mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+            if(ret != ROK)
+            {
+               PJ_FREE_BUF(mBuf);
+               PJ_FREE_BUF(staRep->sta);
+               PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, (Data *)staRep, sizeof(UdxUlStaRepInfo), 0);
+               
+               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                     (ErrVal)EUDXXXX, (ErrVal)ret, "Packing failure");
+               RETVALUE( ret );
+            }
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+            PJ_FREE_BUF(staRep->sta);
+#ifndef XEON_SPECIFIC_CHANGES
+            if (SPutStaticBuffer(pst->region, pst->pool, (Data *)staRep,
+                     sizeof(UdxUlStaRepInfo), 0) != ROK)
+#else
+            if (SPutSBuf(pst->region, pst->pool, (Data *)staRep,
+                     sizeof(UdxUlStaRepInfo)) != ROK)
+#endif
+            {
+               PJ_FREE_BUF(mBuf);
+               RETVALUE(RFAILED);
+            }
+
+            break;
+         }
+       case UDX_SEL_LWLC:
+         {
+            CMCHKPKLOG(cmPkPtr,(PTR)staRep,mBuf,EUDXXXX,pst);
+            break;
+         }
+#endif /* LCUDX */
+   }
+   
+   CMCHKPKLOG(SPkS16, spId, mBuf, EUDXXXX, pst);
+   pst->event = (Event) EVTUDXULSTAREP;
+
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxDlStaRep
+(
+Pst * pst,
+SpId spId,
+UdxDlStaRepInfo *staRep
+)
+#else
+PUBLIC S16 cmPkPjUdxDlStaRep(pst, spId, staRep)
+Pst * pst;
+SpId spId;
+UdxDlStaRepInfo *staRep;
+#endif
+{
+   S16 ret;
+   Buffer *mBuf;
+   mBuf = NULLP;
+
+   TRC3(cmPkPjUdxDlStaRep)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
+   {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX016, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(staRep->staPdu);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo));
+
+      RETVALUE(RFAILED);
+   }
+
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+      case UDX_SEL_LC:
+         {
+            ret = cmPkPjUdxDlStaRepInfo( (staRep), pst, mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+            if(ret != ROK)
+            {
+               PJ_FREE_BUF(mBuf);
+               PJ_FREE_BUF(staRep->staPdu);
+               PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo));
+               
+               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                     (ErrVal)EUDXXXX, (ErrVal)ret, "Packing failure");
+               RETVALUE( ret );
+            }
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+            PJ_FREE_BUF(staRep->staPdu);
+#ifndef XEON_SPECIFIC_CHANGES
+            if (SPutStaticBuffer(pst->region, pst->pool, (Data *)staRep,
+                     sizeof(UdxDlStaRepInfo), 0) != ROK)
+#else
+            if (SPutSBuf(pst->region, pst->pool, (Data *)staRep,
+                     sizeof(UdxDlStaRepInfo)) != ROK)
+#endif
+            {
+               PJ_FREE_BUF(mBuf);
+               RETVALUE(RFAILED);
+            }
+
+            break;
+         }
+       case UDX_SEL_LWLC:
+         {
+            CMCHKPKLOG(cmPkPtr,(PTR)staRep,mBuf,EUDXXXX,pst);
+            break;
+         }
+#endif /* LCUDX */
+   }
+   
+   CMCHKPKLOG(SPkS16, spId, mBuf, EUDXXXX, pst);
+   pst->event = (Event) EVTUDXDLSTAREP;
+
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxCfgReq
+(
+UdxCfgReq func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxCfgReq(func, pst, mBuf)
+UdxCfgReq func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   S16   ret1;
+   SpId spId;
+   UdxCfgReqInfo *cfgReq;
+   
+   TRC3(cmUnpkPjUdxCfgReq)
+   if (SUnpkS16(&spId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX021, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+      case UDX_SEL_LC:
+         {
+
+            if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&cfgReq,\
+                        sizeof(UdxCfgReqInfo))) != ROK)
+            {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                     (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+               RETVALUE(ret1);
+            }
+
+            if (cmUnpkPjUdxCfgReqInfo(pst, cfgReq, mBuf) != ROK) {
+               PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgReq, sizeof(UdxCfgReqInfo);
+               PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                     (ErrVal)EUDX023, (ErrVal)0, "Packing failed");
+#endif
+               RETVALUE(RFAILED);
+            }
+            break;
+         }
+      case UDX_SEL_LWLC:
+         {
+            CMCHKUNPK(cmUnpkPtr,(PTR *) &cfgReq, mBuf);
+            break;
+         }
+#endif /* LCUDX */
+   }
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, spId, cfgReq));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxCfgCfm
+(
+ Pst * pst,
+ SuId suId,
+ UdxCfgCfmInfo * cfgCfm
+ )
+#else
+PUBLIC S16 cmPkPjUdxCfgCfm(pst, suId, cfgCfm)
+        Pst * pst;
+        SuId suId;
+        UdxCfgCfmInfo * cfgCfm;
+#endif
+{
+        Buffer *mBuf = NULLP;
+        TRC3(cmPkPjUdxCfgCfm)
+
+                if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                        (ErrVal)ECPJ024, (ErrVal)0, "Packing failed");
+#endif
+                        PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgCfm, sizeof(UdxCfgCfmInfo));
+                        RETVALUE(RFAILED);
+                }
+        switch(pst->selector)
+        {
+#ifdef LCUDX
+           case UDX_SEL_LC:
+              {
+
+                 if (cmPkPjUdxCfgCfmInfo(cfgCfm, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                    SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                          (ErrVal)ECPJ025, (ErrVal)0, "Packing failed");
+#endif
+                    PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgCfm, sizeof(UdxCfgCfmInfo));
+                    PJ_FREE_BUF(mBuf);
+                    RETVALUE(RFAILED);
+                 }
+                 /* cpj_c_001.main_3 */
+                 /* Free Confirm Structure after packing */
+                 PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgCfm, sizeof(UdxCfgCfmInfo));
+
+
+                 break;
+              }
+           case UDX_SEL_LWLC:
+              {
+                 CMCHKPKLOG(cmPkPtr,(PTR)cfgCfm,mBuf,EUDXXXX,pst);
+                 break;
+              }
+#endif /* LCUDX */
+
+        }
+
+        if (SPkS16(suId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                (ErrVal)ECPJ027, (ErrVal)0, "Packing failed");
+#endif
+                PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgCfm, sizeof(UdxCfgCfmInfo));
+                PJ_FREE_BUF(mBuf);
+                RETVALUE(RFAILED);
+        }
+        pst->event = (Event) EVTCPJCFGCFM;
+        RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxCfgCfm
+(
+ UdxCfgCfm func,
+ Pst *pst,
+ Buffer *mBuf
+ )
+#else
+PUBLIC S16 cmUnpkPjUdxCfgCfm(func, pst, mBuf)
+        UdxCfgCfm func;
+        Pst *pst;
+        Buffer *mBuf;
+#endif
+{
+        S16   ret1;
+        SuId suId;
+        UdxCfgCfmInfo *cfgCfm;
+
+        TRC3(cmUnpkPjUdxCfgCfm)
+        if (SUnpkS16(&suId, mBuf) != ROK) {
+                   PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                        (ErrVal)ECPJ029, (ErrVal)0, "Packing failed");
+#endif
+                        RETVALUE(RFAILED);
+                }
+        switch(pst->selector)
+        {
+#ifdef LCUDX
+                case UDX_SEL_LC:
+                        {
+
+
+                                if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&cfgCfm,\
+                                                                sizeof(UdxCfgCfmInfo))) != ROK)
+                                {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                        (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+                                        RETVALUE(ret1);
+                                }
+
+                                if (cmUnpkPjUdxCfgCfmInfo(cfgCfm, mBuf) != ROK) {
+                                        PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgCfm, sizeof(UdxCfgCfmInfo));
+                                        PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                        (ErrVal)ECPJ031, (ErrVal)0, "Packing failed");
+#endif
+                                        RETVALUE(RFAILED);
+                                }
+                                break;
+                        }
+                case UDX_SEL_LWLC:
+                        {
+                                CMCHKUNPK(cmUnpkPtr,(PTR *) &cfgCfm, mBuf);
+                                break;
+                        }
+#endif /* LCUDX */
+        }
+        PJ_FREE_BUF(mBuf);
+        RETVALUE((*func)(pst, suId, cfgCfm));
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxReEstReq
+(
+Pst * pst,
+SpId spId,
+UdxReEstReqInfo * reEstReq
+)
+#else
+PUBLIC S16 cmPkPjUdxReEstReq(pst, spId, reEstReq)
+Pst * pst;
+SpId spId;
+UdxReEstReqInfo * reEstReq;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkPjUdxReEstReq)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
+   {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX032, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo));
+      RETVALUE(RFAILED);
+   }
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+           case UDX_SEL_LC:
+                   { 
+                           if (cmPkPjUdxReEstReqInfo(reEstReq, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                   (ErrVal)EUDX033, (ErrVal)0, "Packing failed");
+#endif
+                                   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo));
+                                   PJ_FREE_BUF(mBuf);
+                                   RETVALUE(RFAILED);
+                           }
+                           /* Free Request Structure after packing */
+                           PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo));
+
+                           break;
+                   }
+           case UDX_SEL_LWLC:
+                   {
+                           CMCHKPKLOG(cmPkPtr,(PTR)reEstReq,mBuf,EUDXXXX,pst);
+                           break;
+                   }
+#endif /* LCUDX */
+   }
+
+   if (SPkS16(spId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX035, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+
+   pst->event = (Event) EVTUDXREESTREQ;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxReEstReq
+(
+UdxReEstReq func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxReEstReq(func, pst, mBuf)
+UdxReEstReq func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   S16   ret1;
+   SpId spId;
+   UdxReEstReqInfo *reEstReq;
+   
+   TRC3(cmUnpkPjUdxReEstReq)
+
+   if (SUnpkS16(&spId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX037, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+           case UDX_SEL_LC:
+                   { 
+
+                           if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&reEstReq,\
+                                                           sizeof(UdxReEstReqInfo))) != ROK)
+                           {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                   (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+                                   RETVALUE(ret1);
+                           }
+
+                           if (cmUnpkPjUdxReEstReqInfo(reEstReq, mBuf) != ROK) {
+                                   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo));
+                                   PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                   (ErrVal)EUDX039, (ErrVal)0, "Packing failed");
+#endif
+                                   RETVALUE(RFAILED);
+                           }
+                           break;
+                   }
+           case UDX_SEL_LWLC:
+                   {
+                           CMCHKUNPK(cmUnpkPtr,(PTR *) &reEstReq, mBuf);
+                           break;
+                   }
+#endif /* LCUDX */
+}
+
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, spId, reEstReq));
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxReEstCfm
+(
+ Pst * pst,
+ SuId suId,
+ UdxReEstCfmInfo * reEstCfm
+ )
+#else
+PUBLIC S16 cmPkPjUdxReEstCfm(pst, suId, reEstCfm)
+        Pst * pst;
+        SuId suId;
+        UdxReEstCfmInfo * reEstCfm;
+#endif
+{
+        Buffer *mBuf = NULLP;
+        TRC3(cmPkPjUdxReEstCfm)
+
+                if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                        (ErrVal)ECPJ040, (ErrVal)0, "Packing failed");
+#endif
+                        PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstCfm, sizeof(UdxReEstCfmInfo));
+                        RETVALUE(RFAILED);
+                }
+        switch(pst->selector)
+        {
+#ifdef LCUDX
+                case UDX_SEL_LC:
+                        { 
+
+                                if (cmPkPjUdxReEstCfmInfo(reEstCfm, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                        (ErrVal)ECPJ041, (ErrVal)0, "Packing failed");
+#endif
+                                        PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstCfm, sizeof(UdxReEstCfmInfo));
+                                        PJ_FREE_BUF(mBuf);
+                                        RETVALUE(RFAILED);
+                                }
+
+                                /* Free Confirm Structure after packing */
+                                PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstCfm, sizeof(UdxReEstCfmInfo));
+                                break;
+                        }
+                case UDX_SEL_LWLC:
+                        {
+                                CMCHKPKLOG(cmPkPtr,(PTR)reEstCfm,mBuf,EUDXXXX,pst);
+                                break;
+                        }
+#endif /* LCUDX */
+        }
+        if (SPkS16(suId, mBuf) != ROK)
+        {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                (ErrVal)ECPJ043, (ErrVal)0, "Packing failed");
+#endif
+                PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstCfm, sizeof(UdxReEstCfmInfo));
+                PJ_FREE_BUF(mBuf);
+                RETVALUE(RFAILED);
+        }
+
+
+        pst->event = (Event) EVTCPJREESTCFM;
+        RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxReEstCfm
+(
+ UdxReEstCfm func,
+ Pst *pst,
+ Buffer *mBuf
+ )
+#else
+PUBLIC S16 cmUnpkPjUdxReEstCfm(func, pst, mBuf)
+        UdxReEstCfm func;
+        Pst *pst;
+        Buffer *mBuf;
+#endif
+{
+        S16   ret1;
+        SuId suId;
+        UdxReEstCfmInfo *reEstCfm;
+
+        TRC3(cmUnpkPjUdxReEstCfm)
+
+                if (SUnpkS16(&suId, mBuf) != ROK) {
+                   PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                        (ErrVal)ECPJ045, (ErrVal)0, "Packing failed");
+#endif
+                        RETVALUE(RFAILED);
+                }
+        switch(pst->selector)
+        {
+#ifdef LCUDX
+                case UDX_SEL_LC:
+                        { 
+
+
+                                if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&reEstCfm,\
+                                                                sizeof(UdxReEstCfmInfo))) != ROK)
+                                {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                        (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+                                        RETVALUE(ret1);
+                                }
+
+                                if (cmUnpkPjUdxReEstCfmInfo(reEstCfm, mBuf) != ROK) {
+                                        PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstCfm, sizeof(UdxReEstCfmInfo));
+                                        PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                        (ErrVal)ECPJ047, (ErrVal)0, "Packing failed");
+#endif
+                                        RETVALUE(RFAILED);
+                                }
+                                break;
+                        }
+                case UDX_SEL_LWLC:
+                        {
+                                CMCHKUNPK(cmUnpkPtr,(PTR *) &reEstCfm, mBuf);
+                                break;
+                        }
+#endif /* LCUDX */
+        }
+
+        PJ_FREE_BUF(mBuf);
+        RETVALUE((*func)(pst, suId, reEstCfm));
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxSecCfgReq
+(
+Pst * pst,
+SpId spId,
+UdxSecCfgReqInfo * secCfgReq
+)
+#else
+PUBLIC S16 cmPkPjUdxSecCfgReq(pst, spId, secCfgReq)
+Pst * pst;
+SpId spId;
+UdxSecCfgReqInfo * secCfgReq;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkPjUdxSecCfgReq)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX048, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgReq, sizeof(UdxSecCfgReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+           case UDX_SEL_LC:
+                   {
+
+                           if (cmPkPjUdxSecCfgReqInfo(secCfgReq, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                   (ErrVal)EUDX049, (ErrVal)0, "Packing failed");
+#endif
+                                   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgReq, sizeof(UdxSecCfgReqInfo));
+                                   PJ_FREE_BUF(mBuf);
+                                   RETVALUE(RFAILED);
+                           }  
+                           /* Free Request Structure after packing */
+                           PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgReq, sizeof(UdxSecCfgReqInfo));
+                           break;
+
+                   }
+           case UDX_SEL_LWLC:
+                   {
+                           CMCHKPKLOG(cmPkPtr,(PTR)secCfgReq,mBuf,EUDXXXX,pst);
+                           break;
+                   }
+#endif /* LCUDX */
+   }
+
+   if (SPkS16(spId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX051, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgReq, sizeof(UdxSecCfgReqInfo));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+
+    pst->event = (Event) EVTUDXSECCFGREQ;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxSecCfgReq
+(
+UdxSecCfgReq func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxSecCfgReq(func, pst, mBuf)
+UdxSecCfgReq func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   S16   ret1;
+   SpId spId;
+   UdxSecCfgReqInfo *secCfgReq;
+   
+   TRC3(cmUnpkPjUdxSecCfgReq)
+
+   if (SUnpkS16(&spId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX053, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+           case UDX_SEL_LC:
+                   {
+
+                           if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&secCfgReq,\
+                                                           sizeof(UdxSecCfgReqInfo))) != ROK)
+                           {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                   (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+                                   RETVALUE(ret1);
+                           }
+
+                           if (cmUnpkPjUdxSecCfgReqInfo(secCfgReq, mBuf) != ROK) {
+                                   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgReq, sizeof(UdxSecCfgReqInfo));
+                                   PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                   (ErrVal)EUDX055, (ErrVal)0, "Packing failed");
+#endif
+                                   RETVALUE(RFAILED);
+                           }
+                           break;
+
+                   }
+           case UDX_SEL_LWLC:
+                   {
+                           CMCHKUNPK(cmUnpkPtr,(PTR *) &secCfgReq,mBuf);
+                           break;
+                   }
+#endif /* LCUDX */
+   }
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, spId, secCfgReq));
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxSecCfgCfm
+(
+ Pst * pst,
+ SuId suId,
+ UdxSecCfgCfmInfo * secCfgCfm
+ )
+#else
+PUBLIC S16 cmPkPjUdxSecCfgCfm(pst, suId, secCfgCfm)
+        Pst * pst;
+        SuId suId;
+        UdxSecCfgCfmInfo * secCfgCfm;
+#endif
+{
+        Buffer *mBuf = NULLP;
+        TRC3(cmPkPjUdxSecCfgCfm)
+
+                if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                        (ErrVal)ECPJ056, (ErrVal)0, "Packing failed");
+#endif
+                        PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgCfm, sizeof(UdxSecCfgCfmInfo));
+                        RETVALUE(RFAILED);
+                }
+        switch(pst->selector)
+        {
+#ifdef LCUDX
+                case UDX_SEL_LC:
+                        {
+
+
+                                if (cmPkPjUdxSecCfgCfmInfo(secCfgCfm, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                        (ErrVal)ECPJ057, (ErrVal)0, "Packing failed");
+#endif
+                                        PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgCfm, sizeof(UdxSecCfgCfmInfo));
+                                        PJ_FREE_BUF(mBuf);
+                                        RETVALUE(RFAILED);
+                                }
+                                /* Free Confirm Structure after packing */
+                                PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgCfm, sizeof(UdxSecCfgCfmInfo));
+
+
+                                break;
+
+                        }
+                case UDX_SEL_LWLC:
+                        {
+                                CMCHKPKLOG(cmPkPtr,(PTR)secCfgCfm,mBuf,EUDXXXX,pst);
+                                break;
+                        }
+#endif /* LCUDX */
+        }
+
+
+
+        if (SPkS16(suId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                (ErrVal)ECPJ059, (ErrVal)0, "Packing failed");
+#endif
+                PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgCfm, sizeof(UdxSecCfgCfmInfo));
+                PJ_FREE_BUF(mBuf);
+                RETVALUE(RFAILED);
+        }
+
+        pst->event = (Event) EVTCPJSECCFGCFM;
+        RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxSecCfgCfm
+(
+ UdxSecCfgCfm func,
+ Pst *pst,
+ Buffer *mBuf
+ )
+#else
+PUBLIC S16 cmUnpkPjUdxSecCfgCfm(func, pst, mBuf)
+        UdxSecCfgCfm func;
+        Pst *pst;
+        Buffer *mBuf;
+#endif
+{
+        S16   ret1;
+        SuId suId;
+        UdxSecCfgCfmInfo *secCfgCfm;
+
+        TRC3(cmUnpkPjUdxSecCfgCfm)
+
+                if (SUnpkS16(&suId, mBuf) != ROK) {
+                   PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                        (ErrVal)ECPJ061, (ErrVal)0, "Packing failed");
+#endif
+                        RETVALUE(RFAILED);
+                }
+        switch(pst->selector)
+        {
+#ifdef LCUDX
+                case UDX_SEL_LC:
+                        {
+
+
+                                if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&secCfgCfm,\
+                                                                sizeof(UdxSecCfgCfmInfo))) != ROK)
+                                {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                        (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+                                        RETVALUE(ret1);
+                                }
+
+                                if (cmUnpkPjUdxSecCfgCfmInfo(secCfgCfm, mBuf) != ROK) {
+                                        PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgCfm, sizeof(UdxSecCfgCfmInfo));
+                                        PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                        (ErrVal)ECPJ063, (ErrVal)0, "Packing failed");
+#endif
+                                        RETVALUE(RFAILED);
+                                }
+                                break;
+
+                        }
+                case UDX_SEL_LWLC:
+                        {
+                                CMCHKUNPK(cmUnpkPtr,(PTR *)&secCfgCfm,mBuf);
+                                break;
+                        }
+#endif /* LCUDX */
+        }
+        PJ_FREE_BUF(mBuf);
+        RETVALUE((*func)(pst, suId, secCfgCfm));
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxUeIdChgReq
+(
+Pst * pst,
+SpId spId,
+U32 transId,
+UdxUeInfo * oldUeInfo,
+UdxUeInfo * newUeInfo
+)
+#else
+PUBLIC S16 cmPkPjUdxUeIdChgReq(pst, spId, transId, oldUeInfo, newUeInfo)
+Pst * pst;
+SpId spId;
+U32 transId;
+UdxUeInfo * oldUeInfo;
+UdxUeInfo * newUeInfo;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkPjUdxUeIdChgReq)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX064, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo));
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo));
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPjUdxUeInfo(newUeInfo, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)EUDX065, (ErrVal)0, "Packing failed");
+#endif
+         PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo));
+         PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo));
+         PJ_FREE_BUF(mBuf);
+         RETVALUE(RFAILED);
+   }
+
+   if (cmPkPjUdxUeInfo(oldUeInfo, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)EUDX067, (ErrVal)0, "Packing failed");
+#endif
+         PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo));
+         PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo));
+         PJ_FREE_BUF(mBuf);
+         RETVALUE(RFAILED);
+   }
+
+   if (SPkU32(transId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX069, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo));
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (SPkS16(spId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX070, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo));
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+
+   /* Free Request Structure after packing */
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo));
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo));
+
+   pst->event = (Event) EVTUDXUEIDCHGREQ;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxUeIdChgReq
+(
+UdxUeIdChgReq func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxUeIdChgReq(func, pst, mBuf)
+UdxUeIdChgReq func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   S16 ret1;
+   SpId spId;
+   U32 transId;
+   UdxUeInfo *oldUeInfo;
+   UdxUeInfo *newUeInfo;
+   
+   TRC3(cmUnpkPjUdxUeIdChgReq)
+
+   if (SUnpkS16(&spId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX073, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (SUnpkU32(&transId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX074, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+
+    if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&oldUeInfo,\
+                sizeof(UdxUeInfo))) != ROK)
+    {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+             __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+             (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+       RETVALUE(ret1);
+    }
+
+   if (cmUnpkPjUdxUeInfo(oldUeInfo, mBuf) != ROK) {
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo));
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX076, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+
+   if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&newUeInfo,\
+               sizeof(UdxUeInfo))) != ROK)
+   {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+      RETVALUE(ret1);
+   }
+
+   if (cmUnpkPjUdxUeInfo(newUeInfo, mBuf) != ROK)
+   {
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo));
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo));
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX078, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, spId, transId, oldUeInfo, newUeInfo));
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxUeIdChgCfm
+(
+Pst * pst,
+SuId suId,
+U32 transId,
+UdxUeInfo  * ueInfo,
+CmStatus status
+)
+#else
+PUBLIC S16 cmPkPjUdxUeIdChgCfm(pst, suId, transId, ueInfo, status)
+Pst * pst;
+SuId suId;
+U32 transId;
+UdxUeInfo  * ueInfo;
+CmStatus status;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkPjUdxUeIdChgCfm)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ079, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo));
+      RETVALUE(RFAILED);
+   }
+   if (cmPkCmStatus(&status, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ080, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (cmPkPjUdxUeInfo(ueInfo, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ECPJ081, (ErrVal)0, "Packing failed");
+#endif
+         PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo));
+         PJ_FREE_BUF(mBuf);
+         RETVALUE(RFAILED);
+   }
+
+   if (SPkU32(transId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ083, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   if (SPkS16(suId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ084, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+
+   /* Free Confirm Structure after packing */
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo));
+
+   pst->event = (Event) EVTCPJUEIDCHGCFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxUeIdChgCfm
+(
+UdxUeIdChgCfm func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxUeIdChgCfm(func, pst, mBuf)
+UdxUeIdChgCfm func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   S16   ret1;
+   SuId suId;
+   U32 transId;
+   UdxUeInfo *ueInfo;
+   CmStatus status;
+   
+   TRC3(cmUnpkPjUdxUeIdChgCfm)
+
+   if (SUnpkS16(&suId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ086, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (SUnpkU32(&transId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ087, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+
+   if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&ueInfo,\
+               sizeof(UdxUeInfo))) != ROK)
+   {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+      RETVALUE(ret1);
+   }
+
+   if (cmUnpkPjUdxUeInfo(ueInfo, mBuf) != ROK) {
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo));
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ089, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   if (cmUnpkCmStatus(&status, mBuf) != ROK) {
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo));
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ090, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, suId, transId, ueInfo, status));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxCountReq
+(
+Pst * pst,
+SpId spId,
+UdxCountReqInfo * countReq
+)
+#else
+PUBLIC S16 cmPkPjUdxCountReq(pst, spId, countReq)
+Pst * pst;
+SpId spId;
+UdxCountReqInfo * countReq;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkPjUdxCountReq)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX091, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+           case UDX_SEL_LC:
+                   {
+
+                           if (cmPkPjUdxCountReqInfo(countReq, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                   (ErrVal)EUDX092, (ErrVal)0, "Packing failed");
+#endif
+                                   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo));
+                                   PJ_FREE_BUF(mBuf);
+                                   RETVALUE(RFAILED);
+                           }
+                           /* Free Request Structure after packing */
+                           PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo));
+                           break;
+                   }
+           case UDX_SEL_LWLC:
+                   {
+                           CMCHKPKLOG(cmPkPtr,(PTR)countReq,mBuf,EUDXXXX,pst);
+                           break;
+                   }
+#endif /* LCUDX */
+   }
+
+   if (SPkS16(spId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX094, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+
+   pst->event = (Event) EVTUDXCOUNTREQ;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxCountReq
+(
+UdxCountReq func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxCountReq(func, pst, mBuf)
+UdxCountReq func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   S16   ret1;
+   SpId spId;
+   UdxCountReqInfo *countReq;
+   
+   TRC3(cmUnpkPjUdxCountReq)
+
+   if (SUnpkS16(&spId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX096, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+           case UDX_SEL_LC:
+                   {
+
+                           if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&countReq,\
+                                                           sizeof(UdxCountReqInfo))) != ROK)
+                           {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                   (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+                                   RETVALUE(ret1);
+                           }
+
+                           if (cmUnpkPjUdxCountReqInfo(countReq, mBuf) != ROK) {
+                                   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo));
+                                   PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                   (ErrVal)EUDX098, (ErrVal)0, "Packing failed");
+#endif
+                                   RETVALUE(RFAILED);
+                           }
+                           break;
+                   }
+           case UDX_SEL_LWLC:
+                   {
+                           CMCHKUNPK(cmUnpkPtr,(PTR *) &countReq,mBuf);
+                           break;
+                   }
+#endif /* LCUDX */
+}
+
+PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, spId, countReq));
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxCountCfm
+(
+Pst * pst,
+SuId suId,
+UdxCountCfmInfo * countCfm
+)
+#else
+PUBLIC S16 cmPkPjUdxCountCfm(pst, suId, countCfm)
+Pst * pst;
+SuId suId;
+UdxCountCfmInfo * countCfm;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkPjUdxCountCfm)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ099, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countCfm, sizeof(UdxCountCfmInfo));
+      RETVALUE(RFAILED);
+   }
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+           case UDX_SEL_LC:
+                   {
+
+   if (cmPkPjUdxCountCfmInfo(countCfm, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ECPJ100, (ErrVal)0, "Packing failed");
+#endif
+         PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countCfm, sizeof(UdxCountCfmInfo));
+         PJ_FREE_BUF(mBuf);
+         RETVALUE(RFAILED);
+    }
+   /* Free Confirm Structure after packing */
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countCfm, sizeof(UdxCountCfmInfo));
+
+   break;
+  }
+  case UDX_SEL_LWLC:
+                   {
+                           CMCHKPKLOG(cmPkPtr,(PTR)countCfm,mBuf,EUDXXXX,pst);
+                           break;
+                   }
+#endif /* LCUDX */
+   }
+
+   if (SPkS16(suId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ102, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countCfm, sizeof(UdxCountCfmInfo));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+
+   pst->event = (Event) EVTCPJCOUNTCFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxCountCfm
+(
+UdxCountCfm func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxCountCfm(func, pst, mBuf)
+UdxCountCfm func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   S16   ret1;
+   SuId suId;
+   UdxCountCfmInfo *countCfm = NULLP;
+   
+   TRC3(cmUnpkPjUdxCountCfm)
+
+   if (SUnpkS16(&suId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ104, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+           case UDX_SEL_LC:
+                   {
+
+
+   if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&countCfm,\
+               sizeof(UdxCountCfmInfo))) != ROK)
+   {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+      RETVALUE(ret1);
+   }
+
+   if (cmUnpkPjUdxCountCfmInfo(countCfm, mBuf) != ROK) {
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countCfm, sizeof(UdxCountCfmInfo));
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)ECPJ106, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+         break;
+                   }
+           case UDX_SEL_LWLC:
+                   {
+                           CMCHKUNPK(cmUnpkPtr,(PTR *) &countCfm,mBuf);
+                           break;
+                   }
+#endif /* LCUDX */
+}
+
+PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, suId, countCfm));
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxSduStaReq
+(
+Pst * pst,
+SpId spId,
+UdxSduStaReqInfo * staReq
+)
+#else
+PUBLIC S16 cmPkPjUdxSduStaReq(pst, spId, staReq)
+Pst * pst;
+SpId spId;
+UdxSduStaReqInfo * staReq;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkPjUdxSduStaReq)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX107, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+           case UDX_SEL_LC:
+                   {
+
+                           if (cmPkPjUdxSduStaReqInfo(staReq, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                   (ErrVal)EUDX108, (ErrVal)0, "Packing failed");
+#endif
+                                   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo));
+                                   PJ_FREE_BUF(mBuf);
+                                   RETVALUE(RFAILED);
+                           }
+                           /* Free Request Structure after packing */
+                           PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo));
+
+
+                           break;
+                   }
+           case UDX_SEL_LWLC:
+                   {
+                           CMCHKPKLOG(cmPkPtr,(PTR)staReq,mBuf,EUDXXXX,pst);
+                           break;
+                   }
+#endif /* LCUDX */
+}
+   if (SPkS16(spId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX110, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+
+   pst->event = (Event) EVTUDXSDUSTAREQ;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxSduStaReq
+(
+UdxSduStaReq func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxSduStaReq(func, pst, mBuf)
+UdxSduStaReq func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   S16   ret1;
+   SpId spId;
+   UdxSduStaReqInfo *staReq;
+   
+   TRC3(cmUnpkPjUdxSduStaReq)
+
+   if (SUnpkS16(&spId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX112, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+           case UDX_SEL_LC:
+                   {
+
+                           if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&staReq,\
+                                                           sizeof(UdxSduStaReqInfo))) != ROK)
+                           {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                   (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+                                   RETVALUE(ret1);
+                           }
+
+                           if (cmUnpkPjUdxSduStaReqInfo(staReq, mBuf) != ROK) {
+                                   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo));
+                                   PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                   __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                   (ErrVal)EUDX114, (ErrVal)0, "Packing failed");
+#endif
+                                   RETVALUE(RFAILED);
+                           }
+                           break;
+                   }
+           case UDX_SEL_LWLC:
+                   {
+                           CMCHKUNPK(cmUnpkPtr,(PTR *) &staReq,mBuf);
+                           break;
+                   }
+#endif /* LCUDX */
+}
+PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, spId, staReq));
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxSduStaCfm
+(
+ Pst * pst,
+ SuId suId,
+ UdxSduStaCfmInfo * staCfm
+ )
+#else
+PUBLIC S16 cmPkPjUdxSduStaCfm(pst, suId, staCfm)
+        Pst * pst;
+        SuId suId;
+        UdxSduStaCfmInfo * staCfm;
+#endif
+{
+        Buffer *mBuf = NULLP;
+        TRC3(cmPkPjUdxSduStaCfm)
+
+                if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                        (ErrVal)ECPJ115, (ErrVal)0, "Packing failed");
+#endif
+                        PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staCfm, sizeof(UdxSduStaCfmInfo));
+                        RETVALUE(RFAILED);
+                }
+        switch(pst->selector)
+        {
+#ifdef LCUDX
+                case UDX_SEL_LC:
+                        {
+
+
+                                if (cmPkPjUdxSduStaCfmInfo(pst, staCfm, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                                        (ErrVal)ECPJ116, (ErrVal)0, "Packing failed");
+#endif
+                                        PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staCfm, sizeof(UdxSduStaCfmInfo));
+                                        PJ_FREE_BUF(mBuf);
+                                        RETVALUE(RFAILED);
+                                }
+                                break;
+                        }
+                case UDX_SEL_LWLC:
+                        {
+                                CMCHKPKLOG(cmPkPtr,(PTR)staCfm,mBuf,EUDXXXX,pst);
+                                break;
+                        }
+#endif /* LCUDX */
+        }
+
+        if (SPkS16(suId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                (ErrVal)ECPJ118, (ErrVal)0, "Packing failed");
+#endif
+                PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staCfm, sizeof(UdxSduStaCfmInfo));
+                PJ_FREE_BUF(mBuf);
+                RETVALUE(RFAILED);
+        }
+
+        /* Free Confirm Structure after packing */
+        /*SPutSBuf(pst->region, pst->pool, (Data *)staCfm, sizeof(UdxSduStaCfmInfo));*/
+
+        pst->event = (Event) EVTUDXSDUSTACFM;
+        RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxSduStaCfm
+(
+ UdxSduStaCfm func,
+ Pst *pst,
+ Buffer *mBuf
+ )
+#else
+PUBLIC S16 cmUnpkPjUdxSduStaCfm(func, pst, mBuf)
+        UdxSduStaCfm func;
+        Pst *pst;
+        Buffer *mBuf;
+#endif
+{
+        S16   ret1;
+        SuId suId;
+        UdxSduStaCfmInfo *staCfm;
+
+        TRC3(cmUnpkPjUdxSduStaCfm)
+
+                if (SUnpkS16(&suId, mBuf) != ROK) {
+                   PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                        (ErrVal)ECPJ120, (ErrVal)0, "Packing failed");
+#endif
+                        RETVALUE(RFAILED);
+                }
+        switch(pst->selector)
+        {
+#ifdef LCUDX
+                case UDX_SEL_LC:
+                {
+                    if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&staCfm,\
+                                        sizeof(UdxSduStaCfmInfo))) != ROK)
+                    {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                        SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                  __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                 (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+                        RETVALUE(ret1);
+                    }
+
+                    if (cmUnpkPjUdxSduStaCfmInfo(pst, staCfm, mBuf) != ROK) {
+                            PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staCfm, sizeof(UdxSduStaCfmInfo));
+                            PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+                            SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                                            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                                            (ErrVal)ECPJ122, (ErrVal)0, "Packing failed");
+#endif
+                            RETVALUE(RFAILED);
+                    }
+                }
+                break;
+
+                case UDX_SEL_LWLC:
+                {
+                        CMCHKUNPK(cmUnpkPtr,(PTR *) &staCfm,mBuf);
+                }
+                break;
+        }
+#endif /* LCUDX */
+
+
+        PJ_FREE_BUF(mBuf);
+        RETVALUE((*func)(pst, suId, staCfm));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxDatResumeCfm
+(
+ Pst * pst,
+ SuId suId,
+ UdxDatResumeCfmInfo * datResumeCfm
+ )
+#else
+PUBLIC S16 cmPkPjUdxDatResumeCfm(pst, suId, datResumeCfm)
+   Pst * pst;
+   SuId suId;
+   UdxDatResumeCfmInfo * datResumeCfm;
+#endif
+{
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkPjUdxDatResumeCfm)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ECPJ115, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeCfm, sizeof(UdxDatResumeCfmInfo));
+      RETVALUE(RFAILED);
+   }
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+      case UDX_SEL_LC:
+         {
+            if (cmPkPjUdxDatResumeCfmInfo(pst, datResumeCfm, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                     (ErrVal)ECPJ116, (ErrVal)0, "Packing failed");
+#endif
+               PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeCfm, sizeof(UdxDatResumeCfmInfo));
+               PJ_FREE_BUF(mBuf);
+               RETVALUE(RFAILED);
+            }
+            break;
+         }
+      case UDX_SEL_LWLC:
+         {
+            CMCHKPKLOG(cmPkPtr,(PTR)datResumeCfm,mBuf,EUDXXXX,pst);
+            break;
+         }
+#endif /* LCUDX */
+   }
+
+   if (SPkS16(suId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ECPJ118, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeCfm, sizeof(UdxDatResumeCfmInfo));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+
+   /* Free Confirm Structure after packing */
+   /*SPutSBuf(pst->region, pst->pool, (Data *)datResumeCfm, sizeof(UdxSduStaCfmInfo));*/
+
+   pst->event = (Event) EVTUDXDATRESUMECFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+/*
+*
+*    Fun:    cmPkPjUdxDatForwardCfm
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:  None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxDatForwardCfm
+(
+ Pst * pst,
+ SuId suId,
+ UdxDatFwdCfmInfo  * datFwdCfm
+ )
+#else
+PUBLIC S16 cmPkPjUdxDatForwardCfm(pst, suId, datFwdCfm)
+   Pst * pst;
+   SuId suId;
+   UdxDatFwdCfmInfo  * datFwdCfm;
+#endif
+{
+
+   Buffer *mBuf = NULLP;
+   TRC3(cmPkPjUdxDatForwardCfm)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ECPJ115, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo));
+      RETVALUE(RFAILED);
+   }
+
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+      case UDX_SEL_LC:
+         {
+            if (cmPkPjUdxDatForwardCfmInfo(pst, datFwdCfm, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                     (ErrVal)ECPJ116, (ErrVal)0, "Packing failed");
+#endif
+               PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo));
+               PJ_FREE_BUF(mBuf);
+               RETVALUE(RFAILED);
+            }
+            break;
+         }
+      case UDX_SEL_LWLC:
+         {
+            CMCHKPKLOG(cmPkPtr,(PTR)datFwdCfm,mBuf,EUDXXXX,pst);
+            break;
+         }
+#endif /* LCUDX */
+   }
+
+   if (SPkS16(suId, mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ECPJ118, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+
+   /* Free Confirm Structure after packing */
+   /*SPutSBuf(pst->region, pst->pool, (Data *)datFwdCfm, sizeof(UdxDatFwdCfmInfo));*/
+
+   pst->event = (Event) EVTUDXDATFRWDCFM;
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxDatResumeCfm
+(
+ UdxDatResumeCfm func,
+ Pst *pst,
+ Buffer *mBuf
+ )
+#else
+PUBLIC S16 cmUnpkPjUdxDatResumeCfm(func, pst, mBuf)
+   UdxDatResumeCfm func;
+   Pst *pst;
+   Buffer *mBuf;
+#endif
+{
+   S16   ret1;
+   SuId suId;
+   UdxDatResumeCfmInfo *datResumeCfm = NULLP;
+
+   TRC3(cmUnpkPjUdxDatResumeCfm)
+
+   RLOG0(L_DEBUG," Unpacking UdxDatResumeCfm");
+   if (SUnpkS16(&suId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ECPJ120, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+      case UDX_SEL_LC:
+         {
+            if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&datResumeCfm,\
+                        sizeof(UdxDatResumeCfmInfo))) != ROK)
+            {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                     (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+               RETVALUE(ret1);
+            }
+
+            if (cmUnpkPjUdxDatResumeCfmInfo(pst, datResumeCfm, mBuf) != ROK) {
+               PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeCfm, sizeof(UdxDatResumeCfmInfo));
+               PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                     (ErrVal)ECPJ122, (ErrVal)0, "Packing failed");
+#endif
+               RETVALUE(RFAILED);
+            }
+         }
+         break;
+
+      case UDX_SEL_LWLC:
+         {
+            CMCHKUNPK(cmUnpkPtr,(PTR *) &datResumeCfm,mBuf);
+         }
+         break;
+   }
+#endif /* LCUDX */
+
+
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, suId, datResumeCfm));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxDatForwardCfm
+(
+ UdxDatForwardCfm func,
+ Pst *pst,
+ Buffer *mBuf
+ )
+#else
+PUBLIC S16 cmUnpkPjUdxDatForwardCfm(func, pst, mBuf)
+   UdxDatForwardCfm func;
+   Pst *pst;
+   Buffer *mBuf;
+#endif
+{
+   S16   ret1;
+   SuId suId;
+   UdxDatFwdCfmInfo *datFwdCfm;
+
+   TRC3(cmUnpkPjUdxDatForwardCfm)
+
+   if (SUnpkS16(&suId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)ECPJ120, (ErrVal)0, "Packing failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+      case UDX_SEL_LC:
+         {
+            if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&datFwdCfm,\
+                        sizeof(UdxDatFwdCfmInfo))) != ROK)
+            {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                     (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+               RETVALUE(ret1);
+            }
+
+            if (cmUnpkPjUdxDatForwardCfmInfo(pst, datFwdCfm, mBuf) != ROK) {
+               PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo));
+               PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                     (ErrVal)ECPJ122, (ErrVal)0, "Packing failed");
+#endif
+               RETVALUE(RFAILED);
+            }
+         }
+         break;
+
+      case UDX_SEL_LWLC:
+         {
+            CMCHKUNPK(cmUnpkPtr,(PTR *) &datFwdCfm,mBuf);
+         }
+         break;
+   }
+#endif /* LCUDX */
+
+   PJ_FREE_BUF(mBuf);
+   RETVALUE((*func)(pst, suId, datFwdCfm));
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxRlcAm
+*
+*
+*     Desc :  * RLC parameter information in AM mode.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxRlcAm
+(
+UdxRlcAm *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxRlcAm(param, mBuf)
+UdxRlcAm *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxRlcAm)
+
+   CMCHKPK(SPkU8, param->statusRepReqd, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxRlcAm
+*
+*
+*     Desc :  * RLC parameter information in AM mode.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxRlcAm
+(
+UdxRlcAm *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxRlcAm(param, mBuf)
+UdxRlcAm *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxRlcAm)
+
+   CMCHKUNPK(SUnpkU8, &param->statusRepReqd, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxRlcUm
+*
+*
+*     Desc : * RLC parameter information in UM mode.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxRlcUm
+(
+UdxRlcUm *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxRlcUm(param, mBuf)
+UdxRlcUm *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxRlcUm)
+
+   CMCHKPK(SPkU8, param->pdcpSNSize, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxRlcUm
+*
+*
+*     Desc : * RLC parameter information in UM mode.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxRlcUm
+(
+UdxRlcUm *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxRlcUm(param, mBuf)
+UdxRlcUm *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxRlcUm)
+
+   CMCHKUNPK(SUnpkU8, &param->pdcpSNSize, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxRlcInfo
+*
+*
+*     Desc : * Mapped RLC entity information in RLC for the PDCP entity
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxRlcInfo
+(
+UdxRlcInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxRlcInfo(param, mBuf)
+UdxRlcInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxRlcInfo)
+
+      switch(param->mode) {
+         case CM_LTE_MODE_UM:
+            CMCHKPK(cmPkPjUdxRlcUm, &param->m.rlcUm, mBuf);
+            break;
+         case CM_LTE_MODE_AM:
+            CMCHKPK(cmPkPjUdxRlcAm, &param->m.rlcAm, mBuf);
+            break;
+         default :
+            RETVALUE(RFAILED);
+      }
+   CMCHKPK(SPkU8, param->mode, mBuf);
+   CMCHKPK(SPkU8, param->dir, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxRlcInfo
+*
+*
+*     Desc : * Mapped RLC entity information in RLC for the PDCP entity
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxRlcInfo
+(
+UdxRlcInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxRlcInfo(param, mBuf)
+UdxRlcInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxRlcInfo)
+
+   CMCHKUNPK(SUnpkU8, &param->dir, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->mode, mBuf);
+      switch(param->mode) {
+         case CM_LTE_MODE_AM:
+            CMCHKUNPK(cmUnpkPjUdxRlcAm, &param->m.rlcAm, mBuf);
+            break;
+         case CM_LTE_MODE_UM:
+            CMCHKUNPK(cmUnpkPjUdxRlcUm, &param->m.rlcUm, mBuf);
+            break;
+         default :
+            RETVALUE(RFAILED);
+      }
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxCipherInfo
+*
+*
+*     Desc : * Ciphering information to be configured per UE in PDCP.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxCipherInfo
+(
+UdxCipherInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxCipherInfo(param, mBuf)
+UdxCipherInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmPkPjUdxCipherInfo)
+
+   CMCHKPK(SPkU8, param->algoType, mBuf);
+   for (i=UDX_CIPHER_KEY_LEN-1; i >= 0; i--) {
+      CMCHKPK(SPkU8, param->usrplnKey[i], mBuf);
+   }
+   for (i=UDX_CIPHER_KEY_LEN-1; i >= 0; i--) {
+      CMCHKPK(SPkU8, param->ctrlplnKey[i], mBuf);
+   }
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxCipherInfo
+*
+*
+*     Desc : * Ciphering information to be configured per UE in PDCP.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxCipherInfo
+(
+UdxCipherInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxCipherInfo(param, mBuf)
+UdxCipherInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmUnpkPjUdxCipherInfo)
+
+   for (i=0; i<UDX_CIPHER_KEY_LEN; i++) {
+      CMCHKUNPK(SUnpkU8, &param->ctrlplnKey[i], mBuf);
+   }
+   for (i=0; i<UDX_CIPHER_KEY_LEN; i++) {
+      CMCHKUNPK(SUnpkU8, &param->usrplnKey[i], mBuf);
+   }
+   CMCHKUNPK(SUnpkU8, &param->algoType, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxIntegInfo
+*
+*
+*     Desc : * Integrity protection paramater information.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxIntegInfo
+(
+UdxIntegInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxIntegInfo(param, mBuf)
+UdxIntegInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmPkPjUdxIntegInfo)
+
+   for (i=UDX_INTG_KEY_LEN-1; i >= 0; i--) {
+      CMCHKPK(SPkU8, param->intKey[i], mBuf);
+   }
+   CMCHKPK(SPkU8, param->algoType, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxIntegInfo
+*
+*
+*     Desc : * Integrity protection paramater information.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxIntegInfo
+(
+UdxIntegInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxIntegInfo(param, mBuf)
+UdxIntegInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmUnpkPjUdxIntegInfo)
+
+   CMCHKUNPK(SUnpkU8, &param->algoType, mBuf);
+   for (i=0; i<UDX_INTG_KEY_LEN; i++) {
+      CMCHKUNPK(SUnpkU8, &param->intKey[i], mBuf);
+   }
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxSecCfg
+*
+*
+*     Desc : * PDCP Security configuration parameter.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxSecCfg
+(
+UdxSecCfg *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxSecCfg(param, mBuf)
+UdxSecCfg *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxSecCfg)
+
+   CMCHKPK(cmPkPjUdxCipherInfo, &param->cipherInfo, mBuf);
+   CMCHKPK(cmPkPjUdxIntegInfo, &param->integInfo, mBuf);
+   CMCHKPK(SPkU8, param->selSecAct, mBuf);
+   CMCHKPK(SPkU8, param->isHo, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxSecCfg
+*
+*
+*     Desc : * PDCP Security configuration parameter.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxSecCfg
+(
+UdxSecCfg *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxSecCfg(param, mBuf)
+UdxSecCfg *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxSecCfg)
+
+   CMCHKUNPK(SUnpkU8, &param->isHo, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->selSecAct, mBuf);
+   CMCHKUNPK(cmUnpkPjUdxIntegInfo, &param->integInfo, mBuf);
+   CMCHKUNPK(cmUnpkPjUdxCipherInfo, &param->cipherInfo, mBuf);
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxRohcInfo
+*
+*
+*     Desc : * ROHC compression protocol information structure.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxRohcInfo
+(
+UdxRohcInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxRohcInfo(param, mBuf)
+UdxRohcInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmPkPjUdxRohcInfo)
+
+   for (i=UDX_MAX_ROHC_PROF_LIST-1; i >= 0; i--) {
+      CMCHKPK(SPkU8, param->profLst[i], mBuf);
+   }
+   CMCHKPK(SPkU16, param->maxCid, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxRohcInfo
+*
+*
+*     Desc : * ROHC compression protocol information structure.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxRohcInfo
+(
+UdxRohcInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxRohcInfo(param, mBuf)
+UdxRohcInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmUnpkPjUdxRohcInfo)
+
+   CMCHKUNPK(SUnpkU16, &param->maxCid, mBuf);
+   for (i=0; i<UDX_MAX_ROHC_PROF_LIST; i++) {
+      CMCHKUNPK(SUnpkU8, &param->profLst[i], mBuf);
+   }
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxHdrCompCfg
+*
+*
+*     Desc : * ROHC configuration information for PDCP entity.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxHdrCompCfg
+(
+UdxHdrCompCfg *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxHdrCompCfg(param, mBuf)
+UdxHdrCompCfg *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxHdrCompCfg)
+
+   CMCHKPK(cmPkPjUdxRohcInfo, &param->rohcInfo, mBuf);
+   CMCHKPK(SPkU8, param->hdrCompUsed, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxHdrCompCfg
+*
+*
+*     Desc : * ROHC configuration information for PDCP entity.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxHdrCompCfg
+(
+UdxHdrCompCfg *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxHdrCompCfg(param, mBuf)
+UdxHdrCompCfg *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxHdrCompCfg)
+
+   CMCHKUNPK(SUnpkU8, &param->hdrCompUsed, mBuf);
+   CMCHKUNPK(cmUnpkPjUdxRohcInfo, &param->rohcInfo, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxHoInfo
+*
+*
+*     Desc : * Handover Information for RB.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxHoInfo
+(
+Pst *pst,
+UdxHoInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxHoInfo(pst, param, mBuf)
+Pst *pst;
+UdxHoInfo *param;
+Buffer *mBuf;
+#endif
+{
+   S16   cnt, idx;
+
+   TRC3(cmPkPjUdxHoInfo)
+
+   if (param->numBits % 8 == 0)
+      cnt = param->numBits/8;
+   else
+      cnt = param->numBits/8 + 1;
+
+   for (idx = cnt-1; idx >= 0; idx--)
+   {
+      CMCHKPK(SPkU8, param->ulBitMap[idx], mBuf);
+   }
+
+   /* Free ulBitMap after packing */
+   if (cnt)
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, param->ulBitMap, cnt * sizeof(U8));
+
+   CMCHKPK(SPkU16, param->numBits, mBuf);
+   CMCHKPK(SPkU32, param->ulCount, mBuf);
+   CMCHKPK(SPkU32, param->dlCount, mBuf);
+   CMCHKPK(SPkU8, param->isHoPres, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxHoInfo
+*
+*
+*     Desc : * Handover Information for RB.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxHoInfo
+(
+Pst *pst,
+UdxHoInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxHoInfo(pst, param, mBuf)
+Pst *pst;
+UdxHoInfo *param;
+Buffer *mBuf;
+#endif
+{
+   S16   cnt, idx;
+   S16   ret1 = ROK;
+
+   TRC3(cmUnpkPjUdxHoInfo)
+
+   CMCHKUNPK(SUnpkU8, &param->isHoPres, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->dlCount, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->ulCount, mBuf);
+   CMCHKUNPK(SUnpkU16, &param->numBits, mBuf);
+
+   if (param->numBits % 8 == 0)
+      cnt = param->numBits/8;
+   else
+      cnt = param->numBits/8 + 1;
+
+   if(cnt && (ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&param->ulBitMap,\
+               cnt * sizeof(U8), 0)) != ROK)
+   {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+            __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+            (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+      RETVALUE(ret1);
+   }
+
+   if (cnt == 0)
+      param->ulBitMap = NULLP;
+
+   for (idx = 0; idx < cnt; idx++)
+   {
+      CMCHKUNPK(SUnpkU8, &param->ulBitMap[idx], mBuf);
+   }
+
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxCfgEnt
+*
+*
+*     Desc : * Configuration structure for PDCP entity.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxCfgEnt
+(
+Pst *pst,
+UdxCfgEnt *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxCfgEnt(pst, param, mBuf)
+Pst *pst;
+UdxCfgEnt *param;
+Buffer *mBuf;
+#endif
+{
+   TRC3(cmPkPjUdxCfgEnt)
+
+      switch(param->cfgType) {
+         case UDX_CFG_MODIFY:
+            if (cmPkPjUdxModCfgEnt(pst, &param->m.modCfg, mBuf) != ROK)
+               RETVALUE(RFAILED);
+            break;
+         case UDX_CFG_ADD:
+            CMCHKPK(cmPkPjUdxAddCfgEnt, &param->m.addCfg, mBuf);
+            break;
+      }
+   CMCHKPK(SPkU8, param->cfgType, mBuf);
+   CMCHKPK(SPkU8, param->rbType, mBuf);
+   CMCHKPK(SPkU8, param->rbId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxCfgEnt
+*
+*
+*     Desc : * Configuration structure for PDCP entity.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxCfgEnt
+(
+Pst *pst,
+UdxCfgEnt *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxCfgEnt(pst, param, mBuf)
+Pst *pst;
+UdxCfgEnt *param;
+Buffer *mBuf;
+#endif
+{
+   TRC3(cmUnpkPjUdxCfgEnt)
+
+   CMCHKUNPK(SUnpkU8, &param->rbId, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->rbType, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->cfgType, mBuf);
+      switch(param->cfgType) {
+         case UDX_CFG_ADD:
+            CMCHKUNPK(cmUnpkPjUdxAddCfgEnt, &param->m.addCfg, mBuf);
+            break;
+         case UDX_CFG_MODIFY:
+            if (cmUnpkPjUdxModCfgEnt(pst, &param->m.modCfg, mBuf) != ROK)
+               RETVALUE(RFAILED);
+            break;
+      }
+   RETVALUE(ROK);
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxAddCfgEnt
+(
+UdxAddCfgEnt *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxAddCfgEnt(param, mBuf)
+UdxAddCfgEnt *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxAddCfgEnt)
+
+   CMCHKPK(cmPkPjUdxHdrCompCfg, &param->hdrCompCfg, mBuf);
+   CMCHKPK(SPkS16, param->discardTmr, mBuf);
+   CMCHKPK(cmPkPjUdxRlcInfo, &param->rlcInfo, mBuf);
+   /* cpj_c_001.main_4 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+   CMCHKPK(SPkU8, param->qci, mBuf);
+#endif /* LTE_L2_MEAS */
+   CMCHKPK(SPkU8, param->cfmReqd, mBuf);
+   CMCHKPK(SPkU8, param->discReqd, mBuf);
+   RETVALUE(ROK);
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxAddCfgEnt
+(
+UdxAddCfgEnt *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxAddCfgEnt(param, mBuf)
+UdxAddCfgEnt *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxAddCfgEnt)
+
+   CMCHKUNPK(SUnpkU8, &param->discReqd, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->cfmReqd, mBuf);
+   /* cpj_c_001.main_4 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+   CMCHKUNPK(SUnpkU8, &param->qci, mBuf);
+#endif /* LTE_L2_MEAS */
+   CMCHKUNPK(cmUnpkPjUdxRlcInfo, &param->rlcInfo, mBuf);
+   CMCHKUNPK(SUnpkS16, &param->discardTmr, mBuf);
+   CMCHKUNPK(cmUnpkPjUdxHdrCompCfg, &param->hdrCompCfg, mBuf);
+   RETVALUE(ROK);
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxModCfgEnt
+(
+Pst *pst,
+UdxModCfgEnt *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxModCfgEnt(pst, param, mBuf)
+Pst *pst;
+UdxModCfgEnt *param;
+Buffer *mBuf;
+#endif
+{
+   TRC3(cmPkPjUdxModCfgEnt)
+
+   if (cmPkPjUdxHoInfo(pst, &param->hoInfo, mBuf) != ROK)
+      RETVALUE(RFAILED);
+   CMCHKPK(cmPkPjUdxHdrCompCfg, &param->hdrCompCfg, mBuf);
+   CMCHKPK(SPkU8, param->cfmReqd, mBuf);
+   CMCHKPK(SPkU8, param->discReqd, mBuf);
+   CMCHKPK(SPkU8, param->bitFlag, mBuf);
+   RETVALUE(ROK);
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxModCfgEnt
+(
+Pst *pst,
+UdxModCfgEnt *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxModCfgEnt(pst, param, mBuf)
+Pst *pst;
+UdxModCfgEnt *param;
+Buffer *mBuf;
+#endif
+{
+   TRC3(cmUnpkPjUdxModCfgEnt)
+
+   CMCHKUNPK(SUnpkU8, &param->bitFlag, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->discReqd, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->cfmReqd, mBuf);
+   CMCHKUNPK(cmUnpkPjUdxHdrCompCfg, &param->hdrCompCfg, mBuf);
+   if (cmUnpkPjUdxHoInfo(pst, &param->hoInfo, mBuf) != ROK)
+      RETVALUE(RFAILED);
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxCfgReqInfo
+*
+*
+*     Desc : * PDCP Configuration structure. Parameters are filled by RRC 
+   layer while configuring the PDCP layer.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxCfgReqInfo
+(
+Pst *pst,
+UdxCfgReqInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxCfgReqInfo(pst, param, mBuf)
+Pst *pst;
+UdxCfgReqInfo *param;
+Buffer *mBuf;
+#endif
+{
+   S32 i;
+
+   TRC3(cmPkPjUdxCfgReqInfo)
+
+   for (i=param->numEnt-1; i >= 0; i--) {
+      if (cmPkPjUdxCfgEnt(pst, &param->cfgEnt[i], mBuf) != ROK)
+         RETVALUE(RFAILED);
+   }
+#ifdef TENB_MULT_CELL_SUPPRT
+   CMCHKPK(SPkS16, param->rlcDlSapId, mBuf);
+   CMCHKPK(SPkS16, param->rlcUlSapId, mBuf);
+#endif
+
+   CMCHKPK(SPkU8, param->numEnt, mBuf);
+   CMCHKPK(SPkU32, param->transId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   RETVALUE(ROK);
+}
+
+/*
+*
+*    Fun:    cmPkPjUdxUlStaRepInfo
+*
+*    Desc:    pack the structure UdxUlStaRepInfo
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:    None
+*
+*    File:     pj_udx.c
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxUlStaRepInfo
+(
+UdxUlStaRepInfo  *param,
+Pst            *pst,
+Buffer         *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxUlStaRepInfo(param, pst, mBuf)
+UdxUlStaRepInfo  *param;
+Pst            *pst;
+Buffer         *mBuf;
+#endif
+{
+   S16 msgLen;
+   TRC3(cmPkPjUdxUlStaRepInfo)
+
+   CMCHKPK(SPkU8, param->pdcpId.rbType, mBuf);
+   CMCHKPK(cmPkLteRbId, param->pdcpId.rbId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->pdcpId.ueId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->pdcpId.cellId, mBuf);
+
+   if (SFndLenMsg(param->sta, &msgLen) != ROK)
+      RETVALUE(RFAILED);
+   if (SCatMsg(mBuf, param->sta, M1M2) != ROK)
+      RETVALUE(RFAILED);
+   PJ_FREE_BUF(mBuf);
+   CMCHKPK(SPkS16, msgLen, mBuf);
+
+   RETVALUE(ROK);
+} /* cmPkPjUdxUlStaRepInfo */
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxUlStaRepInfo
+(
+Pst *pst,
+UdxUlStaRepInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxUlStaRepInfo(pst, param, mBuf)
+Pst *pst;
+UdxUlStaRepInfo *param;
+Buffer *mBuf;
+#endif
+{
+   MsgLen msgLen=0;
+   MsgLen totalMsgLen;
+
+   TRC3(cmUnpkPjUdxUlStaRepInfo);
+
+   CMCHKUNPK(SUnpkU8, &param->pdcpId.rbType, mBuf);
+   CMCHKUNPK(cmUnpkLteRbId, &param->pdcpId.rbId, mBuf);
+   CMCHKUNPK(cmUnpkLteRnti, &param->pdcpId.ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->pdcpId.cellId, mBuf);
+
+   if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
+      RETVALUE(RFAILED);
+
+   if (SSegMsg(mBuf, totalMsgLen-msgLen, &param->sta) != ROK)
+      RETVALUE(RFAILED);   
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxUlFdbkPktInfo
+(
+Pst *pst,
+UdxUlFdbkPktInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxUlFdbkPktInfo(pst, param, mBuf)
+Pst *pst;
+UdxUlFdbkPktInfo *param;
+Buffer *mBuf;
+#endif
+{
+   MsgLen msgLen=0;
+   MsgLen totalMsgLen;
+
+   TRC3(cmUnpkPjUdxUlFdbkPktInfo);
+
+   CMCHKUNPK(SUnpkU8, &param->pdcpId.rbType, mBuf);
+   CMCHKUNPK(cmUnpkLteRbId, &param->pdcpId.rbId, mBuf);
+   CMCHKUNPK(cmUnpkLteRnti, &param->pdcpId.ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->pdcpId.cellId, mBuf);
+
+   if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
+      RETVALUE(RFAILED);
+
+   if (SSegMsg(mBuf, totalMsgLen-msgLen, &param->fbPkt) != ROK)
+      RETVALUE(RFAILED);   
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxDlFdbkPktInfo
+(
+Pst *pst,
+UdxDlFdbkPktInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxDlFdbkPktInfo(pst, param, mBuf)
+Pst *pst;
+UdxDlFdbkPktInfo *param;
+Buffer *mBuf;
+#endif
+{
+   MsgLen msgLen=0;
+   MsgLen totalMsgLen;
+
+   TRC3(cmUnpkPjUdxDlFdbkPktInfo);
+
+   CMCHKUNPK(SUnpkU8, &param->pdcpId.rbType, mBuf);
+   CMCHKUNPK(cmUnpkLteRbId, &param->pdcpId.rbId, mBuf);
+   CMCHKUNPK(cmUnpkLteRnti, &param->pdcpId.ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->pdcpId.cellId, mBuf);
+
+   if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
+      RETVALUE(RFAILED);
+
+   if (SSegMsg(mBuf, totalMsgLen-msgLen, &param->fbPkt) != ROK)
+      RETVALUE(RFAILED);   
+
+   RETVALUE(ROK);
+}
+
+/*
+*
+*    Fun:    cmPkPjUdxDlStaRepInfo
+*
+*    Desc:    pack the structure UdxDlStaRepInfo
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:    None
+*
+*    File:     pj_udx.c
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxDlStaRepInfo
+(
+UdxDlStaRepInfo  *param,
+Pst            *pst,
+Buffer         *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxDlStaRepInfo(param, pst, mBuf)
+UdxDlStaRepInfo  *param;
+Pst            *pst;
+Buffer         *mBuf;
+#endif
+{
+   S16 msgLen;
+   TRC3(cmPkPjUdxDlStaRepInfo)
+
+   CMCHKPK(SPkU8, param->pdcpId.rbType, mBuf);
+   CMCHKPK(cmPkLteRbId, param->pdcpId.rbId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->pdcpId.ueId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->pdcpId.cellId, mBuf);
+   CMCHKPK(SPkU32, param->fmc, mBuf);
+   
+   if (SFndLenMsg(param->staPdu, &msgLen) != ROK)
+      RETVALUE(RFAILED);
+   if (SCatMsg(mBuf, param->staPdu, M1M2) != ROK)
+      RETVALUE(RFAILED);
+   PJ_FREE_BUF(mBuf);
+   CMCHKPK(SPkS16, msgLen, mBuf);
+
+   RETVALUE(ROK);
+} /* cmPkPjUdxUlStaRepInfo */
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxDlStaRepInfo
+(
+Pst *pst,
+UdxDlStaRepInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxDlStaRepInfo(pst, param, mBuf)
+Pst *pst;
+UdxDlStaRepInfo *param;
+Buffer *mBuf;
+#endif
+{
+   MsgLen msgLen=0;
+   MsgLen totalMsgLen;
+
+   TRC3(cmUnpkPjUdxDlStaRepInfo);
+
+   CMCHKUNPK(SUnpkU8, &param->pdcpId.rbType, mBuf);
+   CMCHKUNPK(cmUnpkLteRbId, &param->pdcpId.rbId, mBuf);
+   CMCHKUNPK(cmUnpkLteRnti, &param->pdcpId.ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->pdcpId.cellId, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->fmc, mBuf);
+
+   if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
+      RETVALUE(RFAILED);
+
+   if (SSegMsg(mBuf, totalMsgLen-msgLen, &param->staPdu) != ROK)
+      RETVALUE(RFAILED);   
+
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxCfgReqInfo
+*
+*
+*     Desc : * PDCP Configuration structure. Parameters are filled by RRC 
+   layer while configuring the PDCP layer.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxCfgReqInfo
+(
+Pst *pst,
+UdxCfgReqInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxCfgReqInfo(pst, param, mBuf)
+Pst *pst;
+UdxCfgReqInfo *param;
+Buffer *mBuf;
+#endif
+{
+   S32 i;
+
+   TRC3(cmUnpkPjUdxCfgReqInfo)
+
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->transId, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->numEnt, mBuf);
+#ifdef TENB_MULT_CELL_SUPPRT
+   CMCHKUNPK(SUnpkS16, &param->rlcUlSapId, mBuf);
+   CMCHKUNPK(SUnpkS16, &param->rlcDlSapId, mBuf);
+#endif
+   for (i=0; i<param->numEnt; i++) {
+      if (cmUnpkPjUdxCfgEnt(pst, &param->cfgEnt[i], mBuf) != ROK)
+         RETVALUE(RFAILED);
+   }
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxCfmEnt
+*
+*
+*     Desc : * PDCP confirm parameter structure for PDCP entity.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxCfmEnt
+(
+UdxCfmEnt *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxCfmEnt(param, mBuf)
+UdxCfmEnt *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxCfmEnt)
+
+   CMCHKPK(SPkS16, param->reason, mBuf);
+   CMCHKPK(SPkS16, param->status, mBuf);
+   CMCHKPK(SPkU8, param->rbType, mBuf);
+   CMCHKPK(SPkU8, param->rbId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxCfmEnt
+*
+*
+*     Desc : * PDCP confirm parameter structure for PDCP entity.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxCfmEnt
+(
+UdxCfmEnt *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxCfmEnt(param, mBuf)
+UdxCfmEnt *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxCfmEnt)
+
+   CMCHKUNPK(SUnpkU8, &param->rbId, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->rbType, mBuf);
+   CMCHKUNPK(SUnpkS16, &param->status, mBuf);
+   CMCHKUNPK(SUnpkS16, &param->reason, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxCfgCfmInfo
+*
+*
+*     Desc : * PDCP configuration confirm structure.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxCfgCfmInfo
+(
+UdxCfgCfmInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxCfgCfmInfo(param, mBuf)
+UdxCfgCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmPkPjUdxCfgCfmInfo)
+
+   for (i=param->numEnt-1; i >= 0; i--) {
+      CMCHKPK(cmPkPjUdxCfmEnt, &param->cfmEnt[i], mBuf);
+   }
+   CMCHKPK(SPkU8, param->numEnt, mBuf);
+   CMCHKPK(SPkU32, param->transId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxCfgCfmInfo
+*
+*
+*     Desc : * PDCP configuration confirm structure.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxCfgCfmInfo
+(
+UdxCfgCfmInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxCfgCfmInfo(param, mBuf)
+UdxCfgCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmUnpkPjUdxCfgCfmInfo)
+
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->transId, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->numEnt, mBuf);
+   for (i=0; i<param->numEnt; i++) {
+      CMCHKUNPK(cmUnpkPjUdxCfmEnt, &param->cfmEnt[i], mBuf);
+   }
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxReEstReqInfo
+*
+*
+*     Desc : * Reestabishment request structure for SRB1 of an UE.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxReEstReqInfo
+(
+UdxReEstReqInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxReEstReqInfo(param, mBuf)
+UdxReEstReqInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmPkPjUdxReEstReqInfo)
+
+   for (i=UDX_CIPHER_KEY_LEN-1; i >= 0; i--) {
+      CMCHKPK(SPkU8, param->usrplnKey[i], mBuf);
+   }
+   for (i=UDX_CIPHER_KEY_LEN-1; i >= 0; i--) {
+      CMCHKPK(SPkU8, param->ctrlplnKey[i], mBuf);
+   }
+   for (i=UDX_INTG_KEY_LEN-1; i >= 0; i--) {
+      CMCHKPK(SPkU8, param->intKey[i], mBuf);
+   }
+   CMCHKPK(SPkU32, param->transId, mBuf);
+
+   CMCHKPK(cmPkLtePdcpId, &param->pdcpId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxReEstReqInfo
+*
+*
+*     Desc : * Reestabishment request structure for SRB1 of an UE.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxReEstReqInfo
+(
+UdxReEstReqInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxReEstReqInfo(param, mBuf)
+UdxReEstReqInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmUnpkPjUdxReEstReqInfo)
+
+   CMCHKUNPK(cmUnpkLtePdcpId, &param->pdcpId, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->transId, mBuf);
+   for (i=0; i<UDX_INTG_KEY_LEN; i++) {
+      CMCHKUNPK(SUnpkU8, &param->intKey[i], mBuf);
+   }
+   for (i=0; i<UDX_CIPHER_KEY_LEN; i++) {
+      CMCHKUNPK(SUnpkU8, &param->ctrlplnKey[i], mBuf);
+   }
+   for (i=0; i<UDX_CIPHER_KEY_LEN; i++) {
+      CMCHKUNPK(SUnpkU8, &param->usrplnKey[i], mBuf);
+   }
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxReEstCfmInfo
+*
+*
+*     Desc : * Reestablishment confirmation structure for an UE.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxReEstCfmInfo
+(
+UdxReEstCfmInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxReEstCfmInfo(param, mBuf)
+UdxReEstCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxReEstCfmInfo)
+
+   CMCHKPK(SPkS16, param->status, mBuf);
+   CMCHKPK(SPkU32, param->transId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxReEstCfmInfo
+*
+*
+*     Desc : * Reestablishment confirmation structure for an UE.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxReEstCfmInfo
+(
+UdxReEstCfmInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxReEstCfmInfo(param, mBuf)
+UdxReEstCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxReEstCfmInfo)
+
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->transId, mBuf);
+   CMCHKUNPK(SUnpkS16, &param->status, mBuf);
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxSecCfgReqInfo
+*
+*
+*     Desc : * PDCP Security Configuration structure. Parameters are filled by RRC
+ * while configuring the security parameters.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxSecCfgReqInfo
+(
+UdxSecCfgReqInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxSecCfgReqInfo(param, mBuf)
+UdxSecCfgReqInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxSecCfgReqInfo)
+
+   CMCHKPK(cmPkPjUdxSecCfg, &param->secCfg, mBuf);
+   CMCHKPK(SPkU32, param->transId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxSecCfgReqInfo
+*
+*
+*     Desc : * PDCP Security Configuration structure. Parameters are filled by RRC
+ * while configuring the security parameters.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxSecCfgReqInfo
+(
+UdxSecCfgReqInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxSecCfgReqInfo(param, mBuf)
+UdxSecCfgReqInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxSecCfgReqInfo)
+
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->transId, mBuf);
+   CMCHKUNPK(cmUnpkPjUdxSecCfg, &param->secCfg, mBuf);
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxSecCfgCfmInfo
+*
+*
+*     Desc : * PDCP Security configuration confirm structure.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxSecCfgCfmInfo
+(
+UdxSecCfgCfmInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxSecCfgCfmInfo(param, mBuf)
+UdxSecCfgCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxSecCfgCfmInfo)
+
+   CMCHKPK(SPkS16, param->reason, mBuf);
+   CMCHKPK(SPkS16, param->status, mBuf);
+   CMCHKPK(SPkU32, param->transId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxSecCfgCfmInfo
+*
+*
+*     Desc : * PDCP Security configuration confirm structure.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxSecCfgCfmInfo
+(
+UdxSecCfgCfmInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxSecCfgCfmInfo(param, mBuf)
+UdxSecCfgCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxSecCfgCfmInfo)
+
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->transId, mBuf);
+   CMCHKUNPK(SUnpkS16, &param->status, mBuf);
+   CMCHKUNPK(SUnpkS16, &param->reason, mBuf);
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxUeInfo
+*
+*
+*     Desc : *  UE ID information
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxUeInfo
+(
+UdxUeInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxUeInfo(param, mBuf)
+UdxUeInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxUeInfo)
+
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxUeInfo
+*
+*
+*     Desc : *  UE ID information
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxUeInfo
+(
+UdxUeInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxUeInfo(param, mBuf)
+UdxUeInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxUeInfo)
+
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxCountReqInfo
+*
+*
+*     Desc : *  PDCP Count Request Information from RRC.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxCountReqInfo
+(
+UdxCountReqInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxCountReqInfo(param, mBuf)
+UdxCountReqInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxCountReqInfo)
+
+   CMCHKPK(SPkU32, param->transId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxCountReqInfo
+*
+*
+*     Desc : *  PDCP Count Request Information from RRC.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxCountReqInfo
+(
+UdxCountReqInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxCountReqInfo(param, mBuf)
+UdxCountReqInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxCountReqInfo)
+
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->transId, mBuf);
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxCountInfo
+*
+*
+*     Desc : *  PDCP Count Information for a DRB.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxCountInfo
+(
+UdxCountInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxCountInfo(param, mBuf)
+UdxCountInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxCountInfo)
+
+   CMCHKPK(SPkU32, param->dlCount, mBuf);
+   CMCHKPK(SPkU32, param->ulCount, mBuf);
+   CMCHKPK(SPkU8, param->dir, mBuf);
+   CMCHKPK(SPkU8, param->rbId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxCountInfo
+*
+*
+*     Desc : *  PDCP Count Information for a DRB.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxCountInfo
+(
+UdxCountInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxCountInfo(param, mBuf)
+UdxCountInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxCountInfo)
+
+   CMCHKUNPK(SUnpkU8, &param->rbId, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->dir, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->ulCount, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->dlCount, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxCountCfmInfo
+*
+*
+*     Desc : *  PDCP Count Request Confirmation to RRC.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxCountCfmInfo
+(
+UdxCountCfmInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxCountCfmInfo(param, mBuf)
+UdxCountCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmPkPjUdxCountCfmInfo)
+
+   CMCHKPK(SPkS16, param->reason, mBuf);
+   CMCHKPK(SPkS16, param->status, mBuf);
+   for (i=param->numRb-1; i >= 0; i--) {
+      CMCHKPK(cmPkPjUdxCountInfo, &param->countInfo[i], mBuf);
+   }
+   CMCHKPK(SPkU8, param->numRb, mBuf);
+   CMCHKPK(SPkU32, param->transId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxCountCfmInfo
+*
+*
+*     Desc : *  PDCP Count Request Confirmation to RRC.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxCountCfmInfo
+(
+UdxCountCfmInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxCountCfmInfo(param, mBuf)
+UdxCountCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmUnpkPjUdxCountCfmInfo)
+
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->transId, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->numRb, mBuf);
+   for (i=0; i<param->numRb; i++) {
+      CMCHKUNPK(cmUnpkPjUdxCountInfo, &param->countInfo[i], mBuf);
+   }
+   CMCHKUNPK(SUnpkS16, &param->status, mBuf);
+   CMCHKUNPK(SUnpkS16, &param->reason, mBuf);
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxSduStaReqInfo
+*
+*
+*     Desc : *  PDCP SDU Status Request Information from RRC - Used for reestablishment
+ *  during handover.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxSduStaReqInfo
+(
+UdxSduStaReqInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxSduStaReqInfo(param, mBuf)
+UdxSduStaReqInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxSduStaReqInfo)
+
+   CMCHKPK(SPkU32, param->transId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxSduStaReqInfo
+*
+*
+*     Desc : *  PDCP SDU Status Request Information from RRC - Used for reestablishment
+ *  during handover.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxSduStaReqInfo
+(
+UdxSduStaReqInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxSduStaReqInfo(param, mBuf)
+UdxSduStaReqInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxSduStaReqInfo)
+
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->transId, mBuf);
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxDlSduStaInfo
+*
+*
+*     Desc : *  PDCP DL SDU Status Information for a DRB mapped to RLC AM.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxDlSduStaInfo
+(
+UdxDlSduStaInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxDlSduStaInfo(param, mBuf)
+UdxDlSduStaInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxDlSduStaInfo)
+                                 
+   CMCHKPK(cmPkBool, param->hoPres, mBuf);  
+   CMCHKPK(SPkU32, param->count, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxDlSduStaInfo
+*
+*
+*     Desc : *  PDCP DL SDU Status Information for a DRB mapped to RLC AM.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxDlSduStaInfo
+(
+UdxDlSduStaInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxDlSduStaInfo(param, mBuf)
+UdxDlSduStaInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxDlSduStaInfo)
+   
+   CMCHKUNPK(cmUnpkBool, &param->hoPres, mBuf); 
+   CMCHKUNPK(SUnpkU32, &param->count, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxSduStaInfo
+*
+*
+*     Desc : *  PDCP SDU Status Information for a DRB mapped to RLC AM.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxSduStaInfo
+(
+Pst *pst,
+UdxSduStaInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxSduStaInfo(pst, param, mBuf)
+Pst *pst;
+UdxSduStaInfo *param;
+Buffer *mBuf;
+#endif
+{
+   TRC3(cmPkPjUdxSduStaInfo)
+
+   CMCHKPK(cmPkPjUdxDlSduStaInfo, &param->dlSduStaInfo, mBuf);
+   CMCHKPK(SPkU8, param->dir, mBuf);
+   CMCHKPK(SPkU8, param->rbId, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxSduStaInfo
+*
+*
+*     Desc : *  PDCP SDU Status Information for a DRB mapped to RLC AM.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxSduStaInfo
+(
+Pst *pst,
+UdxSduStaInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxSduStaInfo(pst, param, mBuf)
+Pst *pst;
+UdxSduStaInfo *param;
+Buffer *mBuf;
+#endif
+{
+   TRC3(cmUnpkPjUdxSduStaInfo)
+
+   CMCHKUNPK(SUnpkU8, &param->rbId, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->dir, mBuf);
+
+   CMCHKUNPK(cmUnpkPjUdxDlSduStaInfo, &param->dlSduStaInfo, mBuf);
+   RETVALUE(ROK);
+}
+
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxSduStaCfmInfo
+*
+*
+*     Desc : *  PDCP SDU Status Request Confirmation for an UE.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxSduStaCfmInfo
+(
+Pst *pst,
+UdxSduStaCfmInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxSduStaCfmInfo(pst, param, mBuf)
+Pst *pst;
+UdxSduStaCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+   S32 i;
+
+   TRC3(cmPkPjUdxSduStaCfmInfo)
+
+   CMCHKPK(SPkS16, param->reason, mBuf);
+   CMCHKPK(SPkS16, param->status, mBuf);
+   for (i=param->numRb-1; i >= 0; i--) {
+      if (cmPkPjUdxSduStaInfo(pst, &param->sduStaInfo[i], mBuf) != ROK)
+         RETVALUE(RFAILED);
+   }
+   CMCHKPK(SPkU8, param->numRb, mBuf);
+   CMCHKPK(SPkU32, param->transId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmPkPjUdxDatResumeCfmInfo
+*
+*
+*     Desc : *  PDCP SDU Status Request Confirmation for an UE.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxDatResumeCfmInfo
+(
+Pst *pst,
+UdxDatResumeCfmInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxDatResumeCfmInfo(pst, param, mBuf)
+Pst *pst;
+UdxDatResumeCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmPkPjUdxDatResumeCfmInfo)
+
+   CMCHKPK(SPkS16, param->reason, mBuf);
+   CMCHKPK(SPkS16, param->status, mBuf);
+   CMCHKPK(SPkU32, param->transId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxDatForwardCfmInfo
+(
+Pst *pst,
+UdxDatFwdCfmInfo *param,
+Buffer *mBuf
+ )
+#else
+PUBLIC S16 cmPkPjUdxDatForwardCfmInfo(pst, param, mBuf)
+Pst *pst;
+UdxDatFwdCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+   TRC3(cmPkPjUdxDatForwardCfmInfo)
+
+   CMCHKPK(SPkS16, param->reason, mBuf);
+   CMCHKPK(SPkS16, param->status, mBuf);
+   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
+   RETVALUE(ROK);
+}
+/*
+*
+*    Fun:    cmPkPjUdxDlFdbkPktInfo
+*
+*    Desc:    pack the structure UdxDlFdbPktInfo
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:    None
+*
+*    File:     pj_udx.c
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxDlFdbkPktInfo
+(
+UdxDlFdbkPktInfo  *param,
+Pst            *pst,
+Buffer         *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxDlFdbkPktInfo(param, pst, mBuf)
+UdxDlFdbkPktInfo  *param;
+Pst            *pst;
+Buffer         *mBuf;
+#endif
+{
+   S16 msgLen;
+   TRC3(cmPkPjUdxDlFdbkPktInfo)
+
+   CMCHKPK(SPkU8, param->pdcpId.rbType, mBuf);
+   CMCHKPK(cmPkLteRbId, param->pdcpId.rbId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->pdcpId.ueId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->pdcpId.cellId, mBuf);
+
+   if (SFndLenMsg(param->fbPkt, &msgLen) != ROK)
+      RETVALUE(RFAILED);
+   if (SCatMsg(mBuf, param->fbPkt, M1M2) != ROK)
+      RETVALUE(RFAILED);
+   PJ_FREE_BUF(mBuf);
+   CMCHKPK(SPkS16, msgLen, mBuf);
+
+   RETVALUE(ROK);
+} /* cmPkPjUdxDlFdbkPktInfo */
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxSduStaCfmInfo
+*
+*
+*     Desc : *  PDCP SDU Status Request Confirmation for an UE.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxSduStaCfmInfo
+(
+Pst *pst,
+UdxSduStaCfmInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxSduStaCfmInfo(pst, param, mBuf)
+Pst *pst;
+UdxSduStaCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   S32 i;
+   TRC3(cmUnpkPjUdxSduStaCfmInfo)
+
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->transId, mBuf);
+   CMCHKUNPK(SUnpkU8, &param->numRb, mBuf);
+   for (i=0; i<param->numRb; i++) {
+      if (cmUnpkPjUdxSduStaInfo(pst, &param->sduStaInfo[i], mBuf) != ROK)
+         RETVALUE(RFAILED);
+   }
+   CMCHKUNPK(SUnpkS16, &param->status, mBuf);
+   CMCHKUNPK(SUnpkS16, &param->reason, mBuf);
+   RETVALUE(ROK);
+}
+
+\f
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxDatResumeCfmInfo
+*
+*
+*     Desc : *  PDCP SDU Status Request Confirmation for an UE.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxDatResumeCfmInfo
+(
+Pst *pst,
+UdxDatResumeCfmInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxDatResumeCfmInfo(pst, param, mBuf)
+Pst *pst;
+UdxDatResumeCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxDatResumeCfmInfo)
+
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(SUnpkU32, &param->transId, mBuf);
+   CMCHKUNPK(SUnpkS16, &param->status, mBuf);
+   CMCHKUNPK(SUnpkS16, &param->reason, mBuf);
+   RETVALUE(ROK);
+}
+/***********************************************************
+*
+*     Func : cmUnpkPjUdxDatForwardCfm
+*
+*
+*     Desc : *  PDCP Data Forward Confirmation for an UE.
+*
+*
+*     Ret  : S16
+*
+*     Notes:
+*
+*     File  : 
+*
+**********************************************************/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxDatForwardCfmInfo
+(
+Pst *pst,
+UdxDatFwdCfmInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxDatForwardCfmInfo(pst, param, mBuf)
+Pst *pst;
+UdxDatFwdCfmInfo *param;
+Buffer *mBuf;
+#endif
+{
+
+   TRC3(cmUnpkPjUdxDatForwardCfmInfo)
+
+   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
+   CMCHKUNPK(SUnpkS16, &param->status, mBuf);
+   CMCHKUNPK(SUnpkS16, &param->reason, mBuf);
+   RETVALUE(ROK);
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxUlFdbkPkt
+(
+Pst * pst,
+SpId spId,
+UdxUlFdbkPktInfo *fdbkPktInfo
+)
+#else
+PUBLIC S16 cmPkPjUdxUlFdbkPkt(pst, spId, fdbkPktInfo)
+Pst * pst;
+SpId spId;
+UdxUlFdbkPktInfo *fdbkPktInfo;
+#endif
+{
+   S16 ret;
+   Buffer *mBuf;
+   mBuf = NULLP;
+
+   TRC3(cmPkPjUdxUlFdbkPkt)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX016, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxUlFdbkPktInfo));
+
+      RETVALUE(RFAILED);
+   }
+
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+      case UDX_SEL_LC:
+         {
+            ret = cmPkPjUdxUlFdbkPktInfo( (fdbkPktInfo), pst, mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+            if(ret != ROK)
+            {
+               PJ_FREE_BUF(mBuf);
+               PJ_FREE_BUF(fdbkPktInfo->fbPkt);
+               PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxUlFdbkPktInfo));
+               
+               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                     (ErrVal)EUDXXXX, (ErrVal)ret, "Packing failure");
+               RETVALUE( ret );
+            }
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+            PJ_FREE_BUF(fdbkPktInfo->fbPkt);
+#ifndef XEON_SPECIFIC_CHANGES
+            if (SPutStaticBuffer(pst->region, pst->pool, (Data *)fdbkPktInfo,
+                     sizeof(UdxUlFdbkPktInfo), 0) != ROK)
+#else
+            if (SPutSBuf(pst->region, pst->pool, (Data *)fdbkPktInfo,
+                     sizeof(UdxUlFdbkPktInfo)) != ROK)
+#endif
+            {
+               PJ_FREE_BUF(mBuf);
+               RETVALUE(RFAILED);
+            }
+
+            break;
+         }
+       case UDX_SEL_LWLC:
+         {
+            CMCHKPKLOG(cmPkPtr,(PTR)fdbkPktInfo,mBuf,EUDXXXX,pst);
+            break;
+         }
+#endif /* LCUDX */
+   }
+   
+   CMCHKPKLOG(SPkS16, spId, mBuf, EUDXXXX, pst);
+   pst->event = (Event) EVTUDXULROHCFDB;
+
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxDlFdbkPkt
+(
+Pst * pst,
+SpId spId,
+UdxDlFdbkPktInfo *fdbkPktInfo
+)
+#else
+PUBLIC S16 cmPkPjUdxDlFdbkPkt(pst, spId, fdbkPktInfo)
+Pst * pst;
+SpId spId;
+UdxDlFdbkPktInfo *fdbkPktInfo;
+#endif
+{
+   S16 ret;
+   Buffer *mBuf;
+   mBuf = NULLP;
+
+   TRC3(cmPkPjUdxDlFdbkPkt)
+
+   if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX016, (ErrVal)0, "Packing failed");
+#endif
+      PJ_FREE_BUF(mBuf);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxUlFdbkPktInfo));
+
+      RETVALUE(RFAILED);
+   }
+
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+      case UDX_SEL_LC:
+         {
+            ret = cmPkPjUdxDlFdbkPktInfo( (fdbkPktInfo), pst, mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+            if(ret != ROK)
+            {
+               PJ_FREE_BUF(mBuf);
+               PJ_FREE_BUF(fdbkPktInfo->fbPkt);
+               PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxUlFdbkPktInfo));
+               
+               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                     (ErrVal)EUDXXXX, (ErrVal)ret, "Packing failure");
+               RETVALUE( ret );
+            }
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+            PJ_FREE_BUF(fdbkPktInfo->fbPkt);
+#ifndef XEON_SPECIFIC_CHANGES
+            if (SPutStaticBuffer(pst->region, pst->pool, (Data *)fdbkPktInfo,
+                     sizeof(UdxDlFdbkPktInfo), 0) != ROK)
+#else
+            if (SPutSBuf(pst->region, pst->pool, (Data *)fdbkPktInfo,
+                     sizeof(UdxDlFdbkPktInfo)) != ROK)
+#endif
+            {
+               PJ_FREE_BUF(mBuf);
+               RETVALUE(RFAILED);
+            }
+
+            break;
+         }
+       case UDX_SEL_LWLC:
+         {
+            CMCHKPKLOG(cmPkPtr,(PTR)fdbkPktInfo,mBuf,EUDXXXX,pst);
+            break;
+         }
+#endif /* LCUDX */
+   }
+   
+   CMCHKPKLOG(SPkS16, spId, mBuf, EUDXXXX, pst);
+   pst->event = (Event) EVTUDXDLROHCFDB;
+
+   RETVALUE(SPstTsk(pst,mBuf));
+}
+
+/*
+*
+*    Fun:    cmPkPjUdxUlFdbkPktInfo
+*
+*    Desc:    pack the structure UdxUlFdbPktInfo
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:    None
+*
+*    File:     pj_udx.c
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxUlFdbkPktInfo
+(
+UdxUlFdbkPktInfo  *param,
+Pst            *pst,
+Buffer         *mBuf
+)
+#else
+PUBLIC S16 cmPkPjUdxUlFdbkPktInfo(param, pst, mBuf)
+UdxUlFdbkPktInfo  *param;
+Pst            *pst;
+Buffer         *mBuf;
+#endif
+{
+   S16 msgLen;
+   TRC3(cmPkPjUdxUlFdbkPktInfo)
+
+   CMCHKPK(SPkU8, param->pdcpId.rbType, mBuf);
+   CMCHKPK(cmPkLteRbId, param->pdcpId.rbId, mBuf);
+   CMCHKPK(cmPkLteRnti, param->pdcpId.ueId, mBuf);
+   CMCHKPK(cmPkLteCellId, param->pdcpId.cellId, mBuf);
+
+   if (SFndLenMsg(param->fbPkt, &msgLen) != ROK)
+      RETVALUE(RFAILED);
+   if (SCatMsg(mBuf, param->fbPkt, M1M2) != ROK)
+      RETVALUE(RFAILED);
+   PJ_FREE_BUF(param->fbPkt);
+   CMCHKPK(SPkS16, msgLen, mBuf);
+
+   RETVALUE(ROK);
+} /* cmPkPjUdxUlFdbkPktInfo */
+
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxDlFdbkPkt
+(
+UdxDlFdbkPkt func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxDlFdbkPkt(func, pst, mBuf)
+UdxDlFdbkPkt func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   S16   ret1;
+   SpId  spId;
+   UdxDlFdbkPktInfo *fdbkPkt;
+
+   TRC3(cmUnpkPjUdxDlFdbkPkt)
+   
+   if (SUnpkS16(&spId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX021, (ErrVal)0, "Unpacking failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+       case UDX_SEL_LC:
+       {        
+          if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&fdbkPkt,\
+                      sizeof(UdxDlFdbkPktInfo))) != ROK)
+          {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+              SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                    __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                    (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+
+              PJ_FREE_BUF(mBuf);
+             RETVALUE(ret1);
+          }
+
+          if (cmUnpkPjUdxDlFdbkPktInfo(pst, fdbkPkt, mBuf) != ROK) 
+          {
+             PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPkt, sizeof(UdxDlFdbkPktInfo));
+             PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+             SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                (ErrVal)EUDX023, (ErrVal)0, "Unpacking failed");
+#endif
+             RETVALUE(RFAILED);
+          }
+
+          break;
+       }
+
+       case UDX_SEL_LWLC:
+       {
+          CMCHKUNPK(cmUnpkPtr,(PTR *) &fdbkPkt, mBuf);
+          break;
+       }
+#endif /* LCUDX */
+   }
+
+   PJ_FREE_BUF(mBuf);
+
+   RETVALUE((*func)(pst, spId, fdbkPkt));  
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxDlFdbPktInfo
+(
+Pst *pst,
+UdxDlFdbkPktInfo *param,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxDlFdbPktInfo(pst, param, mBuf)
+Pst *pst;
+UdxDlFdbkPktInfo *param;
+Buffer *mBuf;
+#endif
+{
+   MsgLen msgLen=0;
+   MsgLen totalMsgLen;
+
+   TRC3(cmUnpkPjUdxDlFdbPktInfo);
+
+   CMCHKUNPK(SUnpkU8, &param->pdcpId.rbType, mBuf);
+   CMCHKUNPK(cmUnpkLteRbId, &param->pdcpId.rbId, mBuf);
+   CMCHKUNPK(cmUnpkLteRnti, &param->pdcpId.ueId, mBuf);
+   CMCHKUNPK(cmUnpkLteCellId, &param->pdcpId.cellId, mBuf);
+
+   if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
+      RETVALUE(RFAILED);
+
+   if (SSegMsg(mBuf, totalMsgLen-msgLen, &param->fbPkt) != ROK)
+      RETVALUE(RFAILED);   
+
+   RETVALUE(ROK);
+}
+
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxUlStaRep
+(
+UdxUlStaRep func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxUlStaRep(func, pst, mBuf)
+UdxUlStaRep func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   S16   ret1;
+   SpId  spId;
+   UdxUlStaRepInfo *staRep;
+   
+   TRC3(cmUnpkPjUdxUlStaRep)
+
+   if (SUnpkS16(&spId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX021, (ErrVal)0, "Unpacking failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+
+    switch(pst->selector)
+    {
+#ifdef LCUDX
+       case UDX_SEL_LC:
+       {
+          if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&staRep,\
+                      sizeof(UdxUlStaRepInfo))) != ROK)
+          {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+              SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                    __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                    (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+
+              PJ_FREE_BUF(mBuf);
+             RETVALUE(ret1);
+          }
+
+          if (cmUnpkPjUdxUlStaRepInfo(pst, staRep, mBuf) != ROK) 
+          {
+             PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxUlStaRepInfo));
+             PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+             SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                (ErrVal)EUDX023, (ErrVal)0, "Unpacking failed");
+#endif
+             RETVALUE(RFAILED);
+          }
+
+          break;
+       }
+
+       case UDX_SEL_LWLC:
+       {
+          CMCHKUNPK(cmUnpkPtr,(PTR *) &staRep, mBuf);
+          break;
+       }
+#endif /* LCUDX */
+   }
+
+    PJ_FREE_BUF(mBuf);
+
+   RETVALUE((*func)(pst, spId, staRep));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxDlStaRep
+(
+UdxDlStaRep func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxDlStaRep(func, pst, mBuf)
+UdxDlStaRep func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   S16   ret1;
+   SpId  spId;
+   UdxDlStaRepInfo *staRep;
+   
+   TRC3(cmUnpkPjUdxDlStaRep)
+
+   if (SUnpkS16(&spId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX021, (ErrVal)0, "Unpacking failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+
+    switch(pst->selector)
+    {
+#ifdef LCUDX
+       case UDX_SEL_LC:
+       {
+          if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&staRep,\
+                      sizeof(UdxDlStaRepInfo))) != ROK)
+          {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+              SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                    __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                    (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+
+              PJ_FREE_BUF(mBuf);
+             RETVALUE(ret1);
+          }
+
+          if (cmUnpkPjUdxDlStaRepInfo(pst, staRep, mBuf) != ROK) 
+          {
+             PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo));
+             PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+             SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                (ErrVal)EUDX023, (ErrVal)0, "Unpacking failed");
+#endif
+             RETVALUE(RFAILED);
+          }
+
+          break;
+       }
+
+       case UDX_SEL_LWLC:
+       {
+          CMCHKUNPK(cmUnpkPtr,(PTR *) &staRep, mBuf);
+          break;
+       }
+#endif /* LCUDX */
+   }
+
+    PJ_FREE_BUF(mBuf);
+
+   RETVALUE((*func)(pst, spId, staRep));
+}
+
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxUlFdbkPkt
+(
+UdxUlFdbkPkt func,
+Pst *pst,
+Buffer *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxUlFdbkPkt(func, pst, mBuf)
+UdxUlFdbkPkt func;
+Pst *pst;
+Buffer *mBuf;
+#endif
+{
+   S16   ret1;
+   SpId  spId;
+   UdxUlFdbkPktInfo *fdbkPkt;
+
+   TRC3(cmUnpkPjUdxUlFdbkPkt)
+   
+   if (SUnpkS16(&spId, mBuf) != ROK) {
+      PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+         (ErrVal)EUDX021, (ErrVal)0, "Unpacking failed");
+#endif
+      RETVALUE(RFAILED);
+   }
+
+   switch(pst->selector)
+   {
+#ifdef LCUDX
+       case UDX_SEL_LC:
+       {        
+          if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&fdbkPkt,\
+                      sizeof(UdxUlFdbkPktInfo))) != ROK)
+          {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+              SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                    __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                    (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed");
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+
+              PJ_FREE_BUF(mBuf);
+             RETVALUE(ret1);
+          }
+
+          if (cmUnpkPjUdxUlFdbkPktInfo(pst, fdbkPkt, mBuf) != ROK) 
+          {
+             PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPkt, sizeof(UdxUlFdbkPktInfo));
+             PJ_FREE_BUF(mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+             SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+                (ErrVal)EUDX023, (ErrVal)0, "Unpacking failed");
+#endif
+             RETVALUE(RFAILED);
+          }
+
+          break;
+       }
+
+       case UDX_SEL_LWLC:
+       {
+          CMCHKUNPK(cmUnpkPtr,(PTR *) &fdbkPkt, mBuf);
+          break;
+       }
+#endif /* LCUDX */
+   }
+
+   PJ_FREE_BUF(mBuf);
+
+   RETVALUE((*func)(pst, spId, fdbkPkt));  
+}
+
+#ifdef LTE_L2_MEAS
+/*
+*
+*    Fun:    cmPkPjUdxL2MeasReq
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:  None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxL2MeasReq
+(
+Pst               *pst,
+PjL2MeasReqEvt    *measReqEvt 
+)
+#else
+PUBLIC S16 cmPkPjUdxL2MeasReq(pst, measReqEvt)
+Pst               *pst;
+PjL2MeasReqEvt    *measReqEvt; 
+#endif
+{
+    S16    ret1;
+    Buffer *mBuf = NULLP;
+
+    TRC3(cmPkPjUdxL2MeasReq)
+
+    if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK)
+    {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+       if(ret1 != ROK)
+       {
+          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+               (ErrVal)EUDXXXX, (ErrVal)0, "SGetMsg() failed");
+       }
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+
+       RETVALUE(ret1);
+    }
+    
+    switch (pst->selector)
+    {
+       case UDX_SEL_LC:
+       {
+       }
+       case UDX_SEL_LWLC:
+       {
+         CMCHKPK(cmPkPtr,(PTR) measReqEvt, mBuf);
+         break;
+       }
+    }
+    pst->event = (Event) PJ_UDX_EVT_L2MEAS_REQ;
+
+    RETVALUE(SPstTsk(pst, mBuf));
+
+} /* cmPkPjUdxStaUpdReq */
+
+/*
+*
+*    Fun:    cmPkPjUdxL2MeasSendReq
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:  None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxL2MeasSendReq
+(
+Pst              *pst,
+U8               measType
+)
+#else
+PUBLIC S16 cmPkPjUdxL2MeasSendReq(pst, measReqEvt)
+Pst               *pst;
+U8                measType
+#endif
+{
+    S16    ret1;
+    Buffer *mBuf = NULLP;
+
+    TRC3(cmPkPjUdxL2MeasSendReq)
+
+    if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK)
+    {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+       if(ret1 != ROK)
+       {
+          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+               (ErrVal)EUDXXXX, (ErrVal)0, "SGetMsg() failed");
+       }
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+
+       RETVALUE(ret1);
+    }
+    
+    switch (pst->selector)
+    {
+       case UDX_SEL_LC:
+       {
+       }
+       case UDX_SEL_LWLC:
+       {
+          CMCHKPKLOG(SPkU8, measType, mBuf, EUDXXXX, pst);
+          break;
+       }
+    }
+    pst->event = (Event) PJ_UDX_EVT_L2MEAS_SEND_REQ;
+
+    RETVALUE(SPstTsk(pst, mBuf));
+
+} 
+
+/*
+*
+*    Fun:    cmPkPjUdxL2MeasStopReq
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:  None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxL2MeasStopReq
+(
+Pst              *pst,
+U8               measType
+)
+#else
+PUBLIC S16 cmPkPjUdxL2MeasStopReq(pst, measType)
+Pst               *pst;
+U8                measType
+#endif
+{
+    S16    ret1;
+    Buffer *mBuf = NULLP;
+
+    TRC3(cmPkPjUdxL2MeasStopReq)
+
+    if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK)
+    {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+       if(ret1 != ROK)
+       {
+          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+               (ErrVal)EUDXXXX, (ErrVal)0, "SGetMsg() failed");
+       }
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+
+       RETVALUE(ret1);
+    }
+    
+    switch (pst->selector)
+    {
+       case UDX_SEL_LC:
+       {
+       }
+       case UDX_SEL_LWLC:
+       {
+          CMCHKPKLOG(SPkU8, measType, mBuf, EUDXXXX, pst);
+          break;
+       }
+    }
+    pst->event = (Event) PJ_UDX_EVT_L2MEAS_STOP_REQ;
+
+    RETVALUE(SPstTsk(pst, mBuf));
+
+} 
+
+/*
+
+*    Fun:    cmUnpkPjUdxL2MeasReq
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:  None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxL2MeasReq
+(
+UdxL2MeasReq     func,
+Pst              *pst,
+Buffer           *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxL2MeasReq(func, pst, mBuf)
+UdxL2MeasReq     func;
+Pst              *pst;
+Buffer           *mBuf;
+#endif
+{
+   // S16    ret1;
+    PjL2MeasReqEvt    *measReqEvt; 
+
+    TRC3(cmUnpkPjUdxL2MeasReq)
+
+    switch (pst->selector)
+    {
+       case UDX_SEL_LC:
+       {
+       }
+       case UDX_SEL_LWLC:
+       {
+         CMCHKUNPK(cmUnpkPtr, (PTR *)&measReqEvt,mBuf);
+         break;
+       }
+    }
+
+    SPutMsg(mBuf);
+
+    RETVALUE((*func)(pst, measReqEvt));
+} /* cmUnpkPjUdxL2MeasReq */
+
+/*
+*
+*    Fun:    cmUnpkPjUdxL2MeasSendReq
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:  None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxL2MeasSendReq
+(
+UdxL2MeasSendReq     func,
+Pst                  *pst,
+Buffer               *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxL2MeasSendReq(func, pst, mBuf)
+UdxL2MeasSendReq     func;
+Pst                  *pst;
+Buffer               *mBuf;
+#endif
+{
+    //S16    ret1;
+    U8     measType;
+
+    TRC3(cmUnpkPjUdxL2MeasSendReq)
+
+    switch (pst->selector)
+    {
+       case UDX_SEL_LC:
+       {
+       }
+       case UDX_SEL_LWLC:
+       {
+          CMCHKUNPK(SUnpkU8, &measType, mBuf);
+         break;
+       }
+    }
+
+    SPutMsg(mBuf);
+
+    RETVALUE((*func)(pst, measType));
+} /* cmUnpkPjUdxL2MeasReq */
+
+/*
+*
+*    Fun:    cmUnpkPjUdxL2MeasStopReq
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:  None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxL2MeasStopReq
+(
+UdxL2MeasStopReq     func,
+Pst                  *pst,
+Buffer               *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxL2MeasStopReq(func, pst, mBuf)
+UdxL2MeasStopReq     func;
+Pst                  *pst;
+Buffer               *mBuf;
+#endif
+{
+    U8     measType;
+
+    TRC3(cmUnpkPjUdxL2MeasStopReq)
+
+    switch (pst->selector)
+    {
+       case UDX_SEL_LC:
+       {
+       }
+       case UDX_SEL_LWLC:
+       {
+          CMCHKUNPK(SUnpkU8, &measType, mBuf);
+         break;
+       }
+    }
+
+    SPutMsg(mBuf);
+
+    RETVALUE((*func)(pst, measType));
+} /* cmUnpkPjUdxL2MeasStopReq */
+#endif
+
+/*
+*
+*    Fun:    cmPkPjUdxDatResumeReq
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:  None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxDatResumeReq
+(
+Pst           *pst,
+UdxDatResumeInfo  *udxDatResumeInfo 
+)
+#else
+PUBLIC S16 cmPkPjUdxDatResumeReq(pst, cellId, ueId)
+Pst           *pst;
+UdxDatResumeInfo  *udxDatResumeInfo;
+#endif
+{
+    S16    ret1;
+    Buffer *mBuf = NULLP;
+
+    TRC3(cmPkPjUdxDatResume)
+
+    if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK)
+    {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+       if(ret1 != ROK)
+       {
+          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+               (ErrVal)EUDXXXX, (ErrVal)0, "SGetMsg() failed");
+       }
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, (Data *)udxDatResumeInfo,sizeof(UdxDatResumeInfo));
+       RETVALUE(ret1);
+    }
+    
+    switch (pst->selector)
+    {
+       case UDX_SEL_LC:
+       {
+       }
+       case UDX_SEL_LWLC:
+       {
+          CMCHKPKLOG(cmPkPtr,(PTR)udxDatResumeInfo,mBuf,EUDXXXX,pst);
+          break;
+       }
+    }
+   pst->event = (Event) EVTUDXDATRESUME;
+
+    RETVALUE(SPstTsk(pst, mBuf));
+
+} /* cmPkPjUdxDatResumeReq */
+
+/*
+*
+*    Fun:    cmUnpkPjUdxDatResumeReq
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:  None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxDatResumeReq
+(
+UdxDatResumeReq  func,
+Pst              *pst,
+Buffer           *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxDatResumeReq(func, pst, mBuf)
+UdxDatResumeReq  func;
+Pst              *pst;
+Buffer           *mBuf;
+#endif
+{
+   UdxDatResumeInfo  *datResumeInfo;
+
+    TRC3(cmUnpkPjUdxDatResumeReq)
+
+    switch (pst->selector)
+    {
+       case UDX_SEL_LC:
+       {
+       }
+       case UDX_SEL_LWLC:
+       {
+          CMCHKUNPK(cmUnpkPtr,(PTR *) &datResumeInfo, mBuf);
+         break;
+       }
+    }
+
+    SPutMsg(mBuf);
+
+    RETVALUE((*func)(pst, datResumeInfo));
+} /* cmUnpkPjUdxDatResumeReq */
+
+/*
+*
+*    Fun:    cmPkPjUdxDatForwardReq
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:  None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmPkPjUdxDatForwardReq
+(
+Pst           *pst,
+UdxDatForwardInfo   *datFwdInfo
+)
+#else
+PUBLIC S16 cmPkPjUdxDatForwardReq(pst, datFwdInfo)
+Pst           *pst;
+UdxDatForwardInfo   *datFwdInfo;
+#endif
+{
+    S16    ret1;
+    Buffer *mBuf = NULLP;
+
+    TRC3(cmPkPjUdxDatForwardReq)
+
+    RLOG0(L_DEBUG,"Packing UdxDatForwadReq");
+    if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK)
+    {
+#if (ERRCLASS & ERRCLS_ADD_RES)
+       if(ret1 != ROK)
+       {
+          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
+                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
+               (ErrVal)EUDXXXX, (ErrVal)0, "SGetMsg() failed");
+       }
+#endif /*  ERRCLASS & ERRCLS_ADD_RES  */
+
+       RETVALUE(ret1);
+    }
+    
+    switch (pst->selector)
+    {
+       case UDX_SEL_LC:
+       {
+       }
+       case UDX_SEL_LWLC:
+       {
+          CMCHKPKLOG(cmPkPtr,(PTR)datFwdInfo,mBuf,EUDXXXX,pst);
+          break;
+       }
+    }
+   pst->event = (Event) EVTUDXDATFRWD;
+
+    RETVALUE(SPstTsk(pst, mBuf));
+
+} /* cmPkPjUdxDatForwardReq */
+
+/*
+*
+*    Fun:    cmUnpkPjUdxDatForwardReq
+*
+*    Ret:    ROK  -ok
+*
+*    Notes:  None
+*
+*
+*/
+#ifdef ANSI
+PUBLIC S16 cmUnpkPjUdxDatForwardReq
+(
+UdxDatForwardReq  func,
+Pst              *pst,
+Buffer           *mBuf
+)
+#else
+PUBLIC S16 cmUnpkPjUdxDatForwardReq(func, pst, mBuf)
+UdxDatForwardReq  func;
+Pst              *pst;
+Buffer           *mBuf;
+#endif
+{
+   UdxDatForwardInfo   *datFwdInfo;
+
+    TRC3(cmUnpkPjUdxDatForwardReq)
+
+    RLOG0(L_DEBUG,"Unpacking UdxDatForwadReq");
+    switch (pst->selector)
+    {
+       case UDX_SEL_LC:
+       {
+       }
+       case UDX_SEL_LWLC:
+       {
+          CMCHKUNPK(cmUnpkPtr,(PTR *) &datFwdInfo, mBuf);
+         break;
+       }
+    }
+
+    SPutMsg(mBuf);
+
+    RETVALUE((*func)(pst, datFwdInfo));
+} /* cmUnpkPjUdxDatForwardReq */
+#endif /* end of #if(defined(LCUDX) || defined(LWLCUDX)) */
+
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_udx.h b/src/5gnrpdcp/pj_udx.h
new file mode 100755 (executable)
index 0000000..fe54ddc
--- /dev/null
@@ -0,0 +1,292 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE PDCP Interface  
+    
+        Type:    C include file
+  
+        Desc:    This file contains the defines required by PDCP user
+        File:    pj_udx.h
+  
+*********************************************************************21*/
+#ifndef __UDX_H__
+#define __UDX_H__
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif  /*for extern "C"*/
+
+/**
+ * @file 
+ * @brief Macro for UDX Interface 
+ */
+
+#define UDX_SEL_LC           0   /* UDX loose couple selector */
+#define UDX_SEL_LWLC         1
+#define PJ_MAX_UDX           3
+
+#define UDX_7BIT_SN_SIZE     7               /*!< Sequence length is 7-bit */
+#define UDX_12BIT_SN_SIZE    12              /*!< Sequence length is 12-bit */
+#define UDX_MAX_CFG    10                    /*!< Maximum PDCP entity to be configured */ 
+#define UDX_MAX_DRB    12                    /*!< Maximum DRBs per UE */
+
+/* UDX Configuration Failure Reasons */
+#define UDX_CFG_REAS_NONE                  0  /*!< No Failure */
+#define UDX_CFG_REAS_ENT_CREAT_FAIL        1  /*!< PDCP Entity Creation Failure*/
+#define UDX_CFG_REAS_UE_CREAT_FAIL         2  /*!< UE CB Creation Failure */
+#define UDX_CFG_REAS_INVALID_PDCPID        3  /*!< Invalid PDCP ID */
+#define UDX_CFG_REAS_PDCPID_PRSNT          4  /*!< PDCP ID already present */
+#define UDX_CFG_REAS_INVALID_RLCMODE       5  /*!< Invalid RLC Mode */
+#define UDX_CFG_REAS_PDCPID_UNKWN          6  /*!< PDCP ID Unknown */
+#define UDX_CFG_REAS_UE_UNKWN              7  /*!< UE Cb Unknown */
+#define UDX_CFG_REAS_CIPHER_ALGO_INVALID   8  /*!< Invalid Cipher Algo */
+#define UDX_CFG_REAS_ENT_DEL_FAIL          9  /*!< PDCP Entity Deletion Failure */
+#define UDX_CFG_REAS_UE_DEL_FAIL           10 /*!< UE Cb Deletion Failure */
+#define UDX_CFG_REAS_REEST_FAIL            11 /*!< PDCP Reestablish Failure */
+#define UDX_CFG_REAS_COMP_ALGO_INVALID     12 /*!< Compression Algo not
+                                               supported */
+#define UDX_CFG_REAS_RECFG_FAIL            13 /*!< PDCP Reconfiguration Failed */
+#define UDX_CFG_REAS_INVALID_CFG           14 /*!< Invalid Configuration Type */
+#define UDX_CFG_REAS_SAME_UEID             15 /*!< UE IDs match in ChngUeId 
+                                                   Request*/
+#define UDX_CFG_REAS_SAME_RBID             16 /*!< UE IDs match in ChngUeId 
+                                                   Request */
+#define UDX_CFG_REAS_INVALID_RBID          17 /*!< Invalid RB ID */
+
+#define  UDX_CFG_REAS_INTINIT_FAILED      18 /*!< Integrity Init Failed */
+#define  UDX_CFG_REAS_CCIPHR_FAILED       19 /*!< Control Plane Cihper Init Failed */
+#define  UDX_CFG_REAS_UCIPHR_FAILED       20 /*!< User Plane Cipher Init Failed */
+
+#define  UDX_CFG_REAS_NO_DRBS             21 /*!< No DRBs Present */
+#define  UDX_CFG_REAS_OBD_TIMEOUT         22 /*!< No DRBs Present */
+#define  UDX_CFG_REAS_INVALID_STATE       23 /*!< Invalid state to perform re-establishment */
+
+/* UDX Configuration confirmations */
+#define UDX_CFG_CFM_OK                      1 /*!< Confirm status OK */
+#define UDX_CFG_CFM_NOK                     2 /*!< Confirm status NOK */
+   
+/*Event Code*/
+#define UDX_EVC_RESET_FAILED                1 /*!< Reset Failed */ 
+
+#define EVTUDXBNDREQ         0x20            /*!< Bind Request */
+#define EVTUDXBNDCFM         0x21            /*!< Bind Confirmation */ 
+#define EVTUDXUBNDREQ        0x22            /*!< Unbind Request */
+#define EVTUDXCFGREQ         0x23            /*!< Config Request */
+#define EVTUDXCFGCFM         0x24            /*!< Config Confirmation */
+#define EVTUDXUEIDCHGREQ     0x25            /*!< UE ID Change Request */ 
+#define EVTUDXUEIDCHGCFM     0x26            /*!< UE ID Change Confirmation */
+#define EVTUDXSECCFGREQ      0x27            /*!< Security Config Request */
+#define EVTUDXSECCFGCFM      0x28            /*!< Security Config Confirm */
+#define EVTUDXREESTREQ       0x29            /*!< Count C Request */
+#define EVTUDXREESTCFM       0x2A            /*!< Count C Confirm */
+#define EVTUDXCOUNTREQ       0x2B            /*!< Count C Request */
+#define EVTUDXCOUNTCFM       0x2C            /*!< Count C Confirm */
+#define EVTUDXSDUSTAREQ      0x2D            /*!< SDU Status Request */
+#define EVTUDXSDUSTACFM      0x2E            /*!< SDU Status Confirm */
+#define EVTUDXREESTTRIG      0x2F            /*!< Reestablishment trigger */
+#define EVTUDXULSTAREP       0x30            /*!< UL PDCP Status Report */
+#define EVTUDXDLSTAREP       0x31            /*!< DL PDCP Status Report */
+#define EVTUDXULROHCFDB      0x32            /*!< ROHC FEEDBACK PKT INFO */
+#define EVTUDXDLROHCFDB      0x33            /*!< ROHC FEEDBACK PKT INFO */
+#define EVTUDXDATRESUME      0x34            /*!< Data Resume */
+#define EVTUDXDATFRWD        0x35            /*!< Data Forwarding */
+#define EVTUDXDATRESUMECFM   0x36            /*!< Dats Resume Confirm */
+#define EVTUDXDATFRWDCFM     0x37            /*!< Dats Forwarding Confirm */
+#define PJ_UDX_EVT_L2MEAS_REQ 0x38           /*!< L2 measurement request */
+#define PJ_UDX_EVT_L2MEAS_SEND_REQ 0x39      /*!< L2 measurement send request */
+#define PJ_UDX_EVT_L2MEAS_STOP_REQ 0x40      /*!< L2 measurement stop request */
+
+#define UDX_CIPHER_KEY_LEN       16          /*!< Ciphering key length */
+#define UDX_INTG_KEY_LEN         16          /*!< Integrity key length */
+#define UDX_MAX_ROHC_PROF_LIST   9           /*!< ROHC profile list */
+#define UDX_MAX_CFM              10          /*!< Maximum number of confirm */ 
+
+#define UDX_CFG_ADD            0x01          /*!< Configure new PDCP entity
+                                               in the requested UE */
+#define UDX_CFG_MODIFY         0x02          /*!< Reconfigure PDCP entity
+                                               in the requested UE */
+#define UDX_CFG_DELETE         0x03          /*!< Delete PDCP entity
+                                               in the requested UE */
+#define UDX_CFG_REESTABLISH    0x04          /*!< Reestablish PDCP entity
+                                               in the requested UE */
+#define UDX_CFG_DELETE_UE      0x05          /*!< Delete UE in PDCP */
+
+
+#define UDX_SEC_INTG_INFO      0x01          /*!< Integrity information */
+#define UDX_SEC_CIPHER_INFO    0x02          /*!< Ciphering information */
+
+#define UDX_SEC_ALG_NULL       0x01          /*!< NULL algorithm */
+#define UDX_SEC_ALG_SNOW3G     0x02          /*!< Snow 3G algorithm */
+#define UDX_SEC_ALG_AES        0x03          /*!< AES algorithm */
+
+
+
+/* Defines which is used in ModCfg to set the bitflag */
+#define UDX_RECFG_DISRQD  0x01               /*!< Discard Required is present*/
+#define UDX_RECFG_CFMREQ  0x02               /*!< Confirm Required is present */
+
+/* Flags will be used to fill the Hand off information */
+#define UDX_HO_NOT_PRSNT  0       /*!< Hand of Info is not present */
+#define UDX_HO_UL         1       /*!< Uplink count present */
+#define UDX_HO_DL         2       /*!< Downlink count present */
+
+/* cpj_h_001.main_2 added support for L2 Measurement */   
+#ifdef LTE_L2_MEAS
+#define UDX_MAX_QCI           10
+#endif
+
+/* Error Codes */
+#define EUDXXXX              0   
+#define ERRUDX               0
+
+#define EUDX001         (ERRUDX + 1)
+#define EUDX002         (ERRUDX + 2)
+#define EUDX003         (ERRUDX + 3)
+#define EUDX004         (ERRUDX + 4)
+#define EUDX005         (ERRUDX + 5)
+#define EUDX006         (ERRUDX + 6)
+#define EUDX007         (ERRUDX + 7)
+#define EUDX008         (ERRUDX + 8)
+#define EUDX009         (ERRUDX + 9)
+#define EUDX010         (ERRUDX + 10)
+#define EUDX011         (ERRUDX + 11)
+#define EUDX012         (ERRUDX + 12)
+#define EUDX013         (ERRUDX + 13)
+#define EUDX014         (ERRUDX + 14)
+#define EUDX015         (ERRUDX + 15)
+#define EUDX016         (ERRUDX + 16)
+#define EUDX017         (ERRUDX + 17)
+#define EUDX018         (ERRUDX + 18)
+#define EUDX019         (ERRUDX + 19)
+#define EUDX020         (ERRUDX + 20)
+#define EUDX021         (ERRUDX + 21)
+#define EUDX022         (ERRUDX + 22)
+#define EUDX023         (ERRUDX + 23)
+#define EUDX024         (ERRUDX + 24)
+#define EUDX025         (ERRUDX + 25)
+#define EUDX026         (ERRUDX + 26)
+#define EUDX027         (ERRUDX + 27)
+#define EUDX028         (ERRUDX + 28)
+#define EUDX029         (ERRUDX + 29)
+#define EUDX030         (ERRUDX + 30)
+#define EUDX031         (ERRUDX + 31)
+#define EUDX032         (ERRUDX + 32)
+#define EUDX033         (ERRUDX + 33)
+#define EUDX034         (ERRUDX + 34)
+#define EUDX035         (ERRUDX + 35)
+#define EUDX036         (ERRUDX + 36)
+#define EUDX037         (ERRUDX + 37)
+#define EUDX038         (ERRUDX + 38)
+#define EUDX039         (ERRUDX + 39)
+#define EUDX040         (ERRUDX + 40)
+#define EUDX041         (ERRUDX + 41)
+#define EUDX042         (ERRUDX + 42)
+#define EUDX043         (ERRUDX + 43)
+#define EUDX044         (ERRUDX + 44)
+#define EUDX045         (ERRUDX + 45)
+#define EUDX046         (ERRUDX + 46)
+#define EUDX047         (ERRUDX + 47)
+#define EUDX048         (ERRUDX + 48)
+#define EUDX049         (ERRUDX + 49)
+#define EUDX050         (ERRUDX + 50)
+#define EUDX051         (ERRUDX + 51)
+#define EUDX052         (ERRUDX + 52)
+#define EUDX053         (ERRUDX + 53)
+#define EUDX054         (ERRUDX + 54)
+#define EUDX055         (ERRUDX + 55)
+#define EUDX056         (ERRUDX + 56)
+#define EUDX057         (ERRUDX + 57)
+#define EUDX058         (ERRUDX + 58)
+#define EUDX059         (ERRUDX + 59)
+#define EUDX060         (ERRUDX + 60)
+#define EUDX061         (ERRUDX + 61)
+#define EUDX062         (ERRUDX + 62)
+#define EUDX063         (ERRUDX + 63)
+#define EUDX064         (ERRUDX + 64)
+#define EUDX065         (ERRUDX + 65)
+#define EUDX066         (ERRUDX + 66)
+#define EUDX067         (ERRUDX + 67)
+#define EUDX068         (ERRUDX + 68)
+#define EUDX069         (ERRUDX + 69)
+#define EUDX070         (ERRUDX + 70)
+#define EUDX071         (ERRUDX + 71)
+#define EUDX072         (ERRUDX + 72)
+#define EUDX073         (ERRUDX + 73)
+#define EUDX074         (ERRUDX + 74)
+#define EUDX075         (ERRUDX + 75)
+#define EUDX076         (ERRUDX + 76)
+#define EUDX077         (ERRUDX + 77)
+#define EUDX078         (ERRUDX + 78)
+#define EUDX079         (ERRUDX + 79)
+#define EUDX080         (ERRUDX + 80)
+#define EUDX081         (ERRUDX + 81)
+#define EUDX082         (ERRUDX + 82)
+#define EUDX083         (ERRUDX + 83)
+#define EUDX084         (ERRUDX + 84)
+#define EUDX085         (ERRUDX + 85)
+#define EUDX086         (ERRUDX + 86)
+#define EUDX087         (ERRUDX + 87)
+#define EUDX088         (ERRUDX + 88)
+#define EUDX089         (ERRUDX + 89)
+#define EUDX090         (ERRUDX + 90)
+#define EUDX091         (ERRUDX + 91)
+#define EUDX092         (ERRUDX + 92)
+#define EUDX093         (ERRUDX + 93)
+#define EUDX094         (ERRUDX + 94)
+#define EUDX095         (ERRUDX + 95)
+#define EUDX096         (ERRUDX + 96)
+#define EUDX097         (ERRUDX + 97)
+#define EUDX098         (ERRUDX + 98)
+#define EUDX099         (ERRUDX + 99)
+#define EUDX100         (ERRUDX + 100)
+#define EUDX101         (ERRUDX + 101)
+#define EUDX102         (ERRUDX + 102)
+#define EUDX103         (ERRUDX + 103)
+#define EUDX104         (ERRUDX + 104)
+#define EUDX105         (ERRUDX + 105)
+#define EUDX106         (ERRUDX + 106)
+#define EUDX107         (ERRUDX + 107)
+#define EUDX108         (ERRUDX + 108)
+#define EUDX109         (ERRUDX + 109)
+#define EUDX110         (ERRUDX + 110)
+#define EUDX111         (ERRUDX + 111)
+#define EUDX112         (ERRUDX + 112)
+#define EUDX113         (ERRUDX + 113)
+#define EUDX114         (ERRUDX + 114)
+#define EUDX115         (ERRUDX + 115)
+#define EUDX116         (ERRUDX + 116)
+#define EUDX117         (ERRUDX + 117)
+#define EUDX118         (ERRUDX + 118)
+#define EUDX119         (ERRUDX + 119)
+#define EUDX120         (ERRUDX + 120)
+#define EUDX121         (ERRUDX + 121)
+#define EUDX122         (ERRUDX + 122)
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __UDX_H__ */
+
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_udx.x b/src/5gnrpdcp/pj_udx.x
new file mode 100755 (executable)
index 0000000..b914569
--- /dev/null
@@ -0,0 +1,1503 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE PDCP Interface  
+    
+        Type:    C include file
+  
+        Desc:    This file contains the Data structures for LTE PDCP Interface
+        File:   pj_udx.x
+  
+*********************************************************************21*/
+#ifndef __PJ_UDX_X__
+#define __PJ_UDX_X__
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif  /*for extern "C"*/
+
+/**
+ * @file 
+ * @brief UDX Interface file
+ */
+
+/*************************************************************************
+ *                      START OF STRUCTURES
+ ************************************************************************/
+/**
+ * @brief
+ * Cipher Key type information.
+ */
+typedef U8        UdxCipherKey;
+
+/**
+ * @brief
+ * Integrity Key type information.
+ */
+typedef U8        UdxIntegrityKey;
+
+/**
+  * @brief
+  * RLC Parameter Information in AM mode.
+ */
+typedef struct udxRlcAm
+{
+   Bool           statusRepReqd; /*!< Status report required */
+   U8             pdcpSNSize; /*!< Length of PDCP sequence number */
+}UdxRlcAm;
+
+/**
+ * @brief
+ * RLC Parameter Information in UM mode.
+ */
+typedef struct udxRlcUm
+{
+   U8             pdcpSNSize; /*!< Length of PDCP sequence number */
+}UdxRlcUm;
+
+/**
+ * @brief
+ * Mapped RLC Entity Information in RLC for the PDCP Entity
+ */
+typedef struct udxRlcInfo
+{
+   U8             dir;       /*!< UPLINK/DOWNLINK/BOTH */
+   U8             mode;      /*!< RLC Mode */ 
+   union
+   {
+      UdxRlcAm    rlcAm;     /*!< RLC in AM mode */
+      UdxRlcUm    rlcUm;     /*!< RLC in UM mode */
+   }m;
+}UdxRlcInfo;
+
+
+/**
+ * @brief
+ * Ciphering Information to be configured per UE in PDCP.
+ */
+typedef struct udxCipherInfo         
+{
+   UdxCipherKey   ctrlplnKey[UDX_CIPHER_KEY_LEN];   /*!< Control plane
+                                                        ciphering key */
+   UdxCipherKey   usrplnKey[UDX_CIPHER_KEY_LEN];    /*!< User plane
+                                                        ciphering key */
+   U8             algoType;                         /*!< Algorithm type.
+                                                    Allowed values are:
+                                                    -# UDX_SEC_ALG_NULL 
+                                                    -# UDX_SEC_ALG_SNOW3G
+                                                    -# UDX_SEC_ALG_AES
+                                                    */
+}UdxCipherInfo;
+
+/**
+ * @brief
+ * Integrity protection paramater information. 
+*/
+typedef struct udxIntegInfo
+{
+   U8                algoType;                  /*!< Algorithm type.
+                                                   Allowed values are:
+                                                   -# UDX_SEC_ALG_AES
+                                                   -# UDX_SEC_ALG_SNOW3G
+                                                   */
+   UdxIntegrityKey   intKey[UDX_INTG_KEY_LEN];  /*!< Integrity key */
+} UdxIntegInfo;
+
+/**
+ * @brief
+ * PDCP Security configuration parameter.
+ */
+typedef struct udxSecCfg 
+{
+   Bool           selSecAct;        /*!< Selective security activation flag.
+
+   PDCP applies only Integrity algorithm for the first UL and first DL
+   messages (security activation procedure), applies both Integrity and
+   ciphering for all the other messages (including handover which involves
+   reconfiguration messages). selSecAct enables to identify whether
+   PDCP needs to selectively apply only Integrity for first UL/DL message.
+   */
+   Bool           isHo;             /*!< Will be set true in case of HO > */
+   UdxIntegInfo   integInfo;        /*!< Integrity configuration */
+   UdxCipherInfo  cipherInfo;       /*!< Ciphering configuration */
+} UdxSecCfg;
+
+/**
+ * @brief
+ * ROHC Compression protocol information structure. 
+ */
+typedef struct udxRohcInfo
+{
+   U16            maxCid;                          /*!< Maximum CID */
+   Bool           profLst[UDX_MAX_ROHC_PROF_LIST]; /*!< ROHC profile
+                                                     information */
+}UdxRohcInfo;
+
+/**
+ * @brief
+ * ROHC Configuration information for PDCP entity. 
+ */
+typedef struct udxHdrCompCfg
+{
+   Bool           hdrCompUsed;   /*!< Header Compression Used/Not */
+   UdxRohcInfo    rohcInfo;      /*!< ROHC configuration information */
+}UdxHdrCompCfg;
+
+/**
+ * @brief
+ * Handover Information for RB.
+ */
+typedef struct udxHoInfo
+{
+   U8             isHoPres;   /*!< Last 2bits (from LSB)is used to convey handover information is present or
+                                not. @n Allowed values are:
+                                    -# UDX_HO_NOT_PRSNT  00
+                                    -# UDX_HO_UL         01
+                                    -# UDX_HO_DL         10
+                                    */
+   U8             snLen;         /*!< PDCP-SN length 12/15 bits */
+   U32            dlCount;       /*!< DL COUNT to assign for new SDUs */
+   U32            ulCount;       /*!< UL First Missing SN */
+   U16             numBits;       /*!< Number of bits in UL bitmap */
+   U8             *ulBitMap;     /*!< UL SN bitmap excluding FMS to be used 
+                                      as status report */
+} UdxHoInfo;
+
+/**
+ * @brief
+ * Configuraiton Structure to add an RB.
+ */
+typedef struct udxAddCfgEnt
+{        
+   Bool           discReqd;   /*!< Discard required/not for PDUs
+                                with Integrity Verification failure */
+   Bool           cfmReqd;    /*!< Confirm required/not for SDUs 
+                                received by the peer PDCP entity. */
+  /* cpj_x_001.main_3 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+   U8             qci;        /*!< qCI value Associated with that RB */
+#endif /* LTE_L2_MEAS */
+
+   UdxRlcInfo     rlcInfo;    /*!< Corresponding RLC entity information. */
+   S16            discardTmr; /*!< Discard timer. @n The value for this parameter
+                                is expected in milli seconds. @n Value of infinity
+                                is also allowed and -1 must be passed for
+                                the same. */
+   U16            reOrdTmrVal; /*!< t-Reorder Timer Value in ms */
+   UdxHdrCompCfg  hdrCompCfg; /*!< PDCP compression information */
+}UdxAddCfgEnt;         
+         
+/**
+ * @brief
+ * Configuraiton Structure to modify an RB.
+ */
+typedef struct udxModCfgEnt
+{
+      
+   U8             bitFlag;     /*!< List of Modified Elements 
+                                   Each bit respresents one element  */
+
+   Bool           discReqd;   /*!< Discard required/not for PDUs
+                                with Integrity Verification failure.
+                                bitFlag=0x01 */
+   Bool           cfmReqd;    /*!< Confirm required/not for SDUs 
+                                received by the peer PDCP entity.
+                                bitFlag=0x02 */
+   UdxHdrCompCfg  hdrCompCfg; /*!< PDCP compression information */
+   UdxHoInfo      hoInfo;     /*!< Handover Information */
+   U16            reOrdTmrVal; /*!< t-Reorder Timer Value in ms */
+}UdxModCfgEnt;
+
+
+/**
+ * @brief
+ * Configuration structure for PDCP entity. 
+ */
+typedef struct udxCfgEnt
+{
+   U8             rbId;       /*!< PDCP ID. */
+   U8             cfgType;    /*!< Configuration request type -
+                                -# UDX_CFG_ADD,
+                                -# UDX_CFG_MODIFY,
+                                -# UDX_CFG_DELETE,
+                                -# UDX_REESTABLISH,
+                                -# UDX_CFG_DELETE_UE */
+   U8             rbType;     /*!< RB type.  
+                                -# CM_LTE_SRB
+                                -# CM_LTE_DRB */
+
+   union{
+        UdxAddCfgEnt     addCfg; /*!< Configuration parameters for
+                                    cfgType UDX_CFG_ADD */
+        UdxModCfgEnt     modCfg; /*!< Configuration parameters for
+                                    cfgType UDX_CFG_MODIFY */
+   }m;
+}UdxCfgEnt;
+
+
+
+/**
+ * @brief
+ * PDCP Configuration structure. Parameters are filled by RRC 
+   layer while configuring the PDCP layer.  
+ */
+typedef struct udxCfgReqInfo
+{
+   CmLteRnti      ueId;                 /*!< UE ID */
+   CmLteCellId    cellId;               /*!< Cell ID */
+   U32            transId;              /*!< Transaction ID */
+   U8             numEnt;               /*!< Number of entities to be
+                                          configured in the Config request.*/
+   U8             isHo;
+#ifdef TENB_MULT_CELL_SUPPRT
+   SpId           rlcUlSapId;
+   SpId           rlcDlSapId;
+#endif
+   UdxCfgEnt      cfgEnt[UDX_MAX_CFG];  /*!< Config paramater for
+                                          PDCP entity. */
+}UdxCfgReqInfo;
+
+
+/**
+ * @brief
+ * Status report from PDCP-UL to PDCP-DL during Reestablishment.  
+ */
+typedef struct udxUlStaRepInfo
+{
+   CmLtePdcpId pdcpId;
+   Buffer      *sta;
+}UdxUlStaRepInfo;
+
+/**
+ * @brief
+ * Status report received from peer RLC entity.  
+ */
+typedef struct udxDlStaRepInfo
+{
+   CmLtePdcpId pdcpId;
+   U32         fmc;
+   Buffer      *staPdu;
+}UdxDlStaRepInfo;
+
+
+/**
+ * @brief
+ * ROHC Feedback packet Info from PDCP-UL to PDCP-DL.
+ */
+typedef struct udxUlFdbkPktInfo
+{
+    CmLtePdcpId pdcpId;
+    Buffer      *fbPkt;
+}UdxUlFdbkPktInfo;
+
+/**
+ * @brief
+ * ROHC Feedback packet Info received from UE. Send to PDCP-DL.
+ */
+typedef struct udxDlFdbkPktInfo
+{
+    CmLtePdcpId pdcpId;
+    Buffer      *fbPkt;
+}UdxDlFdbkPktInfo;
+
+
+/**
+ * @brief
+ * PDCP Confirm parameter structure for PDCP entity. 
+ */
+typedef struct udxCfmEnt
+{
+   U8             rbId;       /*!< RB ID */
+   U8             rbType;     /*!< RB Type */
+   Status         status;     /*!< ROK or RFAILED */
+   Reason         reason;     /*!< Reason for failure */
+}UdxCfmEnt;
+
+/**
+ * @brief
+ * PDCP Configuration Confirm structure. 
+ */
+typedef struct udxCfgCfmInfo
+{
+   CmLteRnti      ueId;                   /*!< UE ID */
+   CmLteCellId    cellId;                 /*!< Cell ID */
+   U32            transId;                /*!< Transcation ID */
+   U8             numEnt;                 /*!< Number of entities */
+   UdxCfmEnt      cfmEnt[UDX_MAX_CFM];    /*!< Confirm parameter for
+                                               PDCP entity */
+}UdxCfgCfmInfo;
+
+/**
+ * @brief
+ * Re-estabishment Request structure for SRB1 of an UE.
+ */
+typedef struct udxReEstReqInfo
+{
+   CmLtePdcpId    pdcpId;                          /*!< PDCP ID */
+   U32            transId;                         /*!< Transcation ID */
+   U8             intKey[UDX_INTG_KEY_LEN];         /*!< Integrity key */
+   UdxCipherKey   ctrlplnKey[UDX_CIPHER_KEY_LEN];  /*!< Control plane
+                                                        ciphering key */
+   UdxCipherKey   usrplnKey[UDX_CIPHER_KEY_LEN];   /*!< User plane
+                                                        ciphering key */
+}UdxReEstReqInfo;
+
+/**
+ * @brief
+ * Re-establishment Confirmation structure for an UE.
+ */
+typedef struct udxReEstCfmInfo
+{
+   CmLteRnti      ueId;             /*!< UE ID */
+   CmLteCellId    cellId;           /*!< Cell ID */
+   U32            transId;          /*!< Transcation ID */
+   Status       status;           /*!< Status of reestablishment.
+                                     Allowed values are:
+                                     -# LCM_PRIM_OK
+                                     -# LCM_PRIM_NOK
+                                     */
+}UdxReEstCfmInfo;
+
+/**
+ * @brief
+ * PDCP Security Configuration structure. Parameters are filled by RRC
+ * while configuring the security parameters.
+ */
+typedef struct udxSecCfgReqInfo
+{
+   CmLteRnti      ueId;       /*!< UE ID */
+   CmLteCellId    cellId;     /*!< Cell ID */
+   U32            transId;    /*!< Transcation ID */
+   UdxSecCfg      secCfg;     /*!< Configuration paramater for PDCP entity */
+}UdxSecCfgReqInfo;
+
+/**
+ * @brief
+ * PDCP Security Configuration confirm structure. 
+ */
+typedef struct udxSecCfgCfmInfo
+{
+   CmLteRnti      ueId;       /*!< UE ID */
+   CmLteCellId    cellId;     /*!< Cell ID */
+   U32            transId;    /*!< Transcation ID */
+   Status         status;     /*!< ROK or RFAILED */
+   Reason         reason;     /*!< Reason for failure */
+}UdxSecCfgCfmInfo;
+
+/**
+ *  @brief
+ *  UE ID Information
+ */
+typedef struct udxUeInfo
+{
+   CmLteCellId    cellId;     /*!< Cell ID */
+   CmLteRnti      ueId;       /*!< UE ID */
+}UdxUeInfo;
+
+/**
+ *  @brief
+ *  PDCP Count Request Information from RRC.
+ */
+typedef struct udxCountReqInfo
+{
+   CmLteRnti      ueId;       /*!< UE ID */
+   CmLteCellId    cellId;     /*!< Cell ID */
+   U32            transId;    /*!< Transaction ID */
+} UdxCountReqInfo;
+
+/**
+ *  @brief
+ *  PDCP Count Information for a DRB.
+ */
+typedef struct udxCountInfo
+{
+   U8             rbId;       /*!< RB ID */
+   U8             dir;        /*!< Direction of the RB */
+   U32            ulCount;    /*!< UL Count value */
+   U32            dlCount;    /*!< DL Count value */
+} UdxCountInfo;
+/**
+ *  @brief
+ *  PDCP Count Request Confirmation to RRC.
+ */
+typedef struct udxCountCfmInfo
+{
+   CmLteRnti      ueId;                   /*!< UE ID */
+   CmLteCellId    cellId;                 /*!< Cell ID */
+   U32            transId;                /*!< Transaction ID */
+   U8             numRb;                  /*!< Number of DRBs */
+   UdxCountInfo   countInfo[UDX_MAX_DRB]; /*!< CountInfo of DRBs */
+   Status         status;                 /*!< ROK or RFAILED */
+   Reason         reason;                 /*!< Reason for failure */
+} UdxCountCfmInfo;
+
+/**
+ *  @brief
+ *  PDCP SDU Status Request Information from RRC - Used for reestablishment
+ *  during handover.
+ */
+typedef struct udxSduStaReqInfo
+{
+   CmLteRnti      ueId;       /*!< UE ID */
+   CmLteCellId    cellId;     /*!< Cell ID */
+   U32            transId;    /*!< Transaction ID */
+} UdxSduStaReqInfo;
+
+/**
+ *  @brief
+ *  PDCP DL SDU Status Information for a DRB mapped to RLC AM.
+ */
+typedef struct udxDlSduStaInfo
+{  
+   Bool           hoPres;     
+   U32            count;      /*!< Count with the next SN to be assigned
+                                for a SDU */
+} UdxDlSduStaInfo;
+
+/**
+ *  @brief
+ *  PDCP SDU Status Information for a DRB mapped to RLC AM.
+ */
+typedef struct udxSduStaInfo
+{
+   U8                   rbId;         /*!< RB ID */
+   U8                   dir;          /*!< Direction of the RB */
+   UdxDlSduStaInfo      dlSduStaInfo; /*!< SDU Status Info for DL */ 
+} UdxSduStaInfo;
+
+/**
+ *  @brief
+ *  PDCP SDU Status Request Confirmation for an UE.
+ */
+typedef struct udxSduStaCfmInfo
+{
+   CmLteRnti      ueId;                   /*!< UE ID */
+   CmLteCellId    cellId;                 /*!< Cell ID */
+   U32            transId;                /*!< Transaction ID */
+   U8             numRb;                  /*!< Number of RBs */
+   UdxSduStaInfo  sduStaInfo[UDX_MAX_DRB]; /*!< SDU Status Info of DRBs mapped
+                                             to RLC AM */
+   Status         status;                 /*!< ROK or RFAILED */
+   Reason         reason;                 /*!< Reason for Failure */
+} UdxSduStaCfmInfo;
+
+/**
+ *  @brief
+ *  Data Resume
+ */
+typedef struct udxDatResumeInfo
+{
+   CmLteRnti      ueId;                   /*!< UE ID */
+   CmLteCellId    cellId;                 /*!< Cell ID */
+   U32            transId;                         /*!< Transcation ID */
+} UdxDatResumeInfo;
+
+/**
+ *  @brief
+ *  Data Fwd Cfm
+ */
+typedef struct udxDatFwdCfmInfo
+{
+   CmLteRnti      ueId;                   /*!< UE ID */
+   CmLteCellId    cellId;                 /*!< Cell ID */
+   Status         status;                 /*!< ROK or RFAILED */
+   Reason         reason;                 /*!< Reason for Failure */
+}UdxDatFwdCfmInfo;
+
+
+typedef struct udxDatResumeCfmInfo
+{
+   CmLteRnti      ueId;                   /*!< UE ID */
+   CmLteCellId    cellId;                 /*!< Cell ID */
+   U32            transId;                         /*!< Transcation ID */
+   Status         status;                 /*!< ROK or RFAILED */
+   Reason         reason;                 /*!< Reason for Failure */
+} UdxDatResumeCfmInfo;
+/**
+ *  @brief
+ *  Data Forward
+ */
+typedef struct udxDatForwardInfo
+{
+   CmLteRnti      ueId;                   /*!< UE ID */
+   CmLteCellId    cellId;                 /*!< Cell ID */
+   U32            transId;                         /*!< Transcation ID */
+   Bool           ulFwding;               /*!< UL fwding to be done or not */
+} UdxDatForwardInfo;
+
+/*************************************************************************
+ *                      END OF STRUCTURES
+ ************************************************************************/
+
+/*************************************************************************
+ *                   Start of Pointer Interface primitives
+ ************************************************************************/
+typedef S16 (*UdxBndReq)      ARGS((Pst *pst, SuId suId, SpId spId));
+typedef S16 (*UdxBndCfm)      ARGS((Pst *pst, SuId suId, U8 status));
+typedef S16 (*UdxUbndReq)     ARGS((Pst *pst, SpId spId, Reason reason));
+typedef S16 (*UdxCfgReq)      ARGS((Pst *pst, SpId spId, UdxCfgReqInfo *cfgReq));
+typedef S16 (*UdxCfgCfm)      ARGS((Pst *pst, SuId suId, UdxCfgCfmInfo *cfgCfm));
+typedef S16 (*UdxReEstReq)    ARGS((Pst *pst, SpId spId, UdxReEstReqInfo *reEstReq));
+typedef S16 (*UdxReEstCfm)    ARGS((Pst *pst, SuId suId, UdxReEstCfmInfo *reEstCfm));
+typedef S16 (*UdxSecCfgReq)   ARGS((Pst *pst, SpId spId, UdxSecCfgReqInfo *secCfgReq));
+typedef S16 (*UdxSecCfgCfm)   ARGS((Pst *pst, SuId suId, UdxSecCfgCfmInfo *secCfgCfm));
+typedef S16 (*UdxUeIdChgReq)  ARGS((Pst *pst, SpId spId, U32 transId, 
+                                    UdxUeInfo *oldUeInfo,
+                                    UdxUeInfo *newUeInfo));
+typedef S16 (*UdxUeIdChgCfm)  ARGS((Pst *pst, SuId suId, U32 transId, 
+                                    UdxUeInfo  *ueInfo, CmStatus status));
+typedef S16 (*UdxCountReq)   ARGS((Pst *pst, SpId spId, UdxCountReqInfo *countReq));
+typedef S16 (*UdxCountCfm)   ARGS((Pst *pst, SuId suId, UdxCountCfmInfo *countCfm));
+typedef S16 (*UdxSduStaReq)  ARGS((Pst *pst, SpId spId, UdxSduStaReqInfo *staReq));
+typedef S16 (*UdxSduStaCfm)  ARGS((Pst *pst, SuId suId, UdxSduStaCfmInfo *staCfm));
+typedef S16 (*UdxDatResumeCfm)  ARGS((Pst *pst, SuId suId, UdxDatResumeCfmInfo *datResumeCfm));
+typedef S16 (*UdxDatForwardCfm)  ARGS((Pst *pst, SuId suId, UdxDatFwdCfmInfo *datFwdCfm));
+typedef S16 (*UdxUlStaRep)     ARGS((Pst *pst, SpId spId, UdxUlStaRepInfo *staRep));
+typedef S16 (*UdxDlStaRep)     ARGS((Pst *pst, SpId spId, UdxDlStaRepInfo *staRep));
+typedef S16 (*UdxUlFdbkPkt)     ARGS((Pst *pst, SpId spId, UdxUlFdbkPktInfo *fdbkPktInfo));
+typedef S16 (*UdxDlFdbkPkt)     ARGS((Pst *pst, SpId spId, UdxDlFdbkPktInfo *fdbkPktInfo));
+typedef S16 (*UdxDatResumeReq) ARGS((Pst  *pst, UdxDatResumeInfo  *udxDatResumeInfo));
+typedef S16 (*UdxDatForwardReq) ARGS((Pst  *pst, UdxDatForwardInfo  *udxDatForwardInfo));
+
+#ifdef LTE_L2_MEAS
+typedef S16 (*UdxL2MeasReq) ARGS((Pst* pst,
+                                PjL2MeasReqEvt *measReqEvt));
+
+typedef S16 (*UdxL2MeasSendReq) ARGS((Pst* pst,
+                                    U8 measType));
+
+typedef S16 (*UdxL2MeasStopReq) ARGS((Pst* pst,
+                                    U8 measType));
+#endif
+
+
+/*************************************************************************
+ *                   End of Pointer Interface primitives
+ ************************************************************************/
+/* cpj_x_001.main_2 */
+/*************************************************************************
+ *                   Start of Extern Interface Declarations
+ ************************************************************************/
+/**
+ * @brief Bind request primitive
+ * @details
+ * The function binds the PDCP service user entity (RRC) to the PDCP product.
+ * PDCP acknowledges the receipt of the bind request by sending a PjDlUdxBndCfm
+ * primitive.
+ *
+ * @param[in] pst     - Pointer to the post structure.
+ * @param[in] suId    - Service user ID. This is the reference number used by
+ * PDCP service user to identify its SAP. This reference number is 
+ * provided by PDCP in any further primitives sent by PDCP to the service user.
+ * @param[in] spId    - Service provider ID. This is the reference number used
+ * by PDCP service user to identify its SAP. This reference number is
+ * provided by PDCP in any further primitives sent by PDCP to the service user.
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUlUdxBndReq ARGS((Pst *pst, SuId suId, SpId spId));
+EXTERN S16 PjDlUdxBndReq ARGS((Pst *pst, SuId suId, SpId spId));
+
+/**
+ * @brief Bind confirmation primitive
+ * @details
+ * PDCP invokes the bind confirm primitive to acknowledge the receipt of
+ * the PjDlUdxBndReq primitive from the RRC layer. The status field indicates
+ * whether the bind request succeeded or failed. The bind request may fail due
+ * to invalid parameters in the bind request from the service user
+ * (for example, an invalid spId).
+ *
+ * @param[in] pst    - Pointer to the pst structure.
+ * @param[in] suId   - Service user ID. This is the reference number used
+ * by PDCP service user (RRC layer) to identify its SAP.
+ * @param[in] status - Status field indicates whether the bind request
+ * succeeded or failed. 
+ *  -# TRUE, for successful bind.
+ *  -# FALSE, otherwise.
+ *
+ *  @return ROK.
+ */
+EXTERN S16 PjDlUdxBndCfm ARGS((Pst *pst, SuId suId, U8 status));
+EXTERN S16 PjUlUdxBndCfm ARGS((Pst *pst, SuId suId, U8 status));
+
+/**
+ * @brief Unbind request primitive
+ * @details
+ * The PDCP service user (RRC) initiates this primitive for performing
+ * an unbind operation. This function brings the link between RRC and PDCP 
+ * down if it is already up, and releases all the resources associated for
+ * this SAP at PDCP.
+ *
+ * @param[in] pst    - Pointer to the post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] reason - Unbind reason. Not used in the current implementation. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUlUdxUbndReq ARGS((Pst *pst, SpId spId, Reason reason));
+EXTERN S16 PjDlUdxUbndReq ARGS((Pst *pst, SpId spId, Reason reason));
+
+/**
+ * @brief Configuration request primitive
+ * @details
+ * RRC uses this primitive to configure PDCP system parameters. The
+ * various parameters are configured by RRC. In one configuration request,
+ * multiple PDCP entities can be configured based on the rbId.
+ * For PDCP on target eNB, RRC can configure the handover information.
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] pdcpCfg - PDCP configuration structure. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUlUdxCfgReq ARGS((Pst *pst, SpId spId, UdxCfgReqInfo *cfgReq));
+EXTERN S16 PjDlUdxCfgReq ARGS((Pst *pst, SpId spId, UdxCfgReqInfo *cfgReq));
+EXTERN S16 PjDlUdxUlStaRep ARGS ((Pst *pst, SpId spId, UdxUlStaRepInfo   *staRep));
+EXTERN S16 PjDlUdxDlStaRep ARGS ((Pst *pst, SpId spId, UdxDlStaRepInfo   *staRep));
+EXTERN S16 PjUlUdxUlFdbkPktInfo ARGS((Pst *pst, SpId spId, UdxUlFdbkPktInfo *fdbkPktInfo));
+EXTERN S16 PjUlUdxDlFdbkPktInfo ARGS((Pst *pst, SpId spId, UdxDlFdbkPktInfo *fdbkPktInfo));
+
+
+/**
+ * @brief Configuration confirmation primitive
+ * @details
+ * This primitive is invoked by PDCP to inform to PDCP User (RRC) about
+ * the PDCP configuration request primitive execution status.
+ *
+ * @param[in] pst    - Pointer to the post structure.
+ * @param[in] suId   - Service user ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] pdcpCfgCfm - PDCP configuration confirm structure. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUlUdxCfgCfm ARGS((Pst *pst, SuId suId, UdxCfgCfmInfo *cfgCfm));
+EXTERN S16 PjDlUdxCfgCfm ARGS((Pst *pst, SuId suId, UdxCfgCfmInfo *cfgCfm));
+
+/**
+ * @brief Reestablishment request primtive
+ * @details
+ * RRC uses this primitive to reestablish the PDCP entity.
+ * This primitive is initiation of reestablishment procedure.
+ * This prmitive and corresponding confirmation are followed by
+ * PjDlUdxCfgReq procedure for entire reestablishment procedure to complete.
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used by
+ * PDCP to identify its SAP.
+ * @param[in] reEstReq - PDCP reestablishment request structure. 
+ *
+ */
+EXTERN S16 PjUlUdxReEstReq ARGS((Pst *pst, SpId spId, UdxReEstReqInfo *reEstReq));
+EXTERN S16 PjDlUdxReEstReq ARGS((Pst *pst, SpId spId, UdxReEstReqInfo *reEstReq));
+
+/**
+ * @brief Reestablishment confirmation primitive
+ * @details
+ * This primitive is invoked by PDCP to inform PDCP User (RRC) about the PDCP
+ * (SRB1) reestablishment request primitive execution status.
+ *
+ * @param[in] pst    - Pointer to the post structure.
+ * @param[in] suId   - Service user ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] reEstCfm - PDCP reestablishment confirm structure. 
+ *
+ */
+EXTERN S16 PjUlUdxReEstCfm ARGS((Pst *pst, SuId suId, UdxReEstCfmInfo *reEstCfm));
+EXTERN S16 PjDlUdxReEstCfm ARGS((Pst *pst, SuId suId, UdxReEstCfmInfo *reEstCfm));
+
+/**
+ * @brief Security Configuration request primitive
+ * @details
+ * RRC uses this primitive to configure PDCP security parameters.
+ * Integrity protection and/or Ciphering are configured by RRC based on the
+ * selSecAct flag. Integrity Protection/Ciphering are configured per UE and applicable
+ * to all PDCP entities in that UE. Both Integrity protection and ciphering are
+ * configured during reestablishment. 
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used by
+ * PDCP to identify its SAP.
+ * @param[in] pdcpSecCfg - PDCP security configuration structure. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUlUdxSecCfgReq ARGS((Pst *pst, SpId spId,
+         UdxSecCfgReqInfo *secCfgReq));
+EXTERN S16 PjDlUdxSecCfgReq ARGS((Pst *pst, SpId spId,
+         UdxSecCfgReqInfo *secCfgReq));
+
+/**
+ * @brief Security Configuration confirmation primitive.
+ * @details
+ * This primitive is invoked by PDCP to inform to PDCP User (RRC) about
+ * the PDCP secutiry configuration request primitive execution status.
+ *
+ * @param[in] pst    - Pointer to the post structure.
+ * @param[in] suId   - Service user ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] pdcpSecCfgCfm - PDCP configuration confirm structure. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUlUdxSecCfgCfm ARGS( (Pst *pst, SuId suId,
+         UdxSecCfgCfmInfo *secCfgCfm));
+EXTERN S16 PjDlUdxSecCfgCfm ARGS( (Pst *pst, SuId suId,
+         UdxSecCfgCfmInfo *secCfgCfm));
+
+/**
+ * @brief UE ID change request primitive
+ * @details
+ * This primitive is used by RRC to change the UeId for the existing UE context.
+ *
+ * @param[in] pst       - Point to the post structure
+ * @param[in] spId      - The ID of the service provider SAP in the PDCP layer.
+ * @param[in] transId   - Transaction ID. This field uniquely identifies
+ * transaction between RRC and PDCP.
+ * @param[in] oldUeInfo - Old UE ID info for which the change request has come.
+ * @param[in] newUeInfo - New UE ID info for existing UE context. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUlUdxUeIdChgReq ARGS((Pst *pst, SpId spId, U32 transId,
+                                  UdxUeInfo *oldUeInfo, UdxUeInfo  *newUeInfo));
+EXTERN S16 PjDlUdxUeIdChgReq ARGS((Pst *pst, SpId spId, U32 transId,
+                                  UdxUeInfo *oldUeInfo, UdxUeInfo  *newUeInfo));
+
+/**
+ * @brief UE ID change confirmation primitive
+ * @details
+ * This primitive is used by PDCP to confirm the UeId change requested by RRC.
+ * The different values for status are:\n
+ * ROK       -  Success\n
+ * RFAILED   -  Failure\n
+ *
+ * The different reasons for the failure are:
+ * UDX_CFG_REAS_UE_CREAT_FAIL -  UE Cb update failure \n
+ * UDX_CFG_REAS_UE_UNKWN      -  Request received for an unknown UE ID. 
+ *
+ * @param [in] pst       - Point to the post structure.
+ * @param [in] suId      - The ID of the service user SAP associated with PDCP
+ * @param [in] transId   - Transaction ID. This field uniquely identifies
+ *                         transaction between RRC and PDCP.
+ * @param [in] ueInfo    - UE Identity which is changed with the new ID
+ *                         for the same context.
+ * @param [in] CmStatus  - Confirmation status with appropriate reason
+ *                         information.
+ * @return ROK
+ */
+EXTERN S16 PjUlUdxUeIdChgCfm  ARGS((Pst *pst, SuId suId, U32 transId,
+                                  UdxUeInfo *ueInfo, CmStatus status));
+EXTERN S16 PjDlUdxUeIdChgCfm  ARGS((Pst *pst, SuId suId, U32 transId,
+                                  UdxUeInfo *ueInfo, CmStatus status));
+
+/**
+ * @brief Count request primitive
+ * @details
+ * RRC uses this primitive to request count value for all DRBs in a UE.
+ * PDCP sends the UL and DL count values in the confirmation of this request.
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] countReq - PDCP Count Request Information. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUlUdxCountReq ARGS((Pst *pst, SpId spId, UdxCountReqInfo *countReq));
+EXTERN S16 PjDlUdxCountReq ARGS((Pst *pst, SpId spId, UdxCountReqInfo *countReq));
+
+/**
+ * @brief Count confirmation primitive
+ * @details
+ * PDCP uses this primitive to send the count values for all
+ * DRBs in a UE to RRC. PDCP sends the RB ID, direction 
+ * and count value(s) ( UL, DL or both based on direction of the RB)
+ * for each DRB. 
+ *
+ * @param[in] pst       - Pointer to post structure.
+ * @param[in] suId      - The ID of the service user SAP associated with PDCP.
+ * @param[in] countCfm  - PDCP Count Confirmation Info. 
+ *
+ * @return ROK
+*/
+EXTERN S16 PjUlUdxCountCfm ARGS((Pst *pst, SuId suId, UdxCountCfmInfo *countCfm));
+EXTERN S16 PjDlUdxCountCfm ARGS((Pst *pst, SuId suId, UdxCountCfmInfo *countCfm));
+
+/**
+ * @brief SDU Status Request primitive
+ * @details
+ * RRC uses this primitive to request the status of the SDUs for DRBs in an UE.
+ * Its used as a reestablishment request during handover.
+ * This primitive is used to forward the handover control Information to the target
+ * eNodeB.
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] sduStaReq - PDCP SDU Status Request Information. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUlUdxSduStaReq ARGS((Pst *pst, SpId spId, UdxSduStaReqInfo *staReq));
+EXTERN S16 PjDlUdxSduStaReq ARGS((Pst *pst, SpId spId, UdxSduStaReqInfo *staReq));
+
+/**
+ * @brief SDU Status confirmation primitive
+ * @details
+ * PDCP uses this primitive to send the SDU status for the DRBs in 
+ * the requested UE. PDCP sends the RB ID, direction of the RB,status report 
+ * and count(to indicate the first missing SN) in UL and count(to indicate 
+ * the next SN to be assigned) in DL for each requested DRB mapped on to RLC AM.
+ *
+ * @param[in] pst       - Pointer to post structure.
+ * @param[in] suId      - The ID of the service user SAP associated with PDCP.
+ * @param[in] sduStaCfm - PDCP SDU Status Confirmation Info. 
+ *
+ * @return ROK
+*/
+EXTERN S16 PjDlUdxSduStaCfm ARGS((Pst *pst, SuId suId, UdxSduStaCfmInfo *staCfm));
+EXTERN S16 PjUlUdxSduStaCfm ARGS((Pst *pst, SuId suId, UdxSduStaCfmInfo *staCfm));
+
+
+EXTERN S16 PjDlUdxDatResumeCfm ARGS((Pst *pst, SuId suId, UdxDatResumeCfmInfo
+         *datResumeCfm));
+EXTERN S16 PjUlUdxDatResumeCfm ARGS((Pst *pst, SuId suId, UdxDatResumeCfmInfo
+         *datResumeCfm));
+EXTERN S16 PjDlUdxDatFwdCfm ARGS ((Pst *pst, SuId suId, UdxDatFwdCfmInfo  
+         *datFwdCfm));
+EXTERN S16 PjUlUdxDatForwardCfm ARGS ((Pst *pst, SuId suId, UdxDatFwdCfmInfo  
+         *datFwdCfm));
+
+EXTERN S16 PjDlUdxUlFdbkPktInfo ARGS((Pst *pst, SpId spId, UdxUlFdbkPktInfo *fdbkPktInfo));
+EXTERN S16 PjDlUdxDlFdbkPktInfo ARGS((Pst * pst, SpId spId, UdxDlFdbkPktInfo * fdbkPktInfo));
+
+#ifdef LTE_L2_MEAS
+EXTERN S16 PjDlUdxL2MeasReq ARGS((Pst *pst,
+                                PjL2MeasReqEvt *measReqEvt)); 
+
+EXTERN S16 PjDlUdxL2MeasSendReq ARGS((Pst *pst,
+                                    U8 status)); 
+
+EXTERN S16 PjDlUdxL2MeasStopReq ARGS((Pst *pst,
+                                    U8 status)); 
+
+EXTERN S16 PjUlUdxL2MeasReq ARGS((Pst* pst, 
+                                 PjL2MeasReqEvt *measReqEvt));
+
+EXTERN S16 PjUlUdxL2MeasSendReq ARGS((Pst *pst, U8 status));
+
+EXTERN S16 PjUlUdxL2MeasStopReq ARGS((Pst* pst, U8 measType));
+#endif
+EXTERN S16 PjDlUdxDatResumeReq ARGS((Pst *pst, UdxDatResumeInfo  *udxDatResumeInfo));
+EXTERN S16 PjUlUdxDatResumeReq ARGS((Pst *pst, UdxDatResumeInfo  *udxDatResumeInfo));
+EXTERN S16 PjDlUdxDatForwardReq ARGS((Pst *pst, UdxDatForwardInfo  *udxDatForwardInfo));
+EXTERN S16 PjUlUdxDatForwardReq ARGS((Pst *pst, UdxDatForwardInfo  *udxDatForwardInfo));
+EXTERN S16 PjUlUdxDatResumeReqFB ARGS((Pst *pst, UdxDatResumeInfo  *udxDatResumeInfo));
+EXTERN S16 PjUlUdxDatForwardReqFB ARGS((Pst *pst, UdxDatForwardInfo  *udxDatForwardInfo));
+#ifdef FLAT_BUFFER_OPT
+EXTERN S16 PjDlUdxDatResumeReqFB ARGS((Pst *pst,UdxDatResumeInfo *datResumeInfo));
+EXTERN S16 PjDlUdxDatForwardReqFB ARGS((Pst *pst,UdxDatForwardInfo *datFwdInfo));
+#endif
+/*************************************************************************
+ *                   End of Extern Interface Declarations                *
+ ************************************************************************/
+
+/***********************************************************************
+ *                    Start of pack/unpack functions                   *
+ * *********************************************************************/
+#if (defined(LCUDX) || defined(LCPJULUDX))
+
+EXTERN S16 cmPkPjUdxBndReq ARGS((
+Pst * pst,
+SuId suId,
+SpId spId
+));
+EXTERN S16 cmUnpkPjUdxBndReq ARGS((
+UdxBndReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxBndCfm ARGS((
+Pst * pst,
+SuId suId,
+U8 status
+));
+EXTERN S16 cmUnpkPjUdxBndCfm ARGS((
+UdxBndCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxUbndReq ARGS((
+Pst * pst,
+SpId spId,
+Reason reason
+));
+EXTERN S16 cmUnpkPjUdxUbndReq ARGS((
+UdxUbndReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxCfgReq ARGS((
+Pst * pst,
+SpId spId,
+UdxCfgReqInfo * cfgReq
+));
+EXTERN S16 cmUnpkPjUdxCfgReq ARGS((
+UdxCfgReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxCfgCfm ARGS((
+Pst * pst,
+SuId suId,
+UdxCfgCfmInfo * cfgCfm
+));
+EXTERN S16 cmUnpkPjUdxCfgCfm ARGS((
+UdxCfgCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+
+EXTERN S16 cmPkPjUdxUlStaRep ARGS ((
+Pst * pst,
+SpId spId,
+UdxUlStaRepInfo *staRep
+));
+
+EXTERN S16 cmPkPjUdxDlStaRep ARGS ((
+Pst * pst,
+SpId spId,
+UdxDlStaRepInfo *staRep
+));
+
+EXTERN S16 cmUnpkPjUdxUlStaRepInfo ARGS ((
+Pst *pst,
+UdxUlStaRepInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxDlFdbkPktInfo ARGS ((
+UdxDlFdbkPktInfo  *param,
+Pst            *pst,
+Buffer         *mBuf
+));
+EXTERN S16 cmUnpkPjUdxUlStaRep ARGS ((
+UdxUlStaRep func,
+Pst *pst,
+Buffer *mBuf
+));
+
+EXTERN S16 cmUnpkPjUdxDlStaRep ARGS ((
+UdxDlStaRep func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxUlFdbkPkt ARGS ((
+UdxUlFdbkPkt func,
+Pst *pst,
+Buffer *mBuf
+));
+
+
+EXTERN S16 cmPkPjUdxUlStaRepInfo ARGS ((
+UdxUlStaRepInfo  *param,
+Pst            *pst,
+Buffer         *mBuf
+));
+
+
+EXTERN S16 cmPkPjUdxDlStaRepInfo ARGS ((
+UdxDlStaRepInfo  *param,
+Pst            *pst,
+Buffer         *mBuf
+));
+
+EXTERN S16 cmUnpkPjUdxDlStaRepInfo ARGS ((
+Pst *pst,
+UdxDlStaRepInfo *param,
+Buffer *mBuf
+));
+
+EXTERN S16 cmUnpkPjUdxDlFdbPktInfo ARGS ((
+Pst *pst,
+UdxDlFdbkPktInfo *param,
+Buffer *mBuf
+));
+
+
+EXTERN S16 cmPkPjUdxUlFdbkPkt ARGS((
+Pst * pst,
+SpId spId,
+UdxUlFdbkPktInfo  *fdbkPktInfo
+));
+
+EXTERN S16 cmPkPjUdxDlFdbkPkt ARGS((
+Pst * pst,
+SpId spId,
+UdxDlFdbkPktInfo  *fdbkPktInfo
+));
+
+EXTERN S16 cmPkPjUdxUlFdbkPktInfo ARGS((
+UdxUlFdbkPktInfo  *fdbkPktInfo,
+Pst *pst,
+Buffer *mBuf
+));
+
+EXTERN S16 cmUnpkPjUdxDlFdbkPkt ARGS((
+UdxDlFdbkPkt func,
+Pst *pst,
+Buffer *mBuf
+));
+
+EXTERN S16 cmUnpkPjUdxDlFdbkPktInfo ARGS((
+Pst *pst,
+UdxDlFdbkPktInfo  *fdbkPktInfo,
+Buffer *mBuf
+));
+
+EXTERN S16 cmUnpkPjUdxUlFdbkPktInfo ARGS ((
+Pst *pst,
+UdxUlFdbkPktInfo *param,
+Buffer *mBuf
+));
+
+EXTERN S16 cmPkPjUdxReEstReq ARGS((
+Pst * pst,
+SpId spId,
+UdxReEstReqInfo * reEstReq
+));
+EXTERN S16 cmUnpkPjUdxReEstReq ARGS((
+UdxReEstReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxReEstCfm ARGS((
+Pst * pst,
+SuId suId,
+UdxReEstCfmInfo * reEstCfm
+));
+EXTERN S16 cmUnpkPjUdxReEstCfm ARGS((
+UdxReEstCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxSecCfgReq ARGS((
+Pst * pst,
+SpId spId,
+UdxSecCfgReqInfo * secCfgReq
+));
+EXTERN S16 cmUnpkPjUdxSecCfgReq ARGS((
+UdxSecCfgReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxSecCfgCfm ARGS((
+Pst * pst,
+SuId suId,
+UdxSecCfgCfmInfo * secCfgCfm
+));
+EXTERN S16 cmUnpkPjUdxSecCfgCfm ARGS((
+UdxSecCfgCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxUeIdChgReq ARGS((
+Pst * pst,
+SpId spId,
+U32 transId,
+UdxUeInfo * oldUeInfo,
+UdxUeInfo * newUeInfo
+));
+EXTERN S16 cmUnpkPjUdxUeIdChgReq ARGS((
+UdxUeIdChgReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxUeIdChgCfm ARGS((
+Pst * pst,
+SuId suId,
+U32 transId,
+UdxUeInfo  * ueInfo,
+CmStatus status
+));
+EXTERN S16 cmUnpkPjUdxUeIdChgCfm ARGS((
+UdxUeIdChgCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxCountReq ARGS((
+Pst * pst,
+SpId spId,
+UdxCountReqInfo * countReq
+));
+EXTERN S16 cmUnpkPjUdxCountReq ARGS((
+UdxCountReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxCountCfm ARGS((
+Pst * pst,
+SuId suId,
+UdxCountCfmInfo * countCfm
+));
+EXTERN S16 cmUnpkPjUdxCountCfm ARGS((
+UdxCountCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxSduStaReq ARGS((
+Pst * pst,
+SpId spId,
+UdxSduStaReqInfo * staReq
+));
+EXTERN S16 cmUnpkPjUdxSduStaReq ARGS((
+UdxSduStaReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxSduStaCfm ARGS((
+Pst * pst,
+SuId suId,
+UdxSduStaCfmInfo * staCfm
+));
+EXTERN S16 cmUnpkPjUdxSduStaCfm ARGS((
+UdxSduStaCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxDatResumeCfm ARGS((
+Pst * pst,
+SuId suId,
+UdxDatResumeCfmInfo * staCfm
+));
+EXTERN S16 cmPkPjUdxDatForwardCfm ARGS((
+Pst * pst,
+SuId suId,
+UdxDatFwdCfmInfo * datFwdCfm
+));
+EXTERN S16 cmUnpkPjUdxDatResumeCfm ARGS((
+UdxDatResumeCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+
+EXTERN S16 cmUnpkPjUdxDatResumeReq ARGS((
+UdxDatResumeReq  func,
+Pst              *pst,
+Buffer           *mBuf
+));
+EXTERN S16 cmUnpkPjUdxDatForwardReq ARGS((
+UdxDatForwardReq  func,
+Pst              *pst,
+Buffer           *mBuf
+));
+EXTERN S16 cmUnpkPjUdxDatForwardCfm ARGS((
+ UdxDatForwardCfm func,
+ Pst *pst,
+ Buffer *mBuf
+ ));
+EXTERN S16 cmPkPjUdxRlcAm ARGS((
+UdxRlcAm *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxRlcAm ARGS((
+UdxRlcAm *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxRlcUm ARGS((
+UdxRlcUm *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxRlcUm ARGS((
+UdxRlcUm *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxRlcInfo ARGS((
+UdxRlcInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxRlcInfo ARGS((
+UdxRlcInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxCipherInfo ARGS((
+UdxCipherInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxCipherInfo ARGS((
+UdxCipherInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxIntegInfo ARGS((
+UdxIntegInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxIntegInfo ARGS((
+UdxIntegInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxSecCfg ARGS((
+UdxSecCfg *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxSecCfg ARGS((
+UdxSecCfg *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxRohcInfo ARGS((
+UdxRohcInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxRohcInfo ARGS((
+UdxRohcInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxHdrCompCfg ARGS((
+UdxHdrCompCfg *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxHdrCompCfg ARGS((
+UdxHdrCompCfg *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxHoInfo ARGS((
+Pst *pst,
+UdxHoInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxHoInfo ARGS((
+Pst *pst,
+UdxHoInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxCfgEnt ARGS((
+Pst *pst,
+UdxCfgEnt *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxCfgEnt ARGS((
+Pst *pst,
+UdxCfgEnt *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxAddCfgEnt ARGS((
+UdxAddCfgEnt *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxAddCfgEnt ARGS((
+UdxAddCfgEnt *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxModCfgEnt ARGS((
+Pst *pst,
+UdxModCfgEnt *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxModCfgEnt ARGS((
+Pst *pst,
+UdxModCfgEnt *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxCfgReqInfo ARGS((
+Pst *pst,
+UdxCfgReqInfo *param,
+Buffer *mBuf
+));
+
+EXTERN S16 cmUnpkPjUdxCfgReqInfo ARGS((
+Pst *pst,
+UdxCfgReqInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxCfmEnt ARGS((
+UdxCfmEnt *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxCfmEnt ARGS((
+UdxCfmEnt *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxCfgCfmInfo ARGS((
+UdxCfgCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxCfgCfmInfo ARGS((
+UdxCfgCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxReEstReqInfo ARGS((
+UdxReEstReqInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxReEstReqInfo ARGS((
+UdxReEstReqInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxReEstCfmInfo ARGS((
+UdxReEstCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxReEstCfmInfo ARGS((
+UdxReEstCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxSecCfgReqInfo ARGS((
+UdxSecCfgReqInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxSecCfgReqInfo ARGS((
+UdxSecCfgReqInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxSecCfgCfmInfo ARGS((
+UdxSecCfgCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxSecCfgCfmInfo ARGS((
+UdxSecCfgCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxUeInfo ARGS((
+UdxUeInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxUeInfo ARGS((
+UdxUeInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxCountReqInfo ARGS((
+UdxCountReqInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxCountReqInfo ARGS((
+UdxCountReqInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxCountInfo ARGS((
+UdxCountInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxCountInfo ARGS((
+UdxCountInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxCountCfmInfo ARGS((
+UdxCountCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxCountCfmInfo ARGS((
+UdxCountCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxSduStaReqInfo ARGS((
+UdxSduStaReqInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxSduStaReqInfo ARGS((
+UdxSduStaReqInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxDlSduStaInfo ARGS((
+UdxDlSduStaInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxDlSduStaInfo ARGS((
+UdxDlSduStaInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxSduStaInfo ARGS((
+Pst *pst,
+UdxSduStaInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxSduStaInfo ARGS((
+Pst *pst,
+UdxSduStaInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxSduStaCfmInfo ARGS((
+Pst *pst,
+UdxSduStaCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxSduStaCfmInfo ARGS((
+Pst *pst,
+UdxSduStaCfmInfo *param,
+Buffer *mBuf
+));
+
+EXTERN S16 cmPkPjUdxDatResumeCfmInfo ARGS((
+Pst *pst,
+UdxDatResumeCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUdxDatForwardCfmInfo ARGS((
+Pst *pst,
+UdxDatFwdCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxDatResumeCfmInfo ARGS((
+Pst *pst,
+UdxDatResumeCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUdxDatForwardCfmInfo ARGS((
+Pst *pst,
+UdxDatFwdCfmInfo *param,
+Buffer *mBuf
+));
+
+EXTERN S16 cmPkPjUdxDatResumeReq ARGS((
+Pst           *pst,
+UdxDatResumeInfo  *udxDatResumeInfo 
+));
+EXTERN S16 cmPkPjUdxDatForwardReq ARGS((
+Pst           *pst,
+UdxDatForwardInfo  *udxDatForwardInfo
+));
+#ifdef LTE_L2_MEAS
+EXTERN S16 cmPkPjUdxL2MeasReq ARGS((Pst *pst, PjL2MeasReqEvt *measReqEvt)); 
+EXTERN S16 cmPkPjUdxL2MeasSendReq ARGS((Pst *pst, U8 measType)); 
+EXTERN S16 cmPkPjUdxL2MeasStopReq ARGS((Pst *pst, U8 measType)); 
+EXTERN S16 cmUnpkPjUdxL2MeasReq ARGS((UdxL2MeasReq func, Pst* pst, Buffer *mBuf));
+EXTERN S16 cmUnpkPjUdxL2MeasSendReq ARGS((UdxL2MeasSendReq func, Pst* pst, Buffer *mBuf));
+EXTERN S16 cmUnpkPjUdxL2MeasStopReq ARGS((UdxL2MeasStopReq func, Pst* pst, Buffer *mBuf));
+#endif
+#endif
+
+/***********************************************************************
+ *                    End of pack/unpack functions                     *
+ * *********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __UDX_X__ */
+
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_udx_dl.c b/src/5gnrpdcp/pj_udx_dl.c
new file mode 100755 (executable)
index 0000000..c3d64d7
--- /dev/null
@@ -0,0 +1,1740 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE-PDCP Layer - Upper Interface Functions
+    
+        Type:    C file
+  
+        Desc:    Source code for PDCP Upper Interface Module
+                 This file contains following functions
+      
+        --PjDlUdxBndReq
+        --PjDlUdxUbndReq
+        --PjDlUdxCfgReq
+        --PjDlUdxUeIdChgReq
+        --PjDlUdxReEstReq
+        --PjDlUdxSecCfgReq
+        --PjDlUdxSduStaReq
+     
+
+     File:     pj_udx_dl.c
+
+**********************************************************************/
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=225;
+/** @file pj_udx_dl.c
+@brief PDCP Upper Interface Module 
+*/
+
+\f
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "lpj.h"           /* LPJ define */
+#include "cpj.h"           /* RRC layer */
+#include "pju.h"           /* PDCP service user */
+#include "pj_env.h"        /* RLC environment options */
+#include "pj.h"            /* RLC defines */
+#include "pj_dl.h"
+#include "pj_udx.h"
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "lpj.x"           /* LM(PDCP) */
+#include "cpj.x"           /* RRC layer */
+#include "pju.x"           /* PDCP service user */
+#include "pj_err.h"
+#include "pj.x"
+#include "pj_udx.h"          /* LIB */
+#include "pj_udx.x"          /* LIB */
+#include "pj_dl.x"
+#include "pj_udx.x"
+
+/* kw004.201 Assigned build issue in LTE RLC pj_uim.c */
+#include "pj_lib.x"
+
+
+/*****************************************************************************
+ *                          UDX INTERFACE
+ ****************************************************************************/
+/**
+ *
+ * @brief 
+ *
+ *        Handler for binding the PDCP upper layer service user with 
+ *        the PDCP layer.
+ *
+ * @b Description:
+ *
+ *        1. This function is used by PDCP user to request for binding to 
+ *        PDCP. @n
+ *        2. This function is called by the UDX interface to bind 
+ *        PDCP's SAP (identified by spId) with the service user's
+ *        SAP (identified by suId). @n
+ *
+ *  @param[in] pst   Post structure  
+ *  @param[in] suId  Service user SAP ID 
+ *  @param[in] spId  Service provider ID
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjDlUdxBndReq 
+(
+Pst  *pst,   
+SuId suId,  
+SpId spId   
+)
+#else
+PUBLIC S16 PjDlUdxBndReq (pst, suId, spId)
+Pst *pst;    
+SuId suId;   
+SpId spId;   
+#endif
+{
+   PjUdxDlSapCb      *udxSap;            /* pointer to session SAP */
+   S16             ret;                /* return value */
+   PjCb            *tPjCb;
+
+   TRC3(PjDlUdxBndReq)
+
+   ret = ROK;
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   RLOG2(L_DEBUG, "PjDlUdxBndReq(pst, spId(%d), suId(%d))", spId, suId);
+
+   udxSap = (tPjCb->u.dlCb->udxDlSap + spId);
+
+   /* Verify UDX SAP State */
+   switch(udxSap->state)
+   {
+      /* SAP is configured but not bound */
+      case PJ_SAP_CFG:
+      case PJ_SAP_UBND:
+      {
+         /* copy bind configuration parameters in SSAP sap */
+         udxSap->suId = suId;
+         udxSap->pst.dstProcId = pst->srcProcId;
+         udxSap->pst.dstEnt = pst->srcEnt;
+         udxSap->pst.dstInst = pst->srcInst;
+
+         /* Update the State */
+         udxSap->state = PJ_SAP_BND;
+
+         RLOG1(L_DEBUG, "PjDlUdxBndReq: state (%d)", udxSap->state);
+         break;
+      }
+
+      /* SAP is already bound */
+      case PJ_SAP_BND:
+      {
+         /* 
+          * Sap is already bound check source, destination Entity and 
+          * Proc Id
+          */
+         if (udxSap->pst.dstProcId != pst->srcProcId 
+               || udxSap->pst.dstEnt != pst->srcEnt
+               || udxSap->pst.dstInst != pst->srcInst
+               || udxSap->suId != suId)
+         {
+
+            RLOG1(L_DEBUG, "PjDlUdxBndReq: SAP already bound -- state(%d)", 
+                         udxSap->state);
+            ret = RFAILED;
+         }
+         break;
+      }
+
+     default:
+      {
+         RLOG0(L_ERROR, "Invalid UDX DL SAP State in Bind Req");
+         ret = RFAILED;
+         break;
+      }
+   }
+
+   if (ret == ROK)
+   {
+      PjDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_OK);
+   }
+   else
+   {
+      PjDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK);
+   }
+
+   RETVALUE(ROK);
+} /* PjDlUdxBndReq */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler for unbinding the RLC upper layer service user UDX with 
+ *        the RLC layer.
+ *
+ * @b Description:
+ *
+ *        1. This function is used by RLC user to request for unbinding  
+ *        with RLC. @n
+ *        2. This function is called by the UDX interface to 
+ *        unbind with RLC. @n
+ *
+ *  @param[in] pst     Post structure  
+ *  @param[in] spId    Service provider SAP ID 
+ *  @param[in] reason  Reason for Unbinding 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjDlUdxUbndReq
+(
+Pst      *pst,            
+SpId     spId,           
+Reason   reason           
+)
+#else
+PUBLIC S16 PjDlUdxUbndReq(pst, spId, reason)
+Pst      *pst;       
+SpId     spId;      
+Reason   reason;      
+#endif
+{
+   PjUdxDlSapCb  *udxSap;            /* UDX SAP control block */
+   PjCb   *tPjCb;
+
+   TRC3(PjDlUdxUbndReq)
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   RLOG2(L_DEBUG, "PjDlUdxUbndReq(pst, spId(%d), reason(%d))", spId, reason);
+
+   UNUSED(pst);
+   UNUSED(reason);
+
+   /* disable upper sap (UDX) */
+   udxSap = &(tPjCb->u.dlCb->udxDlSap[0]);
+
+   udxSap->state = PJ_SAP_CFG;
+
+   RETVALUE(ROK);
+} /* PjDlUdxUbndReq */
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for Sending the PDCP Status Report.
+ *
+ * @b Description:
+ *
+ *        This function is used by PDCP-DL to send PDCP Status Report. 
+ *
+ *  @param[in] pst   -  Post structure  
+ *  @param[in] spId  -  Serive Provider ID 
+ *  @param[in] staRep   -  PDCP Status Report. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjDlUdxUlStaRep
+(
+Pst             *pst,
+SpId            spId,
+UdxUlStaRepInfo   *staRep
+)
+#else
+PUBLIC S16 PjDlUdxUlStaRep(pst, spId, staRep)
+Pst            *pst;
+SpId           spId;
+UdxUlStaRepInfo  *staRep;
+#endif
+{
+   PjCb                 *tPjCb;
+   PjDlUeCb             *ueCb;
+   PjDlRbCb             *tRbCb;
+   PjUdxDlSapCb         *udxSap;       /* UDX SAP Control Block */
+   S16                  ret;           /* Return Value */
+   
+   TRC3(PjDlUdxUlStaRep);
+
+   ret = ROK;
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+#ifndef ALIGN_64BIT
+   RLOG1(L_DEBUG, "PjDlUdxUlStaRep(pst, spId(%d))", spId);
+#else
+   RLOG1(L_DEBUG, "PjDlUdxUlStaRep(pst, spId(%d))", spId);
+#endif
+
+   /* Get the udxSap */
+   udxSap = (tPjCb->u.dlCb->udxDlSap + spId);
+
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret);
+   if (ret != ROK)
+   {
+      /* pj002.201 Freeing from proper region */
+      PJ_FREE_BUF(staRep->sta);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxUlStaRepInfo));
+      RETVALUE(RFAILED);
+   }
+
+   /* Fetch Ue Cb */
+   ret = pjDbmFetchDlUeCb(tPjCb, staRep->pdcpId.ueId, staRep->pdcpId.cellId, &ueCb);
+
+   /* Ue Cb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, staRep->pdcpId.cellId,"UeId[%u] not found",
+            staRep->pdcpId.ueId);
+      PJ_FREE_BUF(staRep->sta);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxUlStaRepInfo));
+      RETVALUE(ret);
+   }
+
+   /* Fetch Rb Cb */
+   PJ_DBM_FETCH_DL_RBCB(staRep->pdcpId.rbId, staRep->pdcpId.rbType, ueCb, tRbCb);
+
+   /* Rb Cb is not present or Rb Cb is not configured for PDCP */
+   if( NULLP == tRbCb )
+   {
+      RLOG_ARG2(L_WARNING, DBG_UEID,staRep->pdcpId.ueId, "CellId[%u]:RbId[%d] not found",
+            staRep->pdcpId.cellId, staRep->pdcpId.rbId);
+      PJ_FREE_BUF(staRep->sta);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxUlStaRepInfo));
+      RETVALUE(RFAILED);
+   }
+   
+   /* This will go to the RLC as a datReq. So we will get a confirm for it
+       * we have to make sure that the count does not clash with the existing
+       * counts. So pick a value that is least expected to clash. */
+   if (tRbCb->state != PJ_STATE_NORMAL)
+   {
+      if (tRbCb->dlCb.staRep != NULL)
+      {
+        PJ_FREE_BUF(tRbCb->dlCb.staRep); 
+      }
+      tRbCb->dlCb.staRep = staRep->sta;
+   }
+   else
+   {
+      pjDlmSendDatReq(tPjCb,tRbCb,0xffffffff, staRep->sta);
+   }
+   
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxUlStaRepInfo));
+
+   RETVALUE(ROK);
+} /* PjDlUdxUlStaRep */
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for Handling the PDCP Status Report.
+ *
+ * @b Description:
+ *
+ *        This function is used by PDCP-DL to handle the PDCP Status Report
+ *        from peer PDCP entity. 
+ *
+ *  @param[in] pst   -  Post structure  
+ *  @param[in] spId  -  Serive Provider ID 
+ *  @param[in] staRep   -  PDCP Status Report. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjDlUdxDlStaRep
+(
+Pst             *pst,
+SpId            spId,
+UdxDlStaRepInfo   *staRep
+)
+#else
+PUBLIC S16 PjDlUdxDlStaRep(pst, spId, staRep)
+Pst            *pst;
+SpId           spId;
+UdxDlStaRepInfo  *staRep;
+#endif
+{
+   PjCb                 *tPjCb;
+   PjDlUeCb             *ueCb;
+   PjDlRbCb             *tRbCb;
+   PjUdxDlSapCb         *udxSap;       /* UDX SAP Control Block */
+   S16                  ret;           /* Return Value */
+   
+   TRC3(PjDlUdxDlStaRep);
+
+   ret = ROK;
+   
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+#ifndef ALIGN_64BIT
+   RLOG1(L_DEBUG, "PjDlUdxDlStaRep(pst, spId(%d))", spId);
+#else
+   RLOG1(L_DEBUG, "PjDlUdxDlStaRep(pst, spId(%d))", spId);
+#endif
+
+   /* Get the udxSap */
+   udxSap = (tPjCb->u.dlCb->udxDlSap + spId);
+
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret);
+   if (ret != ROK)
+   {
+      /* pj002.201 Freeing from proper region */
+      PJ_FREE_BUF(staRep->staPdu);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo));
+      RETVALUE(RFAILED);
+   }
+
+   /* Fetch Ue Cb */
+   ret = pjDbmFetchDlUeCb(tPjCb, staRep->pdcpId.ueId, staRep->pdcpId.cellId, &ueCb);
+
+   /* Ue Cb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, staRep->pdcpId.cellId,"UeId[%u] not found",
+            staRep->pdcpId.ueId);
+      PJ_FREE_BUF(staRep->staPdu);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo));
+      RETVALUE(ret);
+   }
+
+   /* Fetch Rb Cb */
+   PJ_DBM_FETCH_DL_RBCB(staRep->pdcpId.rbId, staRep->pdcpId.rbType, ueCb, tRbCb);
+
+   /* Rb Cb is not present or Rb Cb is not configured for PDCP */
+   if( NULLP == tRbCb )
+   {
+      RLOG_ARG2(L_WARNING, DBG_UEID,staRep->pdcpId.ueId, "CellId[%u]:RbId[%d] not found",
+            staRep->pdcpId.cellId, staRep->pdcpId.rbId);
+      PJ_FREE_BUF(staRep->staPdu);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo));
+      RETVALUE(RFAILED);
+   }
+   
+   ret = pjDlmHndlStaRep(tPjCb, tRbCb, staRep->fmc, staRep->staPdu);
+
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo));
+
+   RETVALUE(ret);
+} /* PjUdxDlStaRep */    
+
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler for configuring Downlink PDCP entities.
+ *
+ * @b Description:
+ *
+ *        This function is used by RRC to configure(add/delete/modify/
+ *        reestalish/delete all RB in a UE) one or more PDCP entities. 
+ *
+ *        - UDX_CFG_ADD          => pjCfgAddRb
+ *        - UDX_CFG_MODIFY       => pjCfgReCfgRb
+ *        - UDX_CFG_DELETE       => pjCfgDelRb
+ *        - UDX_CFG_REESTABLISH  => pjCfgReEstRb
+ *        - UDX_CFG_DELETE_UE    => pjCfgDelUe
+ *
+ *  @param[in] pst   -  Post structure  
+ *  @param[in] spId  -  Service Provider ID 
+ *  @param[in] cfg   -  Configuration information for one or more PDCP entities. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjDlUdxCfgReq
+(
+Pst             *pst,
+SpId            spId,
+UdxCfgReqInfo   *cfg
+)
+#else
+PUBLIC S16 PjDlUdxCfgReq(pst, spId, cfg)
+Pst            *pst;
+SpId           spId;
+UdxCfgReqInfo  *cfg;
+#endif
+{
+
+   UdxCfgCfmInfo        *cfgCfm;       /* Configuraiton Confirm */
+   U8                   idx;           /* Index */
+   PjUdxDlSapCb         *udxSap;       /* UDX SAP Control Block */
+   Bool                 reEstPres;     /* ReEstablishment present */
+   Bool                 startTmr;      /* Add present */
+   S16                  ret;           /* Return Value */
+   PjDlUeCb            *ueCb;         /* UE Control Block for storing the
+                                    cfg structure in case of ReEstablishment */
+   U8                   cfmType;
+   PjCb                *tPjCb;
+
+   TRC3(PjDlUdxCfgReq);
+
+   reEstPres = FALSE;
+   cfmType   = 0;
+   ret       = ROK;
+   cfgCfm    = NULLP;
+   idx       = 0;
+   ueCb      = NULLP;
+   startTmr  = 0;
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+#ifndef ALIGN_64BIT
+   RLOG2(L_DEBUG, "PjDlUdxCfgReq(pst, spId(%d), TransId(%ld))", 
+         spId, cfg->transId);
+#else
+   RLOG2(L_DEBUG, "PjDlUdxCfgReq(pst, spId(%d), TransId(%d))", 
+         spId, cfg->transId);
+#endif
+
+   /* Get the udxsap */
+   udxSap = (tPjCb->u.dlCb->udxDlSap + spId);
+
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret);
+   if (ret != ROK)
+   {
+      /* pj002.201 Freeing from proper region */
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfg, sizeof(UdxCfgReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   ret = ROK;
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfgCfm, 
+      sizeof (UdxCfgCfmInfo), ret);
+   /* Allocate memory and memset to 0 for cfmInfo */
+    if(ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      /* pj002.201 Freeing from proper region */
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfg, sizeof(UdxCfgReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   /* Fetch UeCb */
+   pjDbmFetchDlUeCb(tPjCb, cfg->ueId, cfg->cellId, &ueCb);
+  /* KW_FIX : UDX_MAX_CFG , UDX_MAX_CFM have the same value , hence checking for only one */
+   /* For every entity configuration process by cfgType */
+   for (idx = 0; idx < cfg->numEnt && idx < UDX_MAX_CFG; idx++)
+   {
+      UdxCfmEnt         *entCfgCfm;
+      UdxCfgEnt         *entCfg;
+
+      entCfg  = (UdxCfgEnt *)&(cfg->cfgEnt[idx]);
+      entCfgCfm   = (UdxCfmEnt *)&(cfgCfm->cfmEnt[idx]);
+
+      if (NULL != ueCb)
+      {
+         /* Fill the detault values here */
+         PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, UDX_CFG_CFM_OK,\
+               UDX_CFG_REAS_NONE);
+      }
+      else
+      {
+         RLOG_ARG1(L_WARNING, DBG_CELLID,cfg->cellId,"UeId[%u] not found",
+               cfg->ueId);
+         PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
+            CPJ_CFG_REAS_UE_UNKWN);
+
+         RLOG_ARG1(L_WARNING,DBG_UEID,cfg->ueId, 
+           "Dl RB Config Req- UE CB is not found for cellid (%d)",cfg->cellId);
+         if (entCfg->cfgType !=  UDX_CFG_ADD)
+         {
+            /* all other requests require ueCb mandatorily */
+            continue;
+         }
+      }
+
+      switch (entCfg->cfgType)
+      {
+         case UDX_CFG_ADD:
+            {
+               if (entCfg->m.addCfg.rlcInfo.dir & PJ_DIR_DL)
+               {
+                  U8 isHo;
+
+                  isHo = cfg->isHo;
+                  /* Add a new RB entity configuration */
+                  if (pjCfgAddDlRb(tPjCb,cfg->ueId, cfg->cellId, isHo,
+                                     entCfg, &ueCb,entCfgCfm) != ROK)
+                  {
+                     RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "Dl Cfg RB Add Req"
+                           " for cellId(%d), rbId(%d) Failed: reason (%d)",
+                       cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
+                  }
+                  /* Only In case of DRB only we need to set this flag */
+#ifdef PJ_CMP_ASYNC
+                  else if(PJ_DRB == entCfg->rbType)
+                  {
+                     if(entCfg->m.addCfg.hdrCompCfg.hdrCompUsed)
+                     {
+                        cfmType  |=  PJ_CFG_ASYNC_CFM;
+                        startTmr =  TRUE;
+                     }
+                  }
+#endif /* PJ_CMP_ASYNC */
+               }
+               break;
+            }
+
+         case UDX_CFG_MODIFY:
+            {
+               /* Re-configure the existing RB entity configuration */
+               if ((entCfg->m.modCfg.bitFlag & 0x02) ||
+                  (entCfg->m.modCfg.hdrCompCfg.hdrCompUsed) ||
+                  (entCfg->m.modCfg.hoInfo.isHoPres & CPJ_HO_DL))
+               {
+                  if (pjCfgReCfgDlRb(tPjCb,ueCb, entCfg, entCfgCfm) != ROK)
+                  {
+                     RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId,"Dl RB Modify Req"
+                            "for cellId(%d),rbId(%d) not done as RbCb not found: reason(%d)",
+                        cfg->cellId,cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
+                  }
+#ifdef PJ_CMP_ASYNC
+                  else if(PJ_DRB == entCfg->rbType)
+                  {
+                     if(entCfg->m.modCfg.hdrCompCfg.hdrCompUsed)
+                     {
+                        cfmType  |=  PJ_CFG_ASYNC_CFM;
+                        startTmr =  TRUE;
+                     }
+                  }
+#endif /* PJ_CMP_ASYNC */
+             }
+               break;
+            }
+
+         case UDX_CFG_DELETE:
+            {
+               /* Delete the existing RB entity configuration */
+               if (pjCfgDelDlRb(tPjCb, ueCb, entCfg, entCfgCfm) != ROK)
+               {
+                  RLOG_ARG3(L_WARNING,DBG_UEID,cfg->ueId, "Dl RB Delete Req for"
+                        "for cellId(%d), rbId(%d) not done as RbCb not found: reason (%d)",
+                    cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
+               }
+               break;
+            }
+
+         case UDX_CFG_REESTABLISH:
+            {
+               if (pjCfgReEstDlRb(tPjCb, ueCb, entCfg, entCfgCfm) != ROK)
+               {
+                   RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "Dl RB Re-establih Req"
+                         "for cellId(%d), rbId(%d) Failed: reason (%d)",
+                      cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
+               }
+               else
+               {
+                  cfmType  |=  PJ_CFG_REEST_ASYNC_CFM;
+                  reEstPres= TRUE;
+               }
+
+               break;
+            }
+
+         case UDX_CFG_DELETE_UE:
+            {
+               /* Delete all RB entity configuration under UE */
+               if (pjCfgDelDlUe(tPjCb, ueCb,entCfg, entCfgCfm) != ROK)
+               {
+
+                  RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "Dl UE Delete Req for"
+                     "cellId(%d), rbId(%d) Failed: reason (%d)",
+                      cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
+               }
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+               else
+               {
+                  /* Wait for any messages in the Demand q to be processed */
+                  cfmType  |=  PJ_CFG_UEDEL_ASYNC_CFM;
+                  startTmr =  TRUE;
+               }
+#endif /* (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) */
+               break;
+            }
+
+         default:
+            {
+               PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, UDX_CFG_CFM_NOK,\
+                     UDX_CFG_REAS_INVALID_CFG);
+
+               RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "Dl Cfg Req with Invalid"
+                      "config type,cellId(%d),cfgType(%d),rbId(%d) ",
+                     cfg->cellId, entCfg->cfgType, cfg->cfgEnt[idx].rbId);
+            }
+      }
+   }
+
+   /* Assign number of entity configuraitons and suId */
+   cfgCfm->transId = cfg->transId;
+   cfgCfm->ueId = cfg->ueId;
+   cfgCfm->cellId = cfg->cellId;
+   cfgCfm->numEnt = cfg->numEnt;
+
+   if (cfmType != 0)
+   {
+      if (ueCb != NULLP)
+      {
+         if(TRUE == reEstPres )
+         {
+#ifdef PJ_ASYNC_CFM
+            pjUtlDlSaveCfmInfo(tPjCb, ueCb, cfmType, startTmr, ENTPJ, (PTR)cfgCfm, (PTR)cfg);
+#endif
+            pjUtlDlUpdUpSecKeys(tPjCb, ueCb); 
+#ifdef PJ_ASYNC_CFM
+            PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, cfgCfm, sizeof(UdxCfgCfmInfo));
+#else
+            PjDlUdxCfgCfm(&(udxSap->pst), udxSap->suId, cfgCfm);
+#endif
+          
+         }
+         else
+         {
+            pjUtlDlSaveCfmInfo(tPjCb, ueCb, cfmType, startTmr, ENTPJ, (PTR)cfgCfm, (PTR)cfg);
+            PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, cfgCfm, sizeof(UdxCfgCfmInfo));
+         }
+         /* Free the cfg */
+         PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfg, sizeof(UdxCfgReqInfo));
+      }
+      else
+      {
+         PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfg, sizeof(UdxCfgReqInfo));
+         PjDlUdxCfgCfm(&(udxSap->pst), udxSap->suId, cfgCfm);
+      }
+   }
+   else
+   {
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfg, sizeof(UdxCfgReqInfo));
+      PjDlUdxCfgCfm(&(udxSap->pst), udxSap->suId, cfgCfm);
+   }
+
+   RETVALUE(ret);
+} /* PjDlUdxCfgReq */
+
+/**
+ *@details This primitive is used by RRC to change the UeId for the existing UE
+           context.
+
+ * @param pst     -  Point to the pst structure
+ * @param spId    -  The ID of the service provider SAP in the PDCP layer 
+ * @param transId -  Transaction ID. This field uniquily identifies
+ *                   transaction between RRC and PDCP.
+ * @param ueInfo    -  Old UE Id Info for which the change request has come 
+ * @param newUeInfo -  New UE Id Info for existing UE context 
+ * @return ROK
+**/
+#ifdef ANSI
+PUBLIC S16 PjDlUdxUeIdChgReq
+(
+Pst        *pst, 
+SpId       spId, 
+U32        transId, 
+UdxUeInfo  *ueInfo,
+UdxUeInfo  *newUeInfo
+)
+#else
+PUBLIC S16 PjDlUdxUeIdChgReq(pst,spId,transId,ueInfo,newUeInfo)
+Pst        *pst;
+SpId       spId;
+U32        transId;
+UdxUeInfo  *ueInfo;
+UdxUeInfo  *newUeInfo;
+#endif
+{
+   S16         ret;           /* Return Value */
+   CmStatus    status;        /* Status of the request */
+   PjUdxDlSapCb  *udxSap;       /* UDX SAP Control Block */
+   UdxUeInfo   *tUeInfo;      /* Temporary UE info */
+   PjCb         *tPjCb;
+
+   TRC3(PjDlUdxUeIdChgReq)
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifndef ALIGN_64BIT
+   RLOG2(L_DEBUG, "PjDlUdxUeIdChgReq(pst, spId(%d), transId(%ld))", spId, transId);
+#else
+   RLOG2(L_DEBUG, "PjDlUdxUeIdChgReq(pst, spId(%d), transId(%d))", spId, transId);
+#endif
+
+   ret = ROK;
+   tUeInfo = NULLP;
+   udxSap = &(tPjCb->u.dlCb->udxDlSap[0]);
+   status.reason = UDX_CFG_REAS_NONE;
+   status.status = UDX_CFG_CFM_OK;
+   
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret);
+   if (ret != ROK)
+   {
+      /* kw002.201 Freeing from proper region */
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo));
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo));
+      RETVALUE(RFAILED);
+   }
+
+   if (pjCfgDlUeIdChng(tPjCb, ueInfo,
+                   newUeInfo, &status) != ROK)
+   {
+      RLOG_ARG4(L_ERROR,DBG_UEID,ueInfo->ueId,"Dl UeId Change Req old-ueId(%d),"
+            "new-ueId(%d), cellId(%d) Failed: reason (%d)",
+             ueInfo->ueId, newUeInfo->ueId, newUeInfo->cellId, status.reason);
+   }
+
+   /* Allocate memory for UdxUeInfo */
+   /* Memory leak fix ccpu00135359 */
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, tUeInfo,
+        sizeof (UdxUeInfo), ret);
+   if( ret != ROK)
+   {
+      /* Free memory for UdxUeInfo */
+      /* kw002.201 Freeing from proper region */
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo));
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo));
+
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   tUeInfo->ueId = ueInfo->ueId;
+   tUeInfo->cellId = ueInfo->cellId;
+
+   /* Free memory for CkwUeInfo */
+   /* kw002.201 Freeing from proper region */
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo));
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo));
+
+   PjDlUdxUeIdChgCfm(&(udxSap->pst), udxSap->suId, transId, tUeInfo, status);
+
+   RETVALUE(ROK);
+} /* PjDlUdxUeIdChgReq */
+
+
+/**
+ *@details  
+ * 1. RRC uses this primitive to configure PDCP security parameters.
+ * Integrity protection and/or Ciphering are configured by RRC based on the
+ * selSecAct flag.  @n
+ * 2. Integirty Protection/Ciphering are configured per UE and applicable
+ * to all pdcp entities in that UE. Both Integrity protection and ciphering are
+ * re-configured during re-establishment.  @n
+ *
+ * @param pst     -  Point to the pst structure
+ * @param spId    -  The ID of the service provider SAP in the PDCP layer 
+ * @param secCfg  -  Security Configuration Info per UE.
+ *
+ * @return 
+ *       -# ROK
+ *       -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 PjDlUdxSecCfgReq
+(
+Pst              *pst,
+SpId             spId,
+UdxSecCfgReqInfo *secCfg
+)
+#else
+PUBLIC S16 PjDlUdxSecCfgReq(pst,spId,secCfg)
+Pst              *pst;
+SpId             spId;
+UdxSecCfgReqInfo *secCfg;
+#endif
+{
+   S16               ret;           /* Return Value */
+   UdxSecCfgCfmInfo  *cfgCfm;       /* Security Cfg Confirm structure */
+   PjUdxDlSapCb        *udxSap;       /* UDX SAP Control Block */
+#ifdef PJ_SEC_ASYNC
+   PjDlUeCb            *ueCb;         /* UE Control Block */
+#endif
+   PjCb   *tPjCb;
+
+   TRC2(PjDlUdxSecCfgReq)
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifndef ALIGN_64BIT 
+   RLOG2(L_DEBUG, "PjDlUdxSecCfgReq(pst, spId(%d), TransId(%ld))", spId,
+               secCfg->transId);
+#else
+   RLOG2(L_DEBUG, "PjDlUdxSecCfgReq(pst, spId(%d), TransId(%d))", spId,
+               secCfg->transId);
+#endif
+
+   ret = ROK;
+   cfgCfm = NULLP;
+   udxSap = NULLP;
+
+   udxSap = &(tPjCb->u.dlCb->udxDlSap[0]);
+
+#ifdef PJ_SEC_ASYNC
+   ueCb   = NULLP;
+#endif
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfgCfm, 
+      sizeof (UdxSecCfgCfmInfo), ret);
+    if(ret != ROK)
+   {
+      /* Free memory for CfgReqInfo */
+      /* kw002.201 Freeing from proper region */  
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfg, sizeof(UdxSecCfgReqInfo));
+
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   if ( pjCfgPrcSecDlCfg(tPjCb,secCfg,
+                            cfgCfm) != ROK )
+   {
+      RLOG_ARG2(L_ERROR,DBG_UEID,secCfg->ueId, " Dl Sec Cfg Req for cellId(%d)"
+            " Failed: reason (%d)", secCfg->cellId, cfgCfm->reason);
+   }
+
+#ifdef PJ_SEC_ASYNC
+   ret = pjDbmFetchDlUeCb(tPjCb,secCfg->ueId, secCfg->cellId, &ueCb);
+   if ( ueCb != NULLP )
+   {
+      pjUtlDlSaveCfmInfo(tPjCb, ueCb, PJ_SEC_ASYNC_CFM, TRUE,  ENTPJ, (PTR)cfgCfm, NULLP);
+      PJ_FREE(tPjCb, cfgCfm, sizeof(UdxSecCfgCfmInfo));
+   }
+   else
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, secCfg->cellId,"UeId[%u] not found",
+            secCfg->ueId);
+      PjDlUdxSecCfgCfm(&(udxSap->pst), udxSap->suId, cfgCfm);
+   }
+#else
+   PjDlUdxSecCfgCfm(&(udxSap->pst), udxSap->suId, cfgCfm);
+#endif 
+
+  /* Configuration information needs to be freed from proper region */
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfg, sizeof(UdxSecCfgReqInfo));
+
+   RETVALUE(ret); 
+}
+
+
+
+/**
+ * @details
+ * 1. RRC uses this primitive to re-establish the PDCP entity. @n
+ * 2. This primitive is initiation of re-establishment procedure. @n
+ * 3. This prmitive and corresponding confirmation shall be followed by
+ *    PjDlUdxCfgReq procedure for entire re-establishment procedure to complete.
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used by
+ * PDCP to identify its SAP.
+ * @param[in] reEstReq - PDCP re-establishment request structure. 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjDlUdxReEstReq 
+(
+Pst             *pst, 
+SpId            spId, 
+UdxReEstReqInfo *reEstReq
+)
+#else 
+PUBLIC S16 PjDlUdxReEstReq(pst,spId,reEstReq)
+Pst             *pst;
+SpId            spId;
+UdxReEstReqInfo *reEstReq;
+#endif
+{
+   S16               ret;           /* Return Value */
+   UdxReEstCfmInfo   *reEstCfm;     /* Re-Establish Confirm */
+   PjUdxDlSapCb        *udxSap;       /* UDX SAP Control Block */
+   PjCb   *tPjCb;
+
+   TRC2(PjDlUdxReEstReq);
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   RLOG1(L_DEBUG, "PjDlUdxReEstReq(pst, spId(%d))", spId);
+
+   ret = ROK;
+   udxSap = &(tPjCb->u.dlCb->udxDlSap[0]);
+
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret);
+   if (ret != ROK)
+   {
+      /* pj002.201 Freeing from proper region */  
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo));
+      RETVALUE(RFAILED);
+   }
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst , reEstCfm, 
+      sizeof (UdxReEstCfmInfo), ret);
+   if(ret != ROK)
+   {
+      /* Free memory for CfgReqInfo */
+      /* kw002.201 Freeing from proper region */  
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo));
+
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   if ( pjCfgDlReEstReq(tPjCb,(UdxReEstReqInfo *)reEstReq,
+                              (UdxReEstCfmInfo *)reEstCfm) != ROK )
+   {
+      RLOG_ARG2(L_ERROR,DBG_UEID,reEstReq->pdcpId.ueId, "Dl Re-Est Req Cfg for"
+            " cellId(%d)  Failed: reason (%u)",
+         reEstReq->pdcpId.cellId, reEstCfm->status);
+
+       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo));
+       PjDlUdxReEstCfm(&(udxSap->pst), udxSap->suId, reEstCfm); 
+       RETVALUE (ROK);
+   }
+
+   /* kw002.201 Freeing from proper region */  
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo));
+
+#ifdef PJ_ASYNC_CFM   
+   /* If Async is enabled then we need to wait for confirmation */
+   RETVALUE(ROK);
+#endif
+   PjDlUdxReEstCfm(&(udxSap->pst), udxSap->suId, reEstCfm); 
+   RETVALUE(ROK); 
+}
+
+
+/**
+ * @details
+ * 1. RRC uses this primitive to request count value for all DRBs in a UE. @n
+ * 2. PDCP sends the UL and DL count values in the confirmation of this request. 
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] countReq - PDCP Count Request Information. 
+ *
+ * @return ROK
+ */
+#ifdef ANSI
+PUBLIC S16 PjDlUdxCountReq 
+(
+Pst             *pst, 
+SpId            spId, 
+UdxCountReqInfo *countReq
+)
+#else
+PUBLIC S16 PjDlUdxCountReq(pst,spId,countReq)
+Pst             *pst;
+SpId            spId;
+UdxCountReqInfo *countReq;
+#endif
+{
+
+   S16               ret;           /* Return Value */
+   UdxCountCfmInfo   *countCfm;     /* Count Confirm structure */
+   PjUdxDlSapCb        *udxSap;       /* UDX SAP Control Block */
+   PjCb   *tPjCb;
+
+   TRC2(PjDlUdxCountReq);
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   RLOG1(L_DEBUG, "PjDlUdxCountReq(pst, spId(%d))", spId);
+
+   ret = ROK;
+   countCfm = NULLP;
+   udxSap = &(tPjCb->u.dlCb->udxDlSap[0]);
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, countCfm, 
+      sizeof (UdxCountCfmInfo), ret);
+   if( ret != ROK)
+   {
+      /* Free memory for CfgReqInfo */
+      /* kw002.201 Freeing from proper region */
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo));
+
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+   if ( pjCfgPrcDlCount(tPjCb, countReq, 
+                             countCfm) != ROK )
+   {
+      RLOG_ARG2(L_ERROR,DBG_UEID,countReq->ueId, "Dl Count Req for cellId(%d)"
+            " Failed: reason (%d)",
+          countReq->cellId, countCfm->reason);
+
+   }
+
+   /* Freeing from proper region */
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo));
+
+   PjDlUdxCountCfm(&(udxSap->pst), udxSap->suId,countCfm);
+
+   RETVALUE(ROK);
+
+}
+
+/**
+ * 
+ * @details
+ * 1. RRC uses this primitive to request the status of the SDUs for DRBs in an UE. @n
+ * 2. Its used as a reestablishment request during handover.  @n
+ * 3. This primitive is used to forward the handover control Information to the target
+ * eNodeB.
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] sduStaReq - PDCP SDU Status Request Information. 
+ *
+ * @return ROK
+ */
+#ifdef ANSI
+PUBLIC S16 PjDlUdxSduStaReq 
+(
+Pst              *pst, 
+SpId             spId, 
+UdxSduStaReqInfo *staReq
+)
+#else
+PUBLIC S16 PjDlUdxSduStaReq(pst,spId,staReq)
+Pst              *pst;
+SpId             spId;
+UdxSduStaReqInfo *staReq;
+#endif
+{
+
+   S16               ret;          /* Return Value */
+   PjUdxDlSapCb     *udxSap;       /* UDX SAP Control Block */
+   PjCb             *tPjCb;
+
+   TRC2(PjDlUdxSduStaReq);
+
+   ret = ROK;
+   udxSap = NULLP;
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   udxSap = &(tPjCb->u.dlCb->udxDlSap[0]);
+
+    RLOG1(L_DEBUG, "PjDlUdxSduStaReq(pst, spId(%d))", spId);
+
+
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret);
+   if (ret != ROK)
+   {
+      /* kw002.201 Freeing from proper region */
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   if (pjCfgPrcDlSduSta(tPjCb,(UdxSduStaReqInfo *) staReq) != ROK )
+   {
+      RLOG_ARG1(L_ERROR,DBG_UEID,staReq->ueId, 
+            "Dl Sdu Sta Req for cellId(%d) Failed",staReq->cellId);
+      ret = RFAILED;
+
+   }
+   /* kw002.201 Freeing from proper region */
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo));
+
+   RETVALUE(ret);
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for Sending the Feed back Packet Info to DL-RLC.
+ *
+ * @b Description:
+ *
+ *        This function is used by PDCP-DL to send Feedback Packet Info to DL-RLC. 
+ *
+ *  @param[in] pst   -  Post structure  
+ *  @param[in] spId  -  Serive Provider ID 
+ *  @param[in] fdbkPktInfo   -  Feedback Packet Info. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjDlUdxUlFdbkPktInfo
+(
+Pst             *pst,
+SpId            spId,
+UdxUlFdbkPktInfo   *fdbkPktInfo
+)
+#else
+PUBLIC S16 PjDlUdxUlFdbkPktInfo(pst, spId, fdbkPktInfo)
+Pst            *pst;
+SpId           spId;
+UdxUlFdbkPktInfo  *fdbkPktInfo;
+#endif
+{
+   PjCb                 *tPjCb;
+   PjDlUeCb             *ueCb;
+   PjDlRbCb             *tRbCb;
+   PjUdxDlSapCb         *udxSap;       /* UDX SAP Control Block */
+   S16                  ret;           /* Return Value */
+   U32                  count;
+   Data                 hdr = 0;
+   Buffer               *rohcFdbPdu = NULLP;
+
+   TRC3(PjDlUdxUlFdbkPktInfo);
+
+   ret = ROK;
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+#ifndef ALIGN_64BIT
+   RLOG1(L_DEBUG, "PjDlUdxUlFdbkPktInfo(pst, spId(%d))", spId);
+#else
+   RLOG1(L_DEBUG, "PjDlUdxUlFdbkPktInfo(pst, spId(%d))", spId);
+#endif
+
+   /* Get the udxSap */
+   udxSap = (tPjCb->u.dlCb->udxDlSap + spId);
+
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret);
+   if (ret != ROK)
+   {
+      /* pj002.201 Freeing from proper region */
+      PJ_FREE_BUF(fdbkPktInfo->fbPkt);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo));
+      RETVALUE(RFAILED);
+   }
+
+   /* Fetch Ue Cb */
+   ret = pjDbmFetchDlUeCb(tPjCb, fdbkPktInfo->pdcpId.ueId, fdbkPktInfo->pdcpId.cellId, &ueCb);
+
+   /* Ue Cb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, fdbkPktInfo->pdcpId.cellId,"UeId[%u] not found",
+            fdbkPktInfo->pdcpId.ueId);
+      PJ_FREE_BUF(fdbkPktInfo->fbPkt);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo));
+      RETVALUE(ret);
+   }
+
+   /* Fetch Rb Cb */
+   PJ_DBM_FETCH_DL_RBCB(fdbkPktInfo->pdcpId.rbId, fdbkPktInfo->pdcpId.rbType, ueCb, tRbCb);
+
+   /* Rb Cb is not present or Rb Cb is not configured for PDCP */
+   if( NULLP == tRbCb )
+   {
+      RLOG_ARG2(L_WARNING, DBG_UEID,fdbkPktInfo->pdcpId.ueId, "CellId[%u]:RbId[%d] not found",
+            fdbkPktInfo->pdcpId.cellId, fdbkPktInfo->pdcpId.rbId);
+      PJ_FREE_BUF(fdbkPktInfo->fbPkt);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo));
+      RETVALUE(RFAILED);
+   }
+   
+   hdr |= PJ_ROHC_FEEDBACK_HDR;
+   rohcFdbPdu = fdbkPktInfo->fbPkt;
+
+   ret = SAddPreMsg((Data) hdr, rohcFdbPdu);
+   if ( ret != ROK )                                      
+   {                                                       
+       RLOG0(L_ERROR, "SAddPreMsg failed for ROHC Feedbck pdu");
+       PJ_FREE_BUF(rohcFdbPdu);
+       RETVALUE(RFAILED);                                    
+   }                                                       
+   
+   if(tRbCb->mode == PJ_DRB_UM)
+   {
+       count = tRbCb->dlCb.nxtToSub - 1; 
+   }
+   else
+   {
+       count = tRbCb->dlCb.cfmExp - 1;
+   }
+   
+   pjDlmSendDatReq(tPjCb, tRbCb, count, rohcFdbPdu);
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo));
+
+   RETVALUE(ROK);
+} /* PjUlUdxUlFdbkPktInfo*/
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for Sending the Feed back Packet Info to Compression entity.
+ *
+ * @b Description:
+ *
+ *        This function is used by PDCP-DL to send Feedback Packet Info to Compression entity. 
+ *
+ *  @param[in] pst   -  Post structure  
+ *  @param[in] spId  -  Serive Provider ID 
+ *  @param[in] fdbkPktInfo   -  Feedback Packet Info. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjDlUdxDlFdbkPktInfo
+(
+Pst             *pst,
+SpId            spId,
+UdxDlFdbkPktInfo   *fdbkPktInfo
+)
+#else
+PUBLIC S16 PjDlUdxDlFdbkPktInfo(pst, spId, fdbkPktInfo)
+Pst            *pst;
+SpId           spId;
+UdxDlFdbkPktInfo  *fdbkPktInfo;
+#endif
+{
+   PjCb                 *tPjCb;
+   PjDlUeCb             *ueCb;
+   PjDlRbCb             *tRbCb;
+   PjUdxDlSapCb         *udxSap;       /* UDX SAP Control Block */
+   S16                  ret;           /* Return Value */
+
+#ifdef PJ_CMP_ASYNC
+   PjLibTrans libTrans; /* Transaction Id for compression */
+#endif /* PJ_SEC_ASYNC */
+
+   TRC3(PjDlUdxDlFdbkPktInfo);
+
+   ret = ROK;
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+#ifndef ALIGN_64BIT
+   RLOG1(L_DEBUG, "PjDlUdxDlFdbkPktInfo(pst, spId(%d))", spId);
+#else
+   RLOG1(L_DEBUG, "PjDlUdxDlFdbkPktInfo(pst, spId(%d))", spId);
+#endif
+
+   /* Get the udxSap */
+   udxSap = (tPjCb->u.dlCb->udxDlSap + spId);
+
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret);
+   if (ret != ROK)
+   {
+      /* pj002.201 Freeing from proper region */
+      PJ_FREE_BUF(fdbkPktInfo->fbPkt);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo));
+      RETVALUE(RFAILED);
+   }
+
+   /* Fetch Ue Cb */
+   ret = pjDbmFetchDlUeCb(tPjCb, fdbkPktInfo->pdcpId.ueId, fdbkPktInfo->pdcpId.cellId, &ueCb);
+
+   /* Ue Cb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, fdbkPktInfo->pdcpId.cellId,"UeId[%u] not found",
+            fdbkPktInfo->pdcpId.ueId);
+      PJ_FREE_BUF(fdbkPktInfo->fbPkt);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo));
+      RETVALUE(ret);
+   }
+
+   /* Fetch Rb Cb */
+   PJ_DBM_FETCH_DL_RBCB(fdbkPktInfo->pdcpId.rbId, fdbkPktInfo->pdcpId.rbType, ueCb, tRbCb);
+
+   /* Rb Cb is not present or Rb Cb is not configured for PDCP */
+   if( NULLP == tRbCb )
+   {
+      RLOG_ARG2(L_WARNING, DBG_UEID,fdbkPktInfo->pdcpId.ueId, "CellId[%u]:RbId[%d] not found",
+            fdbkPktInfo->pdcpId.cellId, fdbkPktInfo->pdcpId.rbId);
+      PJ_FREE_BUF(fdbkPktInfo->fbPkt);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo));
+      RETVALUE(RFAILED);
+   }
+
+#ifdef PJ_CMP_ASYNC
+   /* Assign transId and cxtId */
+   libTrans.count  = tRbCb->dlCb.nxtToSub;
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   libTrans.rbId   = tRbCb->rbId - 1;
+   libTrans.rbType = tRbCb->rbType;
+   libTrans.ueCb   = (PTR)tRbCb->ueCb;
+
+   PjLibObdCmpFbReq(&(tPjCb->pjGenCfg.obdPst.cmpPst), tRbCb->cmpCxtId, libTrans,
+         fdbkPktInfo->fbPkt);
+#else
+   pjLibCmpFbReq(tRbCb->cmpCxtId, fdbkPktInfo->fbPkt);
+#endif
+
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo));
+
+   RETVALUE(ROK);
+} /* PjDlUdxDlFdbkPktInfo*/
+
+
+#ifdef LTE_L2_MEAS
+/**
+*/
+#ifdef ANSI
+PUBLIC S16 PjDlUdxL2MeasReq 
+(
+Pst            *pst, 
+PjL2MeasReqEvt *measReqEvt 
+)
+#else
+PUBLIC S16 PjDlUdxL2MeasReq (pst, measReqEvt)
+Pst            *pst; 
+PjL2MeasReqEvt *measReqEvt;
+#endif
+{
+   U16            cntr;
+   U8             measType;
+
+   PjCb     *tPjCb=NULLP;
+   TRC3(PjDlUdxL2MeasReq);
+
+   tPjCb =  PJ_GET_PJCB(pst->dstInst);
+   /* Initialize measCfmEvt */
+
+
+   measType = measReqEvt->measReq.measType;
+
+   RLOG1(L_DEBUG, "L2_MEAS START Measurement type is %u",
+             measType);
+
+  for(cntr = 0; cntr < LPJ_MAX_QCI; cntr++)
+  {
+     tPjCb->u.dlCb->pjL2Cb.measOn[cntr] |= measType;
+  }
+#ifdef SS_LOCKLESS_MEMORY
+      PJ_FREE_SHRABL_BUF(tPjCb,measReqEvt, sizeof(PjL2MeasReqEvt));
+#else
+      PJ_FREE(tPjCb,measReqEvt, sizeof(PjL2MeasReqEvt));
+#endif
+      /*stoping Task*/
+
+  RETVALUE(ROK);
+} /* KwDlUdxMeasReq */
+
+/**
+@brief 
+This function processes L2 Measurement stop request received from the layer manager.
+After receving this request, RLC stops L2 Measurement
+ *  @param[in] pst      post structure
+ *  @param[in] measType meas Type 
+ *  @return S16
+ *      -# Success : ROK
+ *      -# Failure : RFAILED
+*/
+
+#ifdef ANSI
+PUBLIC S16 PjDlUdxL2MeasStopReq
+(
+Pst   *pst,
+U8    measType
+)
+#else
+PUBLIC S16 PjDlUdxL2MeasStopReq (pst, measType)
+Pst   *pst;
+U8    measType;
+#endif
+{
+   S16 ret = ROK;
+   PjL2MeasEvtCb   *measEvtCb = NULLP;
+   PjL2MeasCb      *measCb    = NULLP;
+   U16             cntr;
+   U8              status = ROK;
+   PjL2MeasCfmEvt  measCfmEvt;  
+   PjCb     *tPjCb=NULLP;
+   TRC3(PjDlUdxMeasStopReq);
+   tPjCb =  PJ_GET_PJCB(pst->dstInst);
+   RLOG0(L_DEBUG, "L2_MEAS Received stopReq\n");
+   cmMemset((U8*)&measCfmEvt, 0, sizeof(PjL2MeasCfmEvt)); 
+   for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++)
+   {
+      measEvtCb = &(tPjCb->u.dlCb->pjL2Cb.pjL2EvtCb[cntr]);
+      if(measEvtCb->measCb.measType & measType)
+      {
+         measCb = &measEvtCb->measCb;
+         pjUtlResetDlL2MeasCntr(tPjCb, measCb, measType);
+
+      }
+   }
+   status = LCM_PRIM_OK; 
+   PjMiLpjL2MeasStopCfm(&tPjCb->pjGenCfg.lmPst, measType,status); 
+   RETVALUE(ret);
+}
+/**
+@brief 
+This function processes L2 Measurement Send request received from the layer manager.
+After receving this request, RLC sends L2 Measurement
+ *  @param[in] pst      post structure
+ *  @param[in] measType meas Type 
+ *  @return S16
+ *      -# Success : ROK
+ *      -# Failure : RFAILED
+*/
+
+#ifdef ANSI
+PUBLIC S16 PjDlUdxL2MeasSendReq
+(
+Pst            *pst,
+U8             measType
+)
+#else
+PUBLIC S16 PjDlUdxL2MeasSendReq (pst, measType)
+Pst            *pst;
+U8             measType;
+#endif
+{
+   S16 ret = ROK;
+   PjL2MeasEvtCb *measEvtCb = NULLP;
+   U16            cntr;
+   PjCb     *tPjCb=NULLP;
+   TRC3(PjDlUdxMeasSendReq);
+
+   tPjCb =  PJ_GET_PJCB(pst->dstInst);
+   RLOG1(L_DEBUG, "L2_MEAS: Sending Meas for meastype %u",
+             measType);
+
+   for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++)
+   {
+      measEvtCb = &(tPjCb->u.dlCb->pjL2Cb.pjL2EvtCb[cntr]);
+      if(measEvtCb->measCb.measType & measType)
+      {
+         pjUtlSndDlL2MeasCfm(tPjCb, measEvtCb);
+
+      }
+   }
+
+   RETVALUE(ret);
+}
+#endif /* LTE_L2_MEAS */
+/**
+@brief 
+This function processes Data Resume request received from the Application.
+ *  @param[in] pst      post structure
+ *  @param[in] measType meas Type 
+ *  @return S16
+ *      -# Success : ROK
+ *      -# Failure : RFAILED
+*/
+
+#ifdef ANSI
+PUBLIC S16 PjDlUdxDatResumeReq
+(
+Pst               *pst,
+UdxDatResumeInfo  *datResumeInfo
+)
+#else
+PUBLIC S16 PjDlUdxDatResumeReq (pst, *datResumeInfo)
+Pst               *pst;
+UdxDatResumeInfo  *datResumeInfo;
+#endif
+{
+   U8 rbCnt;
+   PjDlUeCb *ueCb;
+   PjDlRbCb *pjRbCb;
+   PjCb     *tPjCb;
+   S16       ret;
+   UdxDatResumeCfmInfo  *cfmInfo;
+   PjUdxDlSapCb   *udxSap;
+
+   tPjCb =  PJ_GET_PJCB(pst->dstInst);
+
+   ret = ROK;
+   /* Perform processing for filling up cfm structures */
+   /* Memory leak fix ccpu00135359 */
+   udxSap = &(tPjCb->u.dlCb->udxDlSap[0]);
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfmInfo,
+        sizeof (UdxDatResumeCfmInfo), ret);
+   if(ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeInfo, sizeof(UdxDatResumeInfo));         
+      RETVALUE(RFAILED);
+   }
+
+   cfmInfo->ueId = datResumeInfo->ueId;
+   cfmInfo->cellId = datResumeInfo->cellId;
+   cfmInfo->transId = datResumeInfo->transId;
+   cfmInfo->status = CPJ_CFG_CFM_OK; 
+   cfmInfo->reason = CPJ_CFG_REAS_NONE;
+   
+   ret = pjDbmFetchDlUeCb(tPjCb, datResumeInfo->ueId, 
+                    datResumeInfo->cellId, &ueCb);
+
+   /* Ue Cb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, datResumeInfo->cellId,"UeId[%u] not found",
+            datResumeInfo->ueId);
+      cfmInfo->status = CPJ_CFG_CFM_NOK; 
+      cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN;
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeInfo, sizeof(UdxDatResumeInfo));         
+      /* Send Failure SduStaCfm */
+      PjDlUdxDatResumeCfm(&tPjCb->u.dlCb->udxDlSap[0].pst, 
+                        tPjCb->u.dlCb->udxDlSap[0].suId, cfmInfo);
+      RETVALUE(ret);
+   }
+
+   for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt ++)
+   {
+      /* Check of rbCb available */
+      if( (pjRbCb = ueCb->drbCb[rbCnt]) == NULLP)
+      {
+         continue;
+      }
+  
+      pjDlmRbDataResume(tPjCb,pjRbCb);
+      pjRbCb->state = PJ_STATE_NORMAL;
+   }
+
+   ueCb->libInfo.state = PJ_STATE_NORMAL;
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeInfo, sizeof(UdxDatResumeInfo));         
+   
+   PjDlUdxDatResumeCfm(&tPjCb->u.dlCb->udxDlSap[0].pst, 
+                     tPjCb->u.dlCb->udxDlSap[0].suId, cfmInfo);
+   RETVALUE(ROK);
+}
+
+
+
+/**
+@brief 
+This function processes Start Data Forwarding request received from UL 
+ *  @param[in] pst      post structure
+ *  @param[in] measType meas Type 
+ *  @return S16
+ *      -# Success : ROK
+ *      -# Failure : RFAILED
+*/
+
+#ifdef ANSI
+PUBLIC S16 PjDlUdxDatForwardReq
+(
+Pst                 *pst,
+UdxDatForwardInfo   *datFwdInfo
+)
+#else
+PUBLIC S16 PjDlUdxDatForwardReq (pst, *datFwdInfo)
+Pst                 *pst;
+UdxDatForwardInfo   *datFwdInfo;
+#endif
+{
+   S16 ret;
+   U8 rbCnt;
+   PjDlUeCb *ueCb =NULLP;
+   PjDlRbCb *pjRbCb = NULLP;
+   PjCb     *tPjCb;
+   UdxDatFwdCfmInfo  *cfmInfo = NULLP;
+   PjUdxDlSapCb      *udxSap;
+
+   tPjCb =  PJ_GET_PJCB(pst->dstInst);
+
+   ret = ROK;
+   udxSap = &(tPjCb->u.dlCb->udxDlSap[0]);
+   /* Allocate MEM and fill the DatFwd Cfm Struct */
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfmInfo, 
+      sizeof (UdxDatFwdCfmInfo), ret);
+   if( ret != ROK)
+   {
+      cfmInfo = NULLP;
+#if (ERRCLASS & ERRCLS_DEBUG)
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdInfo, sizeof(UdxDatForwardInfo));         
+      RETVALUE(RFAILED);
+#endif
+   }
+
+   cfmInfo->ueId = datFwdInfo->ueId;
+   cfmInfo->cellId = datFwdInfo->cellId;
+   cfmInfo->status = CPJ_CFG_CFM_OK;
+
+   ret = pjDbmFetchDlUeCb(tPjCb,datFwdInfo->ueId, 
+         datFwdInfo->cellId, &ueCb);
+
+   /* Ue Cb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, datFwdInfo->cellId,"UeId[%u] not found",
+            datFwdInfo->ueId);
+      cfmInfo->status = CPJ_CFG_CFM_NOK;
+      cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN;
+      /* Send Cfm to UL so that it can fwd the UL Pkts */
+      PjDlUdxDatFwdCfm(&tPjCb->u.dlCb->udxDlSap[0].pst,
+                       tPjCb->u.dlCb->udxDlSap[0].suId, cfmInfo);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdInfo, sizeof(UdxDatForwardInfo));         
+      RETVALUE(ret);
+   }
+
+   for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt ++)
+   {
+      /* Check of rbCb available */
+      if( (pjRbCb = ueCb->drbCb[rbCnt]) == NULLP)
+      {
+         continue;
+      }
+
+      if(pjRbCb->mode == PJ_DRB_AM)
+      {
+         pjDlmStartDataFrwdPerRb(tPjCb,pjRbCb);
+      }
+   }
+   /* Send Data Fwd Cfm to the UL PDCP Module
+    * The UL PDCP Module will forward UL Pkts
+    * after receiving this cfm Info */
+   PjDlUdxDatFwdCfm(&tPjCb->u.dlCb->udxDlSap[0].pst,
+         tPjCb->u.dlCb->udxDlSap[0].suId, cfmInfo);
+
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdInfo, sizeof(UdxDatForwardInfo));         
+   RETVALUE(ROK);
+
+}
+
+
+
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_udx_ptdl.c b/src/5gnrpdcp/pj_udx_ptdl.c
new file mode 100755 (executable)
index 0000000..fffbe6c
--- /dev/null
@@ -0,0 +1,752 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE-PDCP Layer - Upper Interface
+    
+        Type:    C file
+  
+        Desc:    C source code for the upper interface of LTE-PDCP
+        File:    pj_udx_ptdl.c
+  
+*********************************************************************21*/
+
+/** @file pj_udx_ptdl.c
+@brief PDCP Upper Interface
+*/
+
+\f
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "cpj.h"           /* UDX defines */
+#include "pju.h"           /* PJU defines */
+#include "lpj.h"
+
+#include "pj_err.h"
+#include "pj_env.h"        /* RLC environment options */
+#include "pj_udx.h"
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "cpj.x"           /* UDX defines */
+#include "pju.x"           /* PJU defines */
+#include "lpj.x"           /* LPJ defines */
+#include "pj.h"
+#include "pj.x"
+#include "pj_udx.x"
+
+
+#if !(defined(LCPJULUDX)  && defined(PJ))
+#define PTPJUDX
+#endif
+
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif /* __cplusplus */
+
+\f  
+/*********************************************************************
+ *             Forward Declartion for UDX Porting Functions
+ ********************************************************************/
+#ifdef PTPJUDX
+
+EXTERN S16 PtDlUdxBndCfm ARGS((Pst * pst, SuId suId, U8 status));
+
+EXTERN S16 PtDlUdxCfgCfm ARGS((Pst * pst, SuId suId, UdxCfgCfmInfo * cfgCfm));
+
+EXTERN S16 PtDlUdxReEstCfm ARGS((Pst * pst, SuId suId, UdxReEstCfmInfo * reEstCfm));
+
+EXTERN S16 PtDlUdxSecCfgCfm ARGS((Pst * pst, SuId suId, UdxSecCfgCfmInfo * secCfgCfm));
+
+EXTERN S16 PtDlUdxUeIdChgCfm ARGS((Pst * pst, SuId suId, U32 transId, UdxUeInfo  * ueInfo, CmStatus status));
+
+EXTERN S16 PtDlUdxCountCfm ARGS((Pst * pst, SuId suId, UdxCountCfmInfo * countCfm));
+
+EXTERN S16 PtDlUdxSduStaCfm ARGS((Pst * pst, SuId suId, UdxSduStaCfmInfo * staCfm));
+
+EXTERN S16 PtDlUdxDatResumeCfm ARGS((Pst * pst, SuId suId, UdxDatResumeCfmInfo * datResume));
+
+EXTERN S16 PtDlUdxDatForwardCfm ARGS((Pst * pst, SuId suId, UdxDatFwdCfmInfo * datFwdCfm));
+#endif /* PTPJUDX */
+
+\f  
+/*********************************************************************
+ *             Forward Declartion for PJU Porting Functions
+ ********************************************************************/
+
+\f  
+/*********************************************************************
+ *                         Primitives for UDX interface 
+ ********************************************************************/
+PRIVATE CONSTANT UdxBndCfm PjDlUdxBndCfmMt[] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxBndCfm,
+#else
+   PtDlUdxBndCfm,
+#endif
+#ifdef LWLCPJULUDX
+   cmPkPjUdxBndCfm,
+#else
+   PtDlUdxBndCfm,
+#endif
+#ifdef PJ
+   PjUlUdxBndCfm,
+#else
+   PtDlUdxBndCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT UdxCfgCfm PjDlUdxCfgCfmMt[] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxCfgCfm,
+#else
+   PtDlUdxCfgCfm,
+#endif
+#ifdef LWLCPJULUDX
+   cmPkPjUdxCfgCfm,
+#else
+   PtDlUdxCfgCfm,
+#endif
+#ifdef PJ
+   PjUlUdxCfgCfm,
+#else
+   PtDlUdxCfgCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT UdxReEstCfm PjDlUdxReEstCfmMt[] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxReEstCfm,
+#else
+   PtDlUdxReEstCfm,
+#endif
+#ifdef LWLCPJULUDX
+   cmPkPjUdxReEstCfm,
+#else
+   PtDlUdxReEstCfm,
+#endif
+#ifdef PJ
+   PjUlUdxReEstCfm,
+#else
+   PtDlUdxReEstCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT UdxSecCfgCfm PjDlUdxSecCfgCfmMt[] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxSecCfgCfm,
+#else
+   PtDlUdxSecCfgCfm,
+#endif
+#ifdef LWLCPJULUDX
+   cmPkPjUdxSecCfgCfm,
+#else
+   PtDlUdxSecCfgCfm,
+#endif
+#ifdef PJ
+   PjUlUdxSecCfgCfm,
+#else
+   PtDlUdxSecCfgCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT UdxUeIdChgCfm PjDlUdxUeIdChgCfmMt[] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxUeIdChgCfm,
+#else
+   PtDlUdxUeIdChgCfm,
+#endif
+#ifdef LWLCPJULUDX
+   cmPkPjUdxUeIdChgCfm,
+#else
+   PtDlUdxUeIdChgCfm,
+#endif
+#ifdef PJ
+   PjUlUdxUeIdChgCfm,
+#else
+   PtDlUdxUeIdChgCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT UdxCountCfm PjDlUdxCountCfmMt[] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxCountCfm,
+#else
+   PtDlUdxCountCfm,
+#endif
+#ifdef LWLCPJULUDX
+   cmPkPjUdxCountCfm,
+#else
+   PtDlUdxCountCfm,
+#endif
+#ifdef PJ
+   PjUlUdxCountCfm,
+#else
+   PtDlUdxCountCfm,
+#endif
+};
+
+
+PRIVATE CONSTANT UdxSduStaCfm PjDlUdxSduStaCfmMt[] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxSduStaCfm,
+#else
+   PtDlUdxSduStaCfm,
+#endif
+#ifdef LWLCPJULUDX
+   cmPkPjUdxSduStaCfm,
+#else
+   PtDlUdxSduStaCfm,
+#endif
+#ifdef PJ
+   PjUlUdxSduStaCfm,
+#else
+   PtDlUdxSduStaCfm,
+#endif
+};
+
+PRIVATE CONSTANT UdxDatResumeCfm PjDlUdxDatResumeCfmMt[] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxDatResumeCfm,
+#else
+   PtDlUdxDatResumeCfm,
+#endif
+#ifdef LWLCPJULUDX
+   cmPkPjUdxDatResumeCfm,
+#else
+   PtDlUdxDatResumeCfm,
+#endif
+#ifdef PJ
+   PjUlUdxDatResumeCfm,
+#else
+   PtDlUdxDatResumeCfm,
+#endif
+};
+
+PRIVATE CONSTANT UdxDatForwardCfm PjDlUdxDatFwdCfmMt[] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxDatForwardCfm,
+#else
+   PtDlUdxDatForwardCfm,
+#endif
+#ifdef LWLCPJULUDX
+   cmPkPjUdxDatForwardCfm,
+#else
+   PtDlUdxDatForwardCfm,
+#endif
+#ifdef PJ
+   PjUlUdxDatForwardCfm,
+#else
+   PtDlUdxDatForwardCfm,
+#endif
+};
+
+\f  
+/****************************************************************************
+ *                         UDX Interface Mt functions
+ ***************************************************************************/\f
+#ifdef PJ
+#ifdef ANSI
+PUBLIC S16 PjDlUdxBndCfm
+(
+Pst * pst,
+SuId suId,
+U8 status
+)
+#else
+PUBLIC S16 PjDlUdxBndCfm(pst, suId, status)
+Pst * pst;
+SuId suId;
+U8 status;
+#endif
+{
+
+   TRC3(PjDlUdxBndCfm)
+
+   (*PjDlUdxBndCfmMt[pst->selector])(pst, suId, status);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjDlUdxCfgCfm
+(
+Pst * pst,
+SuId suId,
+UdxCfgCfmInfo * cfgCfm
+)
+#else
+PUBLIC S16 PjDlUdxCfgCfm(pst, suId, cfgCfm)
+Pst * pst;
+SuId suId;
+UdxCfgCfmInfo * cfgCfm;
+#endif
+{
+
+   TRC3(PjDlUdxCfgCfm)
+
+   (*PjDlUdxCfgCfmMt[pst->selector])(pst, suId, cfgCfm);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjDlUdxReEstCfm
+(
+Pst * pst,
+SuId suId,
+UdxReEstCfmInfo * reEstCfm
+)
+#else
+PUBLIC S16 PjDlUdxReEstCfm(pst, suId, reEstCfm)
+Pst * pst;
+SuId suId;
+UdxReEstCfmInfo * reEstCfm;
+#endif
+{
+
+   TRC3(PjDlUdxReEstCfm)
+
+   (*PjDlUdxReEstCfmMt[pst->selector])(pst, suId, reEstCfm);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjDlUdxSecCfgCfm
+(
+Pst * pst,
+SuId suId,
+UdxSecCfgCfmInfo * secCfgCfm
+)
+#else
+PUBLIC S16 PjDlUdxSecCfgCfm(pst, suId, secCfgCfm)
+Pst * pst;
+SuId suId;
+UdxSecCfgCfmInfo * secCfgCfm;
+#endif
+{
+
+   TRC3(PjDlUdxSecCfgCfm)
+
+   (*PjDlUdxSecCfgCfmMt[pst->selector])(pst, suId, secCfgCfm);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjDlUdxUeIdChgCfm
+(
+Pst * pst,
+SuId suId,
+U32 transId,
+UdxUeInfo  * ueInfo,
+CmStatus status
+)
+#else
+PUBLIC S16 PjDlUdxUeIdChgCfm(pst, suId, transId, ueInfo, status)
+Pst * pst;
+SuId suId;
+U32 transId;
+UdxUeInfo  * ueInfo;
+CmStatus status;
+#endif
+{
+
+   TRC3(PjDlUdxUeIdChgCfm)
+
+   (*PjDlUdxUeIdChgCfmMt[pst->selector])(pst, suId, transId, ueInfo, status);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjDlUdxCountCfm
+(
+Pst * pst,
+SuId suId,
+UdxCountCfmInfo * countCfm
+)
+#else
+PUBLIC S16 PjDlUdxCountCfm(pst, suId, countCfm)
+Pst * pst;
+SuId suId;
+UdxCountCfmInfo * countCfm;
+#endif
+{
+
+   TRC3(PjDlUdxCountCfm)
+
+   (*PjDlUdxCountCfmMt[pst->selector])(pst, suId, countCfm);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjDlUdxSduStaCfm
+(
+Pst * pst,
+SuId suId,
+UdxSduStaCfmInfo * staCfm
+)
+#else
+PUBLIC S16 PjDlUdxSduStaCfm(pst, suId, staCfm)
+Pst * pst;
+SuId suId;
+UdxSduStaCfmInfo * staCfm;
+#endif
+{
+
+   TRC3(PjDlUdxSduStaCfm)
+
+   (*PjDlUdxSduStaCfmMt[pst->selector])(pst, suId, staCfm);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjDlUdxDatResumeCfm
+(
+Pst * pst,
+SuId suId,
+UdxDatResumeCfmInfo * staCfm
+)
+#else
+PUBLIC S16 PjDlUdxDatResumeCfm(pst, suId, staCfm)
+Pst * pst;
+SuId suId;
+UdxDatResumeCfmInfo * staCfm;
+#endif
+{
+
+   TRC3(PjDlUdxDatResumeCfm)
+
+   (*PjDlUdxDatResumeCfmMt[pst->selector])(pst, suId, staCfm);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjDlUdxDatFwdCfm
+(
+Pst * pst,
+SuId  suId,
+UdxDatFwdCfmInfo  * datFwdCfm
+)
+#else
+PUBLIC S16 PjDlUdxDatFwdCfm(pst, suId, datFwdCfm)
+Pst * pst;
+SuId  suId;
+UdxDatFwdCfmInfo  * datFwdCfm;
+#endif
+{
+
+   TRC3(PjDlUdxDatFwdCfm)
+
+   (*PjDlUdxDatFwdCfmMt[pst->selector])(pst, suId, datFwdCfm);
+
+   RETVALUE(ROK);
+}
+#endif
+\f  
+/*************************************************************************
+ *                         UDX Porting Functions
+ ************************************************************************/
+#ifdef PTPJUDX
+
+#ifdef ANSI
+PUBLIC S16 PtDlUdxBndCfm
+(
+Pst * pst,
+SuId suId,
+U8 status
+)
+#else
+PUBLIC S16 PtDlUdxBndCfm(pst, suId, status)
+Pst * pst;
+SuId suId;
+U8 status;
+#endif
+{
+
+   TRC3(PtDlUdxBndCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(status);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtDlUdxCfgCfm
+(
+Pst * pst,
+SuId suId,
+UdxCfgCfmInfo * cfgCfm
+)
+#else
+PUBLIC S16 PtDlUdxCfgCfm(pst, suId, cfgCfm)
+Pst * pst;
+SuId suId;
+UdxCfgCfmInfo * cfgCfm;
+#endif
+{
+
+   TRC3(PtDlUdxCfgCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(cfgCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtDlUdxReEstCfm
+(
+Pst * pst,
+SuId suId,
+UdxReEstCfmInfo * reEstCfm
+)
+#else
+PUBLIC S16 PtDlUdxReEstCfm(pst, suId, reEstCfm)
+Pst * pst;
+SuId suId;
+UdxReEstCfmInfo *reEstCfm;
+#endif
+{
+
+   TRC3(PtDlUdxReEstCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(reEstCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtDlUdxSecCfgCfm
+(
+Pst * pst,
+SuId suId,
+UdxSecCfgCfmInfo * secCfgCfm
+)
+#else
+PUBLIC S16 PtDlUdxSecCfgCfm(pst, suId, secCfgCfm)
+Pst * pst;
+SuId suId;
+UdxSecCfgCfmInfo * secCfgCfm;
+#endif
+{
+
+   TRC3(PtDlUdxSecCfgCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(secCfgCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtDlUdxUeIdChgCfm
+(
+Pst * pst,
+SuId suId,
+U32 transId,
+UdxUeInfo  * ueInfo,
+CmStatus status
+)
+#else
+PUBLIC S16 PtDlUdxUeIdChgCfm(pst, suId, transId, ueInfo, status)
+Pst * pst;
+SuId suId;
+U32 transId;
+UdxUeInfo  * ueInfo;
+CmStatus status;
+#endif
+{
+
+   TRC3(PtDlUdxUeIdChgCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(transId);
+   UNUSED(ueInfo);
+   UNUSED(status);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtDlUdxCountCfm
+(
+Pst * pst,
+SuId suId,
+UdxCountCfmInfo * countCfm
+)
+#else
+PUBLIC S16 PtDlUdxCountCfm(pst, suId, countCfm)
+Pst * pst;
+SuId suId;
+UdxCountCfmInfo * countCfm;
+#endif
+{
+
+   TRC3(PtDlUdxCountCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(countCfm);
+
+   RETVALUE(ROK);
+
+}
+
+
+#ifdef ANSI
+PUBLIC S16 PtDlUdxSduStaCfm
+(
+Pst * pst,
+SuId suId,
+UdxSduStaCfmInfo * staCfm
+)
+#else
+PUBLIC S16 PtDlUdxSduStaCfm(pst, suId, staCfm)
+Pst * pst;
+SuId suId;
+UdxSduStaCfmInfo * staCfm;
+#endif
+{
+
+   TRC3(PtDlUdxSduStaCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(staCfm);
+
+   RETVALUE(ROK);
+
+}
+
+#ifdef ANSI
+PUBLIC S16 PtDlUdxDatResumeCfm
+(
+Pst * pst,
+SuId suId,
+UdxDatResumeCfmInfo * staCfm
+)
+#else
+PUBLIC S16 PtDlUdxDatResumeCfm(pst, suId, staCfm)
+Pst * pst;
+SuId suId;
+UdxDatResumeCfmInfo * staCfm;
+#endif
+{
+
+   TRC3(PtDlUdxDatResumeCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(staCfm);
+
+   RETVALUE(ROK);
+
+}
+
+#ifdef ANSI
+PUBLIC S16 PtDlUdxDatForwardCfm
+(
+ Pst               *pst,
+ SuId              suId,
+ UdxDatFwdCfmInfo  *datFwdCfm
+ )
+#else
+PUBLIC S16 PtDlUdxDatForwardCfm(pst, suId, datFwdCfm)
+   Pst               *pst;
+   SuId              suId;
+   UdxDatFwdCfmInfo  *datFwdCfm;
+#endif
+{
+
+   TRC3(PtDlUdxDatForwardCfm)
+
+   UNUSED(pst);
+   UNUSED(suId);
+   UNUSED(datFwdCfm); 
+
+   RETVALUE(ROK);
+}
+#endif /*--ifdef PTPJUDX--*/
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_udx_ptul.c b/src/5gnrpdcp/pj_udx_ptul.c
new file mode 100755 (executable)
index 0000000..e46c921
--- /dev/null
@@ -0,0 +1,1632 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE-PDCP Layer - Upper Interface
+    
+        Type:    C file
+  
+        Desc:    C source code for the upper interface of LTE-PDCP
+        File:    pj_udx_ptul.c
+  
+*********************************************************************21*/
+
+/** @file pj_udx_ptul.c
+@brief PDCP Upper Interface
+*/
+
+\f
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "cpj.h"           /* UDX defines */
+#include "pju.h"           /* PJU defines */
+#include "lpj.h"
+#include "pj_udx.h"
+
+#include "pj_err.h"
+#include "pj_env.h"        /* RLC environment options */
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "cpj.x"           /* UDX defines */
+#include "pju.x"           /* PJU defines */
+#include "lpj.x"           /* LPJ defines */
+#include "pj.h"
+#include "pj.x"
+#include "pj_udx.x"
+#include "pj_ul.x"
+
+
+#if !(defined(LCPJULUDX)  && defined(PJ) && defined(LWLCPJULUDX))
+#define PTPJULUDX
+#endif
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif /* __cplusplus */
+
+#ifdef PTPJULUDX
+PRIVATE S16 PtUlUdxBndReq ARGS((Pst *post, SuId suId, SpId spId));
+PRIVATE S16 PtUlUdxUbndReq ARGS((Pst *post, SpId spId, Reason reason));
+PRIVATE S16 PtUlUdxCfgReq ARGS((Pst *post, SpId spId, UdxCfgReqInfo *pdCfgReq));
+PRIVATE S16 PtUlUdxUeIdChgReq ARGS((Pst *post, SpId spId,U32 transId, 
+                                    UdxUeInfo *oldUeInfo,
+                                    UdxUeInfo *newUeInfo));
+
+PRIVATE S16 PtUlUdxSecCfgReq ARGS((Pst *post, SpId spId, 
+                                   UdxSecCfgReqInfo *pdcpSecCfgReq));
+PRIVATE S16 PtUlUdxCountReq ARGS((Pst *post, SpId spId, 
+                                   UdxCountReqInfo *pdcpCountReq));
+PRIVATE S16 PtUlUdxReEstReq ARGS(( Pst *post, SpId spId,
+                                   UdxReEstReqInfo *restbInfo));
+PRIVATE S16 PtUlUdxSduStaReq ARGS(( Pst *post, SpId spId,
+                                   UdxSduStaReqInfo *statReqInfo));
+
+PRIVATE S16 PtUlUdxUlStaRep ARGS ((
+         Pst *post,                      /* Post structure */
+         SpId spId,                      /* Service provider ID */
+         UdxUlStaRepInfo *pdStaRep         /* PDCP UL ot PDCP DL Reestablishment trigger */
+         ));
+PRIVATE S16 PtUlUdxDlStaRep ARGS ((
+         Pst *post,                      /* Post structure */
+         SpId spId,                      /* Service provider ID */
+         UdxDlStaRepInfo *pdStaRep       /* Status report from PDCP UL to PDCP DL */
+         ));
+
+PRIVATE S16 PtUlUdxUlFdbkPktInfo ARGS ((
+         Pst *post,                      /* Post structure */
+         SpId spId,                      /* Service provider ID */
+         UdxUlFdbkPktInfo  *fdbkPktInfo    /* feedback Packet Info */
+            ));
+
+PRIVATE S16 PtUlUdxDlFdbkPktInfo ARGS ((
+         Pst *post,                      /* Post structure */
+         SpId spId,                      /* Service provider ID */
+         UdxDlFdbkPktInfo  *fdbkPktInfo    /* feedback Packet Info */
+            ));
+#ifdef LTE_L2_MEAS
+PRIVATE S16  PtUlUdxL2MeasReq ARGS ((
+         Pst *pst,
+         PjL2MeasReqEvt *measReqEvt
+         ));
+PRIVATE S16  PtUlUdxL2MeasSendReq ARGS((
+         Pst *pst,
+         U8 status
+         ));
+PRIVATE S16  PtUlUdxL2MeasStopReq ARGS((
+         Pst *pst,
+         U8  status
+         ));
+#endif
+PRIVATE S16  PtUlUdxDatResumeReq ARGS((
+         Pst           *pst,
+         UdxDatResumeInfo  *udxDatResumeInfo
+         ));
+PRIVATE S16  PtUlUdxDatForwardReq ARGS((
+         Pst           *pst,
+         UdxDatForwardInfo  *udxDatForwardInfo
+         ));
+#endif /* PTPJULUDX */
+
+\f
+/**************************************************************************
+ * UDX Interface Matrices
+ *************************************************************************/
+
+/* UDX Interface Bind Request primitive */
+PRIVATE CONSTANT UdxBndReq PjUlUdxBndReqMt [PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxBndReq,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxBndReq,          /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+   cmPkPjUdxBndReq,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxBndReq,          /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ
+   PjDlUdxBndReq,          /* 2 - tightly coupled, CTC */
+#else /* PJ */
+   PtUlUdxBndReq,          /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+
+/* UDX Interface Unbind Request primitive */
+PRIVATE CONSTANT UdxUbndReq PjUlUdxUbndReqMt [PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+ cmPkPjUdxUbndReq,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+ PtUlUdxUbndReq,          /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+ cmPkPjUdxUbndReq,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+ PtUlUdxUbndReq,          /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ 
+ PjDlUdxUbndReq,          /* 2 - tightly coupled, UDX */
+#else /* PJ */
+ PtUlUdxUbndReq,          /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+
+/* UDX Interface Config Request primitive */
+PRIVATE CONSTANT UdxCfgReq PjUlUdxCfgReqMt [PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+ cmPkPjUdxCfgReq,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+ PtUlUdxCfgReq,          /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+ cmPkPjUdxCfgReq,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+ PtUlUdxCfgReq,          /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ
+ PjDlUdxCfgReq,          /* 2 - tightly coupled, UDX */
+#else /* PJ */
+ PtUlUdxCfgReq,          /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+
+/* UDX Interface Status Report from PDCP-UL to PDCP-DL primitive */
+PRIVATE CONSTANT UdxUlStaRep PjUlUdxUlStaRepMt [PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+ cmPkPjUdxUlStaRep,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+ PtUlUdxUlStaRep,          /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+ cmPkPjUdxUlStaRep,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+ PtUlUdxUlStaRep,          /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ
+ PjDlUdxUlStaRep,          /* 2 - tightly coupled, UDX */
+#else /* PJ */
+ PtUlUdxUlStaRep,          /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+
+/* UDX Interface Status Report from PDCP-UL to PDCP-DL primitive */
+PRIVATE CONSTANT UdxDlStaRep PjUlUdxDlStaRepMt [PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+ cmPkPjUdxDlStaRep,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+ PtUlUdxDlStaRep,          /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+ cmPkPjUdxDlStaRep,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+ PtUlUdxDlStaRep,          /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ
+ PjDlUdxDlStaRep,          /* 2 - tightly coupled, UDX */
+#else /* PJ */
+ PtUlUdxDlStaRep,          /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+
+/* UDX Interface Status Report from PDCP-UL to PDCP-DL primitive */
+PRIVATE CONSTANT UdxDlFdbkPkt PjUlUdxDlFdbkPktInfoMt [PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+ cmPkPjUdxDlFdbkPkt,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+ PtUlUdxDlFdbkPktInfo,          /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+ cmPkPjUdxDlFdbkPkt,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+ PtUlUdxDlFdbkPktInfo,          /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ
+ PjDlUdxDlFdbkPktInfo,          /* 2 - tightly coupled, UDX */
+#else /* PJ */
+ PtUlUdxDlFdbkPktInfo,          /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+
+
+/* UDX Interface Feedback Pkt Info from PDCP-UL to PDCP-DL primitive */
+PRIVATE CONSTANT UdxUlFdbkPkt PjUlUdxUlFdbkPktInfoMt [3] =
+{
+#ifdef LCPJULUDX
+    cmPkPjUdxUlFdbkPkt,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+    PtUlUdxUlFdbkPktInfo,      /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+    cmPkPjUdxUlFdbkPkt,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+    PtUlUdxUlFdbkPktInfo,      /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ
+    PjDlUdxUlFdbkPktInfo,        /* 2 - tightly coupled, UDX */
+#else /* PJ */
+    PtUlUdxUlFdbkPktInfo,      /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+
+/* UDX Interface UE Id Change Request primitive */
+PRIVATE CONSTANT UdxUeIdChgReq PjUlUdxUeIdChgReqMt [PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxUeIdChgReq,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxUeIdChgReq,          /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+   cmPkPjUdxUeIdChgReq,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxUeIdChgReq,          /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ
+   PjDlUdxUeIdChgReq,          /* 2 - tightly coupled, UDX */
+#else /* PJ */
+   PtUlUdxUeIdChgReq,          /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+
+/* UDX Interface Security Config Request primitive */
+PRIVATE CONSTANT UdxSecCfgReq PjUlUdxSecCfgReqMt [PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxSecCfgReq,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxSecCfgReq,          /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+   cmPkPjUdxSecCfgReq,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxSecCfgReq,          /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ
+   PjDlUdxSecCfgReq,          /* 2 - tightly coupled, UDX */
+#else /* PJ */
+   PtUlUdxSecCfgReq,          /* 2 - tightly coupled, portable */
+#endif/* PJ */
+};
+
+/* UDX Interface COUNT Request primitive */
+PRIVATE CONSTANT UdxCountReq PjUlUdxCountReqMt [PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxCountReq,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxCountReq,          /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+   cmPkPjUdxCountReq,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxCountReq,          /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ
+   PjDlUdxCountReq,          /* 2 - tightly coupled, UDX */
+#else /* PJ */
+   PtUlUdxCountReq,          /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+
+/* UDX Interface PDCP Status Request primitive */
+PRIVATE CONSTANT UdxSduStaReq PjUlUdxSduStaReqMt [PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxSduStaReq,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxSduStaReq,          /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+   cmPkPjUdxSduStaReq,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxSduStaReq,          /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ
+   PjDlUdxSduStaReq,          /* 2 - tightly coupled, UDX */
+#else /* PJ */
+   PtUlUdxSduStaReq,          /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+
+/* UDX Interface Re-Establishment Request primitive */
+PRIVATE CONSTANT UdxReEstReq PjUlUdxReEstReqMt [PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxReEstReq,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxReEstReq,          /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+   cmPkPjUdxReEstReq,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxReEstReq,          /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ
+   PjDlUdxReEstReq,          /* 2 - tightly coupled, UDX */
+#else /* PJ */
+   PtUlUdxReEstReq,          /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+
+#ifdef LTE_L2_MEAS
+PRIVATE CONSTANT UdxL2MeasReq pjUlUdxL2MeasReqMt[PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxL2MeasReq,            /* 0 - loosely coupled */
+#else
+   PtUlUdxL2MeasReq,            /* 0 - loosely coupled, portable  */
+#endif /* LCKWUIKWU */
+#ifdef LWLCPJULUDX
+   cmPkPjUdxL2MeasReq,            /* 1 - loosely coupled */
+#else
+   PtUlUdxL2MeasReq,            /* 1 - loosely coupled, portable  */
+#endif /* LCKWUIKWU */
+#ifdef PJ
+   PjDlUdxL2MeasReq,            /* 2 - tightly coupled, RRC  */
+#else
+   PtUlUdxL2MeasReq,            /* 2 - tightly coupled, portable */
+#endif /* KW */
+};
+
+PRIVATE CONSTANT UdxL2MeasSendReq pjUlUdxL2MeasSendReqMt[PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxL2MeasSendReq,            /* 0 - loosely coupled */
+#else
+   PtUlUdxL2MeasSendReq,            /* 0 - loosely coupled, portable  */
+#endif /* LCKWUIKWU */
+#ifdef LWLCPJULUDX
+   cmPkPjUdxL2MeasSendReq,            /* 1 - loosely coupled */
+#else
+   PtUlUdxL2MeasSendReq,            /* 1 - loosely coupled, portable  */
+#endif /* LCKWUIKWU */
+#ifdef PJ
+   PjDlUdxL2MeasSendReq,            /* 2 - tightly coupled, RRC  */
+#else
+   PtUlUdxL2MeasSendReq,            /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+
+PRIVATE CONSTANT UdxL2MeasStopReq pjUlUdxL2MeasStopReqMt[PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxL2MeasStopReq,            /* 0 - loosely coupled */
+#else
+   PtUlUdxL2MeasStopReq,            /* 0 - loosely coupled, portable  */
+#endif /* LCKWUIKWU */
+#ifdef LWLCPJULUDX
+   cmPkPjUdxL2MeasStopReq,            /* 1 - loosely coupled */
+#else
+   PtUlUdxL2MeasStopReq,            /* 1 - loosely coupled, portable  */
+#endif /* LCKWUIKWU */
+#ifdef PJ
+   PjDlUdxL2MeasStopReq,            /* 2 - tightly coupled, RRC  */
+#else
+   PtUlUdxL2MeasStopReq,            /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+#endif
+
+
+/* UDX Interface PDCP Status Request primitive */
+PRIVATE CONSTANT UdxDatResumeReq pjUlUdxDatResumeReqMt [PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxDatResumeReq,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxDatResumeReq,          /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+   cmPkPjUdxDatResumeReq,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxDatResumeReq,          /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ
+   PjDlUdxDatResumeReq,          /* 2 - tightly coupled, UDX */
+#else /* PJ */
+   PtUlUdxDatResumeReq,          /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+
+
+/* UDX Interface PDCP Start Data Forward primitive */
+PRIVATE CONSTANT UdxDatForwardReq pjUlUdxDatForwardReqMt [PJ_MAX_UDX] =
+{
+#ifdef LCPJULUDX
+   cmPkPjUdxDatForwardReq,          /* 0 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxDatForwardReq,          /* 0 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef LWLCPJULUDX
+   cmPkPjUdxDatForwardReq,          /* 1 - loosely coupled */
+#else /* LCPJULUDX */
+   PtUlUdxDatForwardReq,          /* 1 - loosely coupled, portable */
+#endif /* LCPJULUDX */
+#ifdef PJ
+   PjDlUdxDatForwardReq,          /* 2 - tightly coupled, UDX */
+#else /* PJ */
+   PtUlUdxDatForwardReq,          /* 2 - tightly coupled, portable */
+#endif /* PJ */
+};
+\f
+/**************************************************************************
+ * The UDX Interface
+ *************************************************************************/
+/**
+ *
+ *   @brief  This function binds the RRC service user with the PDCP 
+ *             service provider.
+ *
+ *   @details  This function binds the RRC service user with the PDCP 
+ *             service provider. The PDCP registers this new service 
+ *             user and allocates a Service Access Point (SAP) for 
+ *             this bind. The service user specifies the reference 
+ *             number that is used for the duration of this bind.
+ */
+#ifdef ANSI
+PUBLIC S16 PjUlUdxBndReq
+(
+Pst *post,                       /* Post structure */
+SuId suId,                      /* Service user ID */
+SpId spId                       /* Service provider ID */
+)
+#else /* ANSI */
+PUBLIC S16 PjUlUdxBndReq(post, suId, spId)
+Pst *post;                       /* Post structure */
+SuId suId;                      /* Service user ID */
+SpId spId;                      /* Service provider ID */
+#endif /* ANSI */
+{
+
+   TRC3(PjUlUdxBndReq);
+
+   RETVALUE((*PjUlUdxBndReqMt[post->selector])(post, suId, spId));
+
+} /* end of function PjUlUdxBndReq */
+
+\f
+/*
+*      @brief  This function unbinds the RRC service user with the PDCP 
+*             service provider. 
+*
+*      @details This function unbinds the RRC service user with the PDCP 
+*             service provider. 
+*
+*/
+#ifdef ANSI
+PUBLIC S16 PjUlUdxUbndReq
+(
+Pst *post,                       /* Post structure */
+SpId spId,                      /* Service provider ID */
+Reason reason                   /* Reason */
+)
+#else /* ANSI */
+PUBLIC S16 PjUlUdxUbndReq(post, spId, reason)
+Pst *post;                       /* Post structure */
+SpId spId;                      /* Service provider ID */
+Reason reason;                  /* Reason */
+#endif /* ANSI */
+{
+
+   TRC3(PjUlUdxUbndReq);
+
+   RETVALUE((*PjUlUdxUbndReqMt[post->selector])(post, spId, reason));
+
+} /* end of function PjUlUdxUbndReq */
+
+\f
+/**
+*
+*      @brief  This function is used to pass Signalling Info to PDCP related 
+*             to PDCP configuration.
+*
+*      @details This function is used to pass signaling Info to PDCP related 
+*             to PDCP configuration.
+*
+*/
+#ifdef ANSI
+PUBLIC S16 PjUlUdxCfgReq
+(
+Pst *post,                       /* Post structure */
+SpId spId,                      /* Service provider ID */
+UdxCfgReqInfo *pdCfgReq              /* PDCP Config parameters */
+)
+#else /* ANSI */
+PUBLIC S16 PjUlUdxCfgReq(post, spId, pdCfgReq)
+Pst *post;                       /* Post structure */
+SpId spId;                      /* Service provider ID */
+UdxCfgReqInfo *pdCfgReq;             /* PDCP Config parameters */
+#endif /* ANSI */
+{
+
+  TRC3(PjUlUdxCfgReq);
+
+
+  RETVALUE((*PjUlUdxCfgReqMt[post->selector])(post, spId, pdCfgReq));
+
+} /* end of function PjUlUdxCfgReq */
+
+
+/**
+*
+*      @brief  This function is used to sent the PDCP STATUS report to PDCP-DL during the Reestablishment.
+*      @details This function is used to sent the PDCP STATUS report to PDCP-DL during the Reestablishment
+*
+*/
+#ifdef ANSI
+PUBLIC S16 PjUlUdxUlStaRep
+(
+Pst *pst,                       /* Post structure */
+SpId spId,                      /* Service provider ID */
+UdxUlStaRepInfo *staRep           /*PDCP Status Report*/
+)
+#else /* ANSI */
+PUBLIC S16 PjUlUdxUlStaRep (pst, spId, staRep)
+Pst *pst;                       /* Post structure */
+SpId spId;                      /* Service provider ID */
+UdxUlStaRepInfo *staRep;          /* PDCP Status Report*/
+#endif /* ANSI */
+{
+
+  TRC3(PjUlUdxUlStaRep);
+
+  RETVALUE((*PjUlUdxUlStaRepMt[pst->selector])(pst, spId, staRep));
+
+} /* end of function PjUlUdxUlStaRep */
+
+/**
+*
+*      @brief  This function is used to sent the PDCP STATUS report received from peer RLC to PDCP-DL.
+*      @details This function is used to sent the PDCP STATUS report received from peer RLC to PDCP-DL
+*
+*/
+#ifdef ANSI
+PUBLIC S16 PjUlUdxDlStaRep
+(
+Pst *pst,                       /* Post structure */
+SpId spId,                      /* Service provider ID */
+UdxDlStaRepInfo *staRep           /*PDCP Status Report*/
+)
+#else /* ANSI */
+PUBLIC S16 PjUlUdxDlStaRep (pst, spId, staRep)
+Pst *pst;                       /* Post structure */
+SpId spId;                      /* Service provider ID */
+UdxDlStaRepInfo *staRep;          /* PDCP Status Report*/
+#endif /* ANSI */
+{
+
+  TRC3(PjUlUdxDlStaRep);
+
+  RETVALUE((*PjUlUdxDlStaRepMt[pst->selector])(pst, spId, staRep));
+
+} /* end of function PjUlUdxUlStaRep */
+
+/**
+*
+*      @brief  This function is used to sent the ROHC feedback report received from peer PDCP to PDCP-DL
+*      @details This function is used to sent the ROHC feedback report received from peer PDCP to PDCP-DL
+*
+*/
+#ifdef ANSI
+PUBLIC S16 PjUlUdxDlFdbkPktInfo
+(
+Pst *pst,                       /* Post structure */
+SpId spId,                      /* Service provider ID */
+UdxDlFdbkPktInfo *fdbk           /*ROHC feedback*/
+)
+#else /* ANSI */
+PUBLIC S16 PjUlUdxDlFdbkPktInfo (pst, spId, fdbk)
+Pst *pst;                       /* Post structure */
+SpId spId;                      /* Service provider ID */
+UdxDlFdbkPktInfo *fdbk;          /* ROHC feedback*/
+#endif /* ANSI */
+{
+
+  TRC3(PjUlUdxDlFdbkPktInfo);
+
+  RETVALUE((*PjUlUdxDlFdbkPktInfoMt[pst->selector])(pst, spId, fdbk));
+
+} /* end of function PjUlUdxDlFdbkPktInfo */
+
+/**
+ *
+ *      @brief  This function is used to sent the Feedback pkt info to DL-PDCP.
+ *      @details This function is used to sent the Feedback pkt info to DL-PDCP.
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjUlUdxUlFdbkPktInfo
+(
+Pst *pst,                       /* Post structure */
+SpId spId,                      /* Service provider ID */
+UdxUlFdbkPktInfo *fdbkPktInfo           /*Feedback Packet Info*/
+)
+#else /* ANSI */
+PUBLIC S16 PjUlUdxUlFdbkPktInfo (pst, spId, staRep)
+Pst *pst;                       /* Post structure */
+SpId spId;                      /* Service provider ID */
+UdxUlFdbkPktInfo *fdbkPktInfo;          /* Feedback Packet Info*/
+#endif /* ANSI */
+{
+
+    TRC3(PjUlUdxUlFdbkPktInfo);
+
+    RETVALUE((*PjUlUdxUlFdbkPktInfoMt[pst->selector])(pst, spId, fdbkPktInfo));
+
+} /* end of function PjUlUdxUlFdbkPktInfo */
+
+
+/**
+ *
+ *      @brief  Sends an UE Id Change Indication to PDCP on Ckw interface
+ *      @details Sends an UE Id Change Indication to PDCP on Ckw interface
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjUlUdxUeIdChgReq
+(
+Pst       *post,          /* post structure */
+SpId       spId,         /* service provider */
+U32        transId,      /* RRC Transaction Id */
+UdxUeInfo *oldUeInfo,    /* current UE Id */
+UdxUeInfo *newUeInfo     /* new UE Id */
+)
+#else /* ANSI */
+PUBLIC S16 PjUlUdxUeIdChgReq(post, spId, transId, oldUeInfo, newUeInfo)
+Pst       *post;              /* post structure */
+SpId       spId;             /* service provider */
+U32        transId;          /* RRC Transaction Id */
+UdxUeInfo *oldUeInfo;        /* current UE Id */
+UdxUeInfo *newUeInfo;        /* new UE Id */
+#endif /* ANSI */
+{
+  TRC3(PjUlUdxUeIdChgReq);
+
+  RETVALUE((*PjUlUdxUeIdChgReqMt[post->selector])(post, spId, transId,
+            (UdxUeInfo *)oldUeInfo, (UdxUeInfo *)newUeInfo ));
+
+} /* end of function PjUlUdxUeIdChgReq */
+
+/**
+*
+*      @brief  This function is used to configure PDCP security parameters 
+*              (parametrs of Integrity protection and ciphering)
+*
+*      @details  This function is used to configure PDCP security parameters 
+*              (parametrs of Integrity protection and ciphering)
+*
+*/
+#ifdef ANSI
+PUBLIC S16 PjUlUdxSecCfgReq
+(
+Pst *post,                                /* Post structure */
+SpId spId,                               /* Service provider ID */
+UdxSecCfgReqInfo *cpjSecConfigReqInfo    /* PDCP Security Config parameters */
+)
+#else /* ANSI */
+PUBLIC S16 PjUlUdxSecCfgReq(post, spId, cpjSecConfigReqInfo)
+Pst *post;                                /* Post structure */
+SpId spId;                               /* Service provider ID */
+UdxSecCfgReqInfo *cpjSecConfigReqInfo;   /* PDCP Security Config parameters */
+#endif /* ANSI */
+{
+
+  TRC3(PjUlUdxSecCfgReq);
+
+  RETVALUE((*PjUlUdxSecCfgReqMt[post->selector])(post, spId, 
+                            cpjSecConfigReqInfo));
+
+} /* end of function PjUlUdxSecCfgReq */
+
+/**
+*
+*      @brief  This function is used to get COUNT values of each established DRB 
+*
+*      @details  This function is used to get COUNT values of each established DRB 
+*
+*/
+#ifdef ANSI
+PUBLIC S16 PjUlUdxCountReq
+(
+Pst *post,                       /* Post structure */
+SpId spId,                      /* Service provider ID */
+UdxCountReqInfo *pdcpCountReq              /* PDCP COUNT request paramters */
+)
+#else /* ANSI */
+PUBLIC S16 PjUlUdxCountReq(post, spId, pdcpCountReq)
+Pst *post;                       /* Post structure */
+SpId spId;                      /* Service provider ID */
+UdxCountReqInfo *pdcpCountReq;              /* PDCP COUNT request paramters */
+#endif /* ANSI */
+{
+
+  TRC3(PjUlUdxCountReq);
+
+  RETVALUE((*PjUlUdxCountReqMt[post->selector])(post, spId, pdcpCountReq));
+
+} /* end of function PjUlUdxCountReq */
+
+/**
+*
+*      @brief  This function is used to get PDCP Sdu Status for all DRBs.
+*
+*      @details  This function is used to get PDCP Sdu Status for all DRBs
+*                from PDCP at source during HO.
+*
+*/
+#ifdef ANSI
+PUBLIC S16 PjUlUdxSduStaReq
+(
+Pst *post,                       /* Post structure */
+SpId spId,                      /* Service provider ID */
+UdxSduStaReqInfo *pdcpSduStaReq     /* PDCP SDU status request parameters */
+)
+#else /* ANSI */
+PUBLIC S16 PjUlUdxSduStaReq(post, spId, pdcpSduStaReq)
+Pst *post;                       /* Post structure */
+SpId spId;                      /* Service provider ID */
+UdxSduStaReqInfo *pdcpSduStaReq;    /* PDCP SDU status request parameters */
+#endif /* ANSI */
+{
+
+  TRC3(PjUlUdxSduStaReq);
+
+  RETVALUE((*PjUlUdxSduStaReqMt[post->selector])(post, spId, pdcpSduStaReq));
+
+} /* end of function PjUlUdxSduStaReq */
+\f
+
+/**
+ *
+ *      @brief  Sends a Re-establish request to PDCP on UDX interface
+ *      @details Sends a Re-establish request to PDCP on UDX interface 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjUlUdxReEstReq
+(
+Pst       *post,          /* post structure */
+SpId       spId,         /* service provider */
+UdxReEstReqInfo *restbInfo     /* Re-establishment Info */
+)
+#else /* ANSI */
+PUBLIC S16 PjUlUdxReEstReq(post, spId, restbInfo)
+Pst       *post;              /* post structure */
+SpId       spId;             /* service provider */
+UdxReEstReqInfo *restbInfo;        /* new UE Id */
+#endif /* ANSI */
+{
+  TRC3(PjUlUdxReEstReq);
+
+  RETVALUE((*PjUlUdxReEstReqMt[post->selector])(post, spId, restbInfo));
+
+} /* end of function PjUlUdxReEstReq */
+
+#ifdef LTE_L2_MEAS
+/**
+* @brief Request from ULM to DLM for MeasReq 
+*
+* @details
+*
+*     Function : PjUlUdxL2MeasReq
+*
+*  @param[in]   Pst*           pst
+
+*  @return   S16
+*      -# ROK
+**/
+#ifdef ANSI
+PUBLIC S16  PjUlUdxL2MeasReq
+(
+Pst*                pst,
+PjL2MeasReqEvt      *measReqEvt 
+)
+#else
+PUBLIC S16 PjUlUdxL2MeasReq(pst,measReqEvt)
+Pst*                pst;
+PjL2MeasReqEvt      *measReqEvt; 
+#endif
+{
+
+   TRC3(PjUlUdxStaUpdReq);
+
+   RETVALUE((*pjUlUdxL2MeasReqMt[pst->selector])(pst,measReqEvt));
+} /* end of PjUlUdxMesReq*/
+
+/**
+* @brief Request from ULM to DLM for MeasSendReq 
+*
+* @details
+*
+*     Function : PjUlUdxMeasSendReq
+*
+*  @param[in]   Pst*           pst
+
+*  @return   S16
+*      -# ROK
+**/
+#ifdef ANSI
+PUBLIC S16  PjUlUdxL2MeasSendReq
+(
+Pst*                pst,
+U8                  measType
+)
+#else
+PUBLIC S16 PjUlUdxL2MeasSendReq(pst,measReqEvt)
+Pst*                pst;
+U8                  measType;
+#endif
+{
+
+   TRC3(PjUlUdxL2MeasSendReq);
+
+   RETVALUE((*pjUlUdxL2MeasSendReqMt[pst->selector])(pst,measType));
+} /* end of PjUlUdxMesReq*/
+
+/**
+* @brief Request from ULM to DLM for MeasStopReq 
+*
+* @details
+*
+*     Function : PjUlUdxL2MeasStopReq
+*
+*  @param[in]   Pst*           pst
+
+*  @return   S16
+*      -# ROK
+**/
+#ifdef ANSI
+PUBLIC S16  PjUlUdxL2MeasStopReq
+(
+Pst*                pst,
+U8                  measType
+)
+#else
+PUBLIC S16 PjUlUdxL2MeasStopReq(pst,measReqEvt)
+Pst*                pst;
+U8                  measType;
+#endif
+{
+
+   TRC3(PjUlUdxL2MeasStopReq);
+
+   RETVALUE((*pjUlUdxL2MeasStopReqMt[pst->selector])(pst,measType));
+} /* end of PjUlUdxMesReq*/
+#endif
+
+
+
+/**
+* @brief Request from ULM to DLM for MeasStopReq 
+*
+* @details
+*
+*     Function : PjUlUdxDatResumeReq
+*
+*  @param[in]   Pst*           pst
+
+*  @return   S16
+*      -# ROK
+**/
+#ifdef ANSI
+PUBLIC S16  PjUlUdxDatResumeReq
+(
+Pst*          pst,
+UdxDatResumeInfo  *udxDatResumeInfo
+)
+#else
+PUBLIC S16 PjUlUdxDatResumeReq(pst, udxDatResumeInfo)
+Pst*          pst;
+UdxDatResumeInfo  *udxDatResumeInfo; 
+#endif
+{
+
+   TRC3(PjUlUdxDatResumeReq);
+
+   RETVALUE((*pjUlUdxDatResumeReqMt[pst->selector])(pst, udxDatResumeInfo));
+} /* end of PjUlUdxMesReq*/
+
+
+/**
+* @brief 
+*
+* @details
+*
+*     Function : PjUlUdxDatForwardReq
+*
+*  @param[in]   Pst*           pst
+
+*  @return   S16
+*      -# ROK
+**/
+#ifdef ANSI
+PUBLIC S16  PjUlUdxDatForwardReq
+(
+Pst*          pst,
+UdxDatForwardInfo  *udxDatForwardInfo
+)
+#else
+PUBLIC S16 PjUlUdxDatForwardReq(pst, udxDatForwardInfo)
+Pst*          pst;
+UdxDatForwardInfo  *udxDatForwardInfo; 
+#endif
+{
+
+   TRC3(PjUlUdxDatForwardReq);
+
+   RETVALUE((*pjUlUdxDatForwardReqMt[pst->selector])(pst, udxDatForwardInfo));
+} /* end of PjUlUdxMesReq*/
+/**************************************************************************
+ * The UDX (Portable) Interface
+ *************************************************************************/
+#ifdef PTPJULUDX
+/**************************************************************************
+ *
+ *      Fun:   PtUlUdxBndReq
+ *
+ *      Desc:  Portable UdxBndReq primitive
+ *
+ *      Ret:   ROK 
+ *
+ *      Notes: 
+ *
+ *      File:  nh_ptli.c
+ *
+ *************************************************************************/
+#ifdef ANSI
+PRIVATE S16 PtUlUdxBndReq
+(
+Pst *post,                      /* Post structure */
+SuId suId,                      /* Service user ID */
+SpId spId                       /* Service provider ID */
+)
+#else /* ANSI */
+PRIVATE S16 PtUlUdxBndReq(post, suId, spId)
+Pst *post;                      /* Post structure */
+SuId suId;                      /* Service user ID */
+SpId spId;                      /* Service provider ID */
+#endif /* ANSI */
+{
+
+   TRC3(PtUlUdxBndReq);
+
+   UNUSED(post);
+   UNUSED(suId);
+   UNUSED(spId);
+
+   RETVALUE(ROK);
+
+} /* end of function PtUlUdxBndReq */
+
+\f
+/**************************************************************************
+*
+*      Fun:   PtUlUdxUbndReq
+*
+*      Desc:  Portable UdxUbndReq primitive
+*
+*      Ret:   ROK 
+*
+*      Notes: 
+*
+*      File:  nh_ptli.c
+*
+*************************************************************************/
+#ifdef ANSI
+PRIVATE S16 PtUlUdxUbndReq
+(
+Pst *post,                      /* Post structure */
+SpId spId,                      /* Service provider ID */
+Reason reason                   /* Reason */
+)
+#else /* ANSI */
+PRIVATE S16 PtUlUdxUbndReq(post, spId, reason)
+Pst *post;                      /* Post structure */
+SpId spId;                      /* Service provider ID */
+Reason reason;                  /* Reason */
+#endif /* ANSI */
+{
+
+   TRC3(PtUlUdxUbndReq);
+
+   UNUSED(post);
+   UNUSED(spId);
+   UNUSED(reason);
+
+   RETVALUE(ROK);
+
+} /* end of function PtUlUdxUbndReq */
+
+\f
+/**************************************************************************
+*
+*      Fun:   PtUlUdxCfgReq
+*
+*      Desc:  Portable UdxCfgReq primitive
+*
+*      Ret:   ROK 
+*
+*      Notes: 
+*
+*      File:  nh_ptli.c
+*
+*************************************************************************/
+#ifdef ANSI
+PRIVATE S16 PtUlUdxCfgReq
+(
+Pst *post,                      /* Post structure */
+SpId spId,                      /* Service provider ID */
+UdxCfgReqInfo *pdCfgReq         /* PDCP Config parameters */
+)
+#else /* ANSI */
+PRIVATE S16 PtUlUdxCfgReq(post, spId, pdCfgReq)
+Pst *post;                      /* Post structure */
+SpId spId;                      /* Service provider ID */
+UdxCfgReqInfo *pdCfgReq;        /* PDCP Config parameters */
+#endif /* ANSI */
+{
+
+   TRC3(PtUlUdxCfgReq);
+
+   UNUSED(post);
+   UNUSED(spId);
+   UNUSED(pdCfgReq);
+
+
+   RETVALUE(ROK);
+
+} /* end of function PtUlUdxCfgReq */
+
+/**************************************************************************
+*
+*      Fun:   PtUlUdxUlStaRep
+*
+*      Desc:  Portable UdxUlStaRep primitive
+*
+*      Ret:   ROK 
+*
+*      Notes: 
+*
+*      File:  pj_udx_ptul.c
+*
+*************************************************************************/
+#ifdef ANSI
+PRIVATE S16 PtUlUdxUlStaRep
+(
+Pst *post,                      /* Post structure */
+SpId spId,                      /* Service provider ID */
+UdxUlStaRepInfo *pdStaRep         /* PDCP UL ot PDCP DL Reestablishment trigger */
+)
+#else /* ANSI */
+PRIVATE S16 PtUlUdxUlStaRep(post, spId, pdStaRep)
+Pst *post;                      /* Post structure */
+SpId spId;                      /* Service provider ID */
+UdxUlStaRepInfo *pdStaRep;        /* PDCP UL ot PDCP DL Reestablishment trigger */
+#endif /* ANSI */
+{
+
+   TRC3(PtUlUdxUlStaRep);
+
+   UNUSED(post);
+   UNUSED(spId);
+   UNUSED(pdStaRep);
+
+
+   RETVALUE(ROK);
+
+} /* end of function  */
+
+/**************************************************************************
+*
+*      Fun:   PtUlUdxUlStaRep
+*
+*      Desc:  Portable UdxUlStaRep primitive
+*
+*      Ret:   ROK 
+*
+*      Notes: 
+*
+*      File:  pj_udx_ptul.c
+*
+*************************************************************************/
+#ifdef ANSI
+PRIVATE S16 PtUlUdxDlStaRep
+(
+Pst *post,                      /* Post structure */
+SpId spId,                      /* Service provider ID */
+UdxDlStaRepInfo *pdStaRep       /* Status report from PDCP UL to PDCP DL */
+)
+#else /* ANSI */
+PRIVATE S16 PtUlUdxDlStaRep(post, spId, pdStaRep)
+Pst *post;                      /* Post structure */
+SpId spId;                      /* Service provider ID */
+UdxDlStaRepInfo *pdStaRep;      /* Status report from PDCP UL to PDCP DL */
+#endif /* ANSI */
+{
+
+   TRC3(PtUlUdxDlStaRep);
+
+   UNUSED(post);
+   UNUSED(spId);
+   UNUSED(pdStaRep);
+
+
+   RETVALUE(ROK);
+
+} /* end of function  */
+
+
+/**************************************************************************
+ *
+ *      Fun:   PtUlUdxUeIdChgReq
+ *
+ *      Desc:  Portable UdxUeIdChgReq primitive
+ *
+ *      Ret:   ROK 
+ *
+ *      Notes: 
+ *
+ *      File:  nh_ptli.c
+ *
+ *************************************************************************/
+#ifdef ANSI
+PRIVATE S16 PtUlUdxUeIdChgReq
+(
+Pst       *post,           /* post structure */
+SpId      spId,            /* service provider */
+U32       transId,         /* TransId */
+UdxUeInfo *oldUeInfo,      /* current UE Id */
+UdxUeInfo *newUeInfo       /* new UE Id */
+)
+#else /* ANSI */
+PRIVATE S16 PtUlUdxUeIdChgReq(post, spId, transId, oldUeInfo, newUeInfo)
+Pst       *post;           /* post structure */
+SpId       spId;           /* service provider */
+U32        transId;        /* TransId */
+UdxUeInfo *oldUeInfo;      /* current UE Id */
+UdxUeInfo *newUeInfo;      /* new UE Id */
+#endif /* ANSI */
+{
+  TRC3(PtUlUdxUeIdChgReq);
+
+  UNUSED(post);
+  UNUSED(spId);
+  UNUSED(transId);
+  UNUSED(oldUeInfo);
+  UNUSED(newUeInfo);
+
+  RETVALUE(ROK);
+
+} /* end of function PtUlCkwUeIdChgReq */
+
+/**************************************************************************
+ *
+ *      Fun:   PtUlUdxSecCfgReq
+ *
+ *      Desc:  Portable UdxSecCfgReq primitive
+ *
+ *      Ret:   ROK 
+ *
+ *      Notes: 
+ *
+ *      File:  nh_ptli.c
+ *
+ *************************************************************************/
+#ifdef ANSI
+PRIVATE S16 PtUlUdxSecCfgReq
+(
+Pst       *post,                  /* post structure */
+SpId      spId,                   /* service provider */
+UdxSecCfgReqInfo *secCfgReq       /* PDCP Security Config paramters */
+)
+#else /* ANSI */
+PRIVATE S16 PtUlUdxSecCfgReq(post, spId, secCfgReq)
+Pst       *post;                  /* post structure */
+SpId       spId;                  /* service provider */
+UdxSecCfgReqInfo *secCfgReq;      /* PDCP Security Config paramters */
+#endif /* ANSI */
+{
+  TRC3(PtUlUdxSecCfgReq);
+
+  UNUSED(post);
+  UNUSED(spId);
+  UNUSED(secCfgReq);
+
+  RETVALUE(ROK);
+
+} /* end of function PtUlUdxSecCfgReq */
+
+/**************************************************************************
+ *
+ *      Fun:   PtUlUdxCountReq
+ *
+ *      Desc:  Portable UdxCountReq primitive
+ *
+ *      Ret:   ROK 
+ *
+ *      Notes: 
+ *
+ *      File:  nh_ptli.c
+ *
+ *************************************************************************/
+#ifdef ANSI
+PRIVATE S16 PtUlUdxCountReq
+(
+Pst       *post,                /* post structure */
+SpId      spId,                 /* service provider */
+UdxCountReqInfo *countReq       /* PDCP Security Config paramters */
+)
+#else /* ANSI */
+PRIVATE S16 PtUlUdxCountReq(post, spId, countReq)
+Pst       *post;                /* post structure */
+SpId       spId;                /* service provider */
+UdxCountReqInfo *countReq;      /* Count value paramters */
+#endif /* ANSI */
+{
+  TRC3(PtUlUdxCountReq);
+
+  UNUSED(post);
+  UNUSED(spId);
+  UNUSED(countReq);
+
+  RETVALUE(ROK);
+
+} /* end of function PtUlUdxCountReq */
+
+/**************************************************************************
+ *
+ *      Fun:   PtUlUdxSduStaReq
+ *
+ *      Desc:  Portable UdxSduStaReq primitive
+ *
+ *      Ret:   ROK 
+ *
+ *      Notes: 
+ *
+ *      File:  nh_ptli.c
+ *
+ *************************************************************************/
+#ifdef ANSI
+PRIVATE S16 PtUlUdxSduStaReq
+(
+Pst          *post,               /* post structure */
+SpId         spId,                /* service provider */
+UdxSduStaReqInfo *sduStaReq       /* PDCP SDU status parameters */
+)
+#else /* ANSI */
+PRIVATE S16 PtUlUdxSduStaReq(post, spId, sduStaReq)
+Pst          *post;               /* post structure */
+SpId         spId;                /* service provider */
+UdxSduStaReqInfo *sduStaReq;      /* PDCP SDU status parameters */
+#endif /* ANSI */
+{
+  TRC3(PtUlUdxSduStaReq);
+
+  UNUSED(post);
+  UNUSED(spId);
+  UNUSED(sduStaReq);
+
+
+  RETVALUE(ROK);
+
+} /* end of function PtUlUdxSduStaReq */
+\f
+
+/**************************************************************************
+ *
+ *      Fun:   PtUlUdxReEstReq
+ *
+ *      Desc:  Portable UdxReEstReq primitive
+ *
+ *      Ret:   ROK 
+ *
+ *      Notes: 
+ *
+ *      File:  nh_ptli.c
+ *
+ *************************************************************************/
+#ifdef ANSI
+PRIVATE S16 PtUlUdxReEstReq
+(
+Pst       *post,                 /* post structure */
+SpId      spId,                  /* service provider */
+UdxReEstReqInfo *restbInfo       /* PDCP Re-establishment Config paramters */
+)
+#else /* ANSI */
+PRIVATE S16 PtUlUdxReEstReq(post, spId, restbInfo)
+Pst       *post;                 /* post structure */
+SpId       spId;                 /* service provider */
+UdxReEstReqInfo *restbInfo;      /* PDCP Re-establishment Config paramters */
+#endif /* ANSI */
+{
+  TRC3(PtUlUdxReEstReq);
+
+  UNUSED(post);
+  UNUSED(spId);
+  UNUSED(restbInfo);
+
+  RETVALUE(ROK);
+
+} /* end of function PtUlUdxReEstReq */
+/**************************************************************************
+ *
+ *      Fun:   PtUlUdxUlFdbkPktInfo
+ *
+ *      Desc:  Portable PtUlUdxUlFdbkPktInfo primitive
+ *
+ *      Ret:   ROK
+ *
+ *      Notes:
+  *
+ *      File :  nh_ptli.c
+ *
+ *************************************************************************/
+#ifdef ANSI
+PRIVATE S16 PtUlUdxUlFdbkPktInfo
+(
+Pst          *post,               /* post structure */
+SpId         spId,                /* service provider */
+UdxUlFdbkPktInfo  *fdbkPktInfo    /* feedback Packet Info */
+)
+#else /* ANSI */
+PRIVATE S16 PtUlUdxUlFdbkPktInfo(post, spId, fdbkPktInfo)
+Pst          *post;               /* post structure */
+SpId         spId;                /* service provider */
+UdxUlFdbkPktInfo  *fdbkPktInfo    /* feedback Packet Info */
+#endif /* ANSI */
+{
+    TRC3(PtUlUdxUlFdbkPktInfo);
+
+    UNUSED(post);
+    UNUSED(spId);
+    UNUSED(fdbkPktInfo);
+
+
+    RETVALUE(ROK);
+
+} /* end of function PtUlUdxUlFdbkPktInfo */
+
+
+/**************************************************************************
+ *
+ *      Fun:   PtUlUdxDlFdbkPktInfo
+ *
+ *      Desc:  Portable PtUlUdxDlFdbkPktInfo primitive
+ *
+ *      Ret:   ROK
+ *
+ *      Notes:
+  *
+ *      File :  nh_ptli.c
+ *
+ *************************************************************************/
+#ifdef ANSI
+PRIVATE S16 PtUlUdxDlFdbkPktInfo
+(
+Pst          *post,               /* post structure */
+SpId         spId,                /* service provider */
+UdxDlFdbkPktInfo  *fdbkPktInfo    /* feedback Packet Info */
+)
+#else /* ANSI */
+PRIVATE S16 PtUlUdxDlFdbkPktInfo(post, spId, fdbkPktInfo)
+Pst          *post;               /* post structure */
+SpId         spId;                /* service provider */
+UdxDlFdbkPktInfo  *fdbkPktInfo    /* feedback Packet Info */
+#endif /* ANSI */
+{
+    TRC3(PtUlUdxDlFdbkPktInfo);
+
+    UNUSED(post);
+    UNUSED(spId);
+    UNUSED(fdbkPktInfo);
+
+
+    RETVALUE(ROK);
+
+} /* end of function PtUlUdxDlFdbkPktInfo */
+
+
+
+
+#ifdef LTE_L2_MEAS
+/**
+* @brief Request from ULM to DLM for Measurement
+*
+* @details
+*
+*     Function : PjUdxUdxL2MeasReq
+*
+*  @param[in]   Pst*           pst
+
+*  @return   S16
+*      -# ROK
+**/
+#ifdef ANSI
+PRIVATE S16  PtUlUdxL2MeasReq
+(
+Pst*                pst,
+PjL2MeasReqEvt      *measReqEvt
+)
+#else
+PRIVATE S16 PtUlUdxL2MeasReq(pst, measReqEvt )
+Pst*                pst;
+PjL2MeasReqEvt      *measReqEvt;
+#endif
+{
+
+   TRC3(PtUlUdxL2MeasReq);
+
+   RETVALUE(ROK);
+} 
+
+/**
+* @brief Request from ULM to DLM for Measurement
+*
+* @details
+*
+*     Function : PjUdxUdxL2MeasSendReq
+*
+*  @param[in]   Pst*           pst
+
+*  @return   S16
+*      -# ROK
+**/
+#ifdef ANSI
+PRIVATE S16  PtUlUdxL2MeasSendReq
+(
+Pst*                pst,
+U8                  status
+)
+#else
+PRIVATE S16 PtUlUdxL2MeasSendReq(pst, status )
+Pst*                pst;
+U8                  status
+#endif
+{
+
+   TRC3(PtUlUdxL2MeasSendReq);
+
+   RETVALUE(ROK);
+}
+
+/**
+* @brief Request from ULM to DLM for Measurement
+*
+* @details
+*
+*     Function : PjUdxUdxL2MeasStopReq
+*
+*  @param[in]   Pst*           pst
+
+*  @return   S16
+*      -# ROK
+**/
+#ifdef ANSI
+PRIVATE S16  PtUlUdxL2MeasStopReq
+(
+Pst*                pst,
+U8                  status
+)
+#else
+PRIVATE S16 PtUlUdxL2MeasStopReq(pst, status )
+Pst*                pst;
+U8                  status
+#endif
+{
+
+   TRC3(PtUlUdxL2MeasStopReq);
+
+   RETVALUE(ROK);
+}
+#endif
+/**
+* @brief Request from ULM to DLM for ResumeReq 
+*
+* @details
+*
+*     Function : PtUlUdxDatResumeReq
+*
+*  @param[in]   Pst*           pst
+
+*  @return   S16
+*      -# ROK
+**/
+#ifdef ANSI
+PRIVATE S16  PtUlUdxDatResumeReq
+(
+Pst*          pst,
+UdxDatResumeInfo  *udxDatResumeInfo
+)
+#else
+PRIVATE S16 PtUlUdxDatResumeReq(pst, udxDatResumeInfo )
+Pst*          pst;
+UdxDatResumeInfo  *udxDatResumeInfo;
+#endif
+{
+
+   TRC3(PtUlUdxDatResumeReq);
+
+   RETVALUE(ROK);
+}
+
+/**
+* @brief  
+*
+* @details
+*
+*     Function : PtUlUdxDatForwardReq
+*
+*  @param[in]   Pst*           pst
+
+*  @return   S16
+*      -# ROK
+**/
+#ifdef ANSI
+PRIVATE S16  PtUlUdxDatForwardReq
+(
+Pst*          pst,
+UdxDatForwardInfo  *udxDatForwardInfo
+)
+#else
+PRIVATE S16 PtUlUdxDatForwardReq(pst, udxDatForwardInfo )
+Pst*          pst;
+UdxDatForwardInfo  *udxDatForwardInfo;
+#endif
+{
+
+   TRC3(PtUlUdxDatForwardReq);
+
+   RETVALUE(ROK);
+}
+
+#endif /* #ifdef PTPJULUDX */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_udx_ul.c b/src/5gnrpdcp/pj_udx_ul.c
new file mode 100755 (executable)
index 0000000..0d1f6b9
--- /dev/null
@@ -0,0 +1,1295 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE-PDCP Layer - Upper Interface
+    
+        Type:    C file
+  
+        Desc:    C source code for the upper interface of LTE-PDCP
+        File:    pj_udx_ul.c
+  
+*********************************************************************21*/
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=226;
+/** @file pj_udx_ul.c
+@brief PDCP Upper Interface
+*/
+
+\f
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "cpj.h"           /* UDX defines */
+#include "pju.h"           /* PJU defines */
+#include "lpj.h"           /* LPJ defines */
+
+#include "pj_err.h"
+#include "pj_env.h"        /* RLC environment options */
+#include "pj.h"
+#include "pj_ul.h"
+#include "pj_udx.h"
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "cpj.x"           /* UDX defines */
+#include "pju.x"           /* PJU defines */
+#include "lpj.x"           /* LPJ defines */
+#include "pj.x"
+#include "pj_udx.h"
+#include "pj_udx.x"
+#include "pj_ul.x"
+
+PRIVATE S16 pjHdlCpjUlCfgReq ARGS((PjCb  *gCb,PjCfgInfo *cfgInfo,
+              UdxCfgCfmInfo *cfmInfo, CpjCfgCfmInfo *cfgCfm, Bool *sndCfgCfm));
+
+
+
+/**
+  * @brief
+  * UDX APIs
+  */
+/**
+ *
+ * @brief 
+ *
+ *        Handler for bind confirmation from DL.
+ *
+ * @b Description:
+ *
+ *        This function handles the bind confirmation received
+ *        from MAC. 
+ *
+ *  @param[in] pst     Post structure  
+ *  @param[in] suId    Service User ID
+ */
+
+
+\f  
+/****************************************************************************
+ *                         UDX Interface Mt functions
+ ***************************************************************************/\f
+#ifdef ANSI
+PUBLIC S16 PjUlUdxBndCfm
+(
+Pst * pst,
+SuId suId,
+U8 status
+)
+#else
+PUBLIC S16 PjUlUdxBndCfm(pst, suId, status)
+Pst * pst;
+SuId suId;
+U8 status;
+#endif
+{
+   U16             event;              /* Event */
+   U16             cause;              /* Cause */
+   PjUdxUlSapCb      *udxSap;            /* RGU SAP Control Block */
+   PjCb            *tPjCb;
+
+   TRC3(PjUlUdxBndCfm)
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+#endif
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef DEBUGP
+   RLOG2(L_DEBUG, "PjUlUdxBndCfm(post, suId(%d), status(%d)", suId, status);
+#endif
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
+   {
+      /* INNC: ERROR CLASS */
+      RLOG0(L_FATAL, "General configuration not done");
+      PJ_SEND_SAPID_ALARM(tPjCb,suId, 
+                          LPJ_EVENT_LI_BND_CFM, LCM_CAUSE_INV_STATE);
+
+      RETVALUE(RFAILED);
+   }
+
+   if (suId < 0)
+   {
+      /* INNC: ERROR CLASS */
+      RLOG0(L_ERROR, "Invalid suId");
+      PJ_SEND_SAPID_ALARM(tPjCb,suId, 
+                           LPJ_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
+
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   udxSap = tPjCb->u.ulCb->udxUlSap + suId;
+
+#ifdef DEBUGP
+   RLOG1(L_DEBUG, "PjLiRguBndCfm: For RGU SAP state=%d",
+       udxSap->state);
+#endif
+
+   /* Check rguSap state */
+   switch (udxSap->state)
+   {
+      case PJ_SAP_BINDING:
+      {
+         pjStopTmr (tPjCb,(PTR)udxSap, PJ_EVT_WAIT_UDX_BNDCFM);
+
+         udxSap->retryCnt = 0;
+          
+         if (status == CM_BND_OK)
+         {
+            udxSap->state = PJ_SAP_BND;
+            event = LCM_EVENT_BND_OK;
+            cause = LPJ_CAUSE_SAP_BNDENB;
+         }
+         else
+         {
+            udxSap->state = PJ_SAP_CFG;
+            event = LCM_EVENT_BND_FAIL;
+            cause = LPJ_CAUSE_UNKNOWN;
+         }
+      }
+      break;
+
+     default:
+        event = LPJ_EVENT_RGU_BND_CFM;
+        cause = LCM_CAUSE_INV_STATE;
+        break;
+   }
+
+   /* Send an alarm with proper event and cause */
+   /*PJ_SEND_SAPID_ALARM(tPjCb,suId, event, cause);*/
+#ifdef LTE_L2_MEAS
+   pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, event, cause, suId, 0,0); 
+#else
+   pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, event, cause, suId, 0); 
+#endif
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjUlUdxCfgCfm
+(
+Pst * pst,
+SuId suId,
+UdxCfgCfmInfo * cfmInfo
+)
+#else
+PUBLIC S16 PjUlUdxCfgCfm(pst, suId, cfmInfo)
+Pst * pst;
+SuId suId;
+UdxCfgCfmInfo * cfmInfo;
+#endif
+{
+   S16              ret;
+   PjCpjSapCb     *cpjSap;
+   PjCb            *tPjCb;
+   CpjCfgCfmInfo   *cfgCfm;
+   Bool            sndCfgCfm;
+   PjCfgInfo       *cfgInfo;
+
+   TRC3(PjUlUdxCfgCfm)
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+#endif
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef DEBUGP
+   RLOG1(L_DEBUG, "PjUlUdxBndCfm(post, suId(%d), )", suId);
+#endif
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (suId < 0)
+   {
+      /* INNC: ERROR CLASS */
+      RLOG0(L_ERROR, "Invalid suId");
+      PJ_SEND_SAPID_ALARM(tPjCb,suId, 
+                           LPJ_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
+
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   ret = pjDbmFindUlTransIdLst(tPjCb,cfmInfo->transId, &cfgInfo);
+   if (ret != ROK)
+   {
+      RLOG0(L_ERROR, "Invalid transId");
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cfmInfo, sizeof (UdxCfgCfmInfo));
+      RETVALUE (RFAILED);
+   }
+   /* Allocate memory and memset to 0 for cfmInfo */
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+   if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfgCfm, 
+      sizeof (CpjCfgCfmInfo)) != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      /* pj002.201 Freeing from proper region */
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cfmInfo, sizeof (UdxCfgCfmInfo));
+      PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->cfgInfo, sizeof(CpjCfgReqInfo));
+      PJ_FREE(tPjCb,cfgInfo,sizeof(PjCfgInfo));
+      RETVALUE(RFAILED);
+   }
+
+   sndCfgCfm = TRUE;
+   ret = pjHdlCpjUlCfgReq(tPjCb,cfgInfo, cfmInfo, cfgCfm, &sndCfgCfm);
+/* AGHOSH */
+   /* Free the cfg confirm allocated from DL, this should actually
+      be a sharable buffer and not a static buffer */
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cfmInfo, sizeof (UdxCfgCfmInfo));
+   PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->cfgInfo, sizeof(CpjCfgReqInfo));
+   PJ_FREE(tPjCb,cfgInfo,sizeof(PjCfgInfo));
+/* AGHOSH */
+   
+   if (sndCfgCfm)
+   {
+       cpjSap = &(tPjCb->u.ulCb->cpjSap);
+
+       PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm);
+   }
+
+   
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjUlUdxReEstCfm
+(
+Pst               *pst,
+SuId              suId,
+UdxReEstCfmInfo   *reEstCfm
+)
+#else
+PUBLIC S16 PjUlUdxReEstCfm(pst, suId, reEstCfm)
+Pst               *pst;
+SuId              suId;
+UdxReEstCfmInfo   *reEstCfm;
+#endif
+{
+   S16              ret;
+   PjCpjSapCb      *cpjSap;
+   PjCb            *tPjCb;
+   PjCfgInfo       *cfgInfo;
+   CpjReEstCfmInfo *cpjReEstCfm;
+    
+   TRC3(PjUlUdxReEstCfm)
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo));
+
+      RETVALUE (RFAILED);
+   }
+#endif
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef DEBUGP
+   RLOG1(L_DEBUG, "PjUlUdxReEstCfm(post, suId(%d), ", suId);
+#endif
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (suId < 0)
+   {
+      /* INNC: ERROR CLASS */
+      RLOG0(L_ERROR, "Invalid suId");
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo));
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   ret = pjDbmFindUlTransIdLst(tPjCb, reEstCfm->transId, &cfgInfo);
+   if (ret != ROK)
+   {
+      RLOG0(L_ERROR, "Invalid transId");
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo));
+      RETVALUE (RFAILED);
+   }
+
+   ret = ROK;
+
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+   if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cpjReEstCfm, 
+      sizeof (CpjReEstCfmInfo)) != ROK)
+   {
+      /* Free memory for CfgReqInfo */
+      /* kw002.201 Freeing from proper region */  
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo));
+      PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->reEstReq, sizeof(CpjReEstReqInfo));
+      PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   cpjReEstCfm->ueId = cfgInfo->reEstReq->pdcpId.ueId;
+   cpjReEstCfm->cellId = cfgInfo->reEstReq->pdcpId.cellId;
+   /* Assign number of entity configuraitons and suId */
+   cpjReEstCfm->transId = cfgInfo->uprLyrTransId;
+   cpjReEstCfm->status = reEstCfm->status;
+   
+   if (CPJ_CFG_CFM_OK == reEstCfm->status)
+   {
+      /* handle ReEstablish here */
+      pjCfgUlReEstReq(tPjCb, cfgInfo->reEstReq, cpjReEstCfm);
+   }
+
+#ifndef PJ_ASYNC_CFM
+   PjUiCpjReEstCfm(&(cpjSap->pst), cpjSap->suId, cpjReEstCfm);
+#endif
+   /* Configuration information needs to be freed from proper region */
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo));
+   PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->reEstReq, sizeof(CpjReEstReqInfo));
+   PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+
+   RETVALUE(ROK);
+}
+
+
+
+#ifdef ANSI
+PUBLIC S16 PjUlUdxSecCfgCfm
+(
+Pst * pst,
+SuId suId,
+UdxSecCfgCfmInfo * secCfgCfm
+)
+#else
+PUBLIC S16 PjUlUdxSecCfgCfm(pst, suId, secCfgCfm)
+Pst * pst;
+SuId suId;
+UdxSecCfgCfmInfo * secCfgCfm;
+#endif
+{
+   S16         ret;
+   CpjSecCfgCfmInfo  *cfgCfm;       /* Security Cfg Confirm structure */
+   PjCpjSapCb          *cpjSap;
+   PjCb            *tPjCb;
+   PjCfgInfo       *cfgInfo;
+   CpjSecCfgReqInfo *secCfg;
+#ifdef PJ_SEC_ASYNC
+   PjUlUeCb               *ueCb = NULLP;
+#endif
+
+   TRC3(PjUlUdxSecCfgCfm)
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+#endif
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef DEBUGP
+   RLOG1(L_DEBUG, "PjUlUdxUeIdChgCfm(post, suId(%d), ", suId);
+#endif
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (suId < 0)
+   {
+      /* INNC: ERROR CLASS */
+      RLOG0(L_ERROR, "Invalid suId");
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+
+   ret = pjDbmFindUlTransIdLst(tPjCb,secCfgCfm->transId, &cfgInfo);
+   if (ret != ROK)
+   {
+      RLOG0(L_ERROR, "Invalid transId");
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,secCfgCfm, sizeof (UdxSecCfgCfmInfo));
+      RETVALUE (RFAILED);
+   }
+
+   secCfg = cfgInfo->secCfgInfo;
+
+
+   if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfgCfm,
+      sizeof (CpjSecCfgCfmInfo)) != ROK)
+   {
+      /* Free memory for CfgReqInfo */
+      /* kw002.201 Freeing from proper region */  
+      PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, secCfg, sizeof(CpjSecCfgReqInfo));
+      PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   if ( pjCfgPrcSecUlCfg(tPjCb,secCfg,cfgCfm) != ROK )
+   {
+      RLOG_ARG2(L_ERROR,DBG_UEID,secCfg->ueId, 
+          "PjUiCpjSecCfgReq  cellId(%d) pjCfgSecCfg Failed: reason (%d)",
+            secCfg->cellId, cfgCfm->reason);
+
+   }
+   else
+   {
+        if (secCfgCfm->status != CPJ_CFG_CFM_OK)
+        {
+            PJ_MEM_CPY(cfgCfm, secCfgCfm, sizeof (CpjSecCfgCfmInfo));             
+        }
+   }
+   
+   cfgCfm->transId = cfgInfo->uprLyrTransId;
+#ifdef PJ_SEC_ASYNC
+   ret = pjDbmFetchUlUeCb(tPjCb,secCfg->ueId, secCfg->cellId, &ueCb);
+   if ( ueCb != NULLP )
+   {
+      pjUtlUlSaveCfmInfo(tPjCb, ueCb, PJ_SEC_ASYNC_CFM, TRUE,  ENTPJ, (PTR)cfgCfm, NULLP);
+      PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgCfm, sizeof(CpjSecCfgCfmInfo));
+   }
+   else
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, secCfg->cellId,"UeId[%u] not found",
+            secCfg->ueId);
+      PjUiCpjSecCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm);
+   }
+#else
+   PjUiCpjSecCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm);
+#endif 
+
+  /* Configuration information needs to be freed from proper region */
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,secCfgCfm, sizeof (UdxSecCfgCfmInfo));
+   PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, secCfg, sizeof(CpjSecCfgReqInfo));
+   PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjUlUdxUeIdChgCfm
+(
+Pst * pst,
+SuId suId,
+U32 transId,
+UdxUeInfo  * ueInfo,
+CmStatus status
+)
+#else
+PUBLIC S16 PjUlUdxUeIdChgCfm(pst, suId, transId, ueInfo, status)
+Pst * pst;
+SuId suId;
+U32 transId;
+UdxUeInfo  * ueInfo;
+CmStatus status;
+#endif
+{
+   S16         ret;
+   CmStatus    tStatus;
+   PjCpjSapCb          *cpjSap;
+   PjCb            *tPjCb;
+   PjCfgInfo       *cfgInfo;
+
+   TRC3(PjUlUdxUeIdChgCfm)
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+#endif
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef DEBUGP
+   RLOG1(L_DEBUG, "PjUlUdxUeIdChgCfm(post, suId(%d), ", suId);
+#endif
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (suId < 0)
+   {
+      /* INNC: ERROR CLASS */
+      RLOG0(L_ERROR, "Invalid suId");
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   ret = pjDbmFindUlTransIdLst(tPjCb, transId, &cfgInfo);
+   if (ret != ROK)
+   {
+      RLOG0(L_ERROR, "Invalid transId");
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,ueInfo, sizeof (UdxUeInfo));
+      RETVALUE (RFAILED);
+   }
+
+   ret = ROK;
+   tStatus.reason = CPJ_CFG_REAS_NONE;
+   tStatus.status = CPJ_CFG_CFM_OK;
+
+   if ( (ret = pjCfgUlUeIdChng(tPjCb,cfgInfo->ueInfo,
+                      cfgInfo->newUeInfo, &tStatus)) != ROK)
+   {
+#ifdef DEBUGP
+      RLOG_ARG4(L_ERROR,DBG_UEID,cfgInfo->ueInfo->ueId, "Cpj UeId Chg Req"
+            " old-ueId(%d), new-ueId(%d), cellId(%d))Failed: reason (%d)",
+             cfgInfo->ueInfo->ueId, cfgInfo->newUeInfo->ueId,
+             cfgInfo->newUeInfo->cellId, status.reason);
+#endif
+   }
+
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+
+   if ((status.status == CPJ_CFG_CFM_OK) || 
+         (tStatus.status == CPJ_CFG_CFM_OK))
+   {
+      tStatus.reason = CPJ_CFG_REAS_NONE;
+      tStatus.status = CPJ_CFG_CFM_OK;
+   }
+   PjUiCpjUeIdChgCfm(&cpjSap->pst,cpjSap->suId,cfgInfo->uprLyrTransId,(CpjUeInfo *)ueInfo,tStatus);
+
+   /* Free the buffers allocated before returning */
+   PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->ueInfo, sizeof(CpjUeInfo));
+   PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->newUeInfo, sizeof(CpjUeInfo));
+   PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjUlUdxCountCfm
+(
+Pst * pst,
+SuId suId,
+UdxCountCfmInfo *cntCfm
+)
+#else
+PUBLIC S16 PjUlUdxCountCfm(pst, suId, cntCfm) 
+Pst * pst;
+SuId suId;
+UdxCountCfmInfo *cntCfm;
+#endif
+{
+
+   S16         ret;
+   PjCpjSapCb          *cpjSap;
+   PjCb            *tPjCb;
+   PjCfgInfo       *cfgInfo;
+   CpjCountReqInfo   *countReq = NULLP;
+   CpjCountCfmInfo *countCfm = NULLP;
+
+   TRC3(PjUlUdxCountCfm)
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+#endif
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef DEBUGP
+   RLOG1(L_DEBUG, "PjUlUdxUeIdChgCfm(post, suId(%d), ", suId);
+#endif
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (suId < 0)
+   {
+      /* INNC: ERROR CLASS */
+      RLOG0(L_ERROR, "Invalid suId");
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   ret = pjDbmFindUlTransIdLst(tPjCb, cntCfm->transId, &cfgInfo);
+   if (ret != ROK)
+   {
+      RLOG0(L_ERROR, "Invalid transId");
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cntCfm, sizeof (UdxCountCfmInfo));
+      RETVALUE (RFAILED);
+   }
+   cpjSap = &tPjCb->u.ulCb->cpjSap;   
+   countReq = cfgInfo->cntReq;
+   if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&countCfm,
+      sizeof (CpjCountCfmInfo)) != ROK)
+   {   
+      /* Free memory for CfgReqInfo */
+      /* kw002.201 Freeing from proper region */
+     /* ccpu00136902 */
+   /*   PJ_PST_FREE(pst->region, pst->pool, countReq, sizeof(CpjCountReqInfo)); */
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cntCfm, sizeof (UdxCountCfmInfo));
+      PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, countReq, sizeof(CpjCountReqInfo));    
+      PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));  /*MEM_LEAK_FIX */
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+
+      RETVALUE(RFAILED);
+   }
+   PJ_MEM_CPY(countCfm, cntCfm, sizeof(CpjCountCfmInfo));      /* KW_FIX */
+   if ( pjCfgPrcUlCount(tPjCb, countReq, countCfm, cntCfm) != ROK )
+   {
+      RLOG_ARG2(L_ERROR,DBG_UEID,countReq->ueId, 
+            "PjUiCpjCountReq cellId(%d)  pjCfgSecCfg Failed: reason (%d)",
+                countReq->cellId, countCfm->reason);
+
+   }
+
+   countCfm->transId = cfgInfo->uprLyrTransId;
+   /* Ned to consolidate confirms */
+   /* Freeing from proper region */
+   
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cntCfm, sizeof (UdxCountCfmInfo));
+   PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, countReq, sizeof(CpjCountReqInfo));    
+   PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));  /*MEM_LEAK_FIX */
+
+
+   PjUiCpjCountCfm(&(cpjSap->pst), cpjSap->suId,countCfm);
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjUlUdxSduStaCfm
+(
+Pst              *pst,
+SuId              suId,
+UdxSduStaCfmInfo *staCfm
+)
+#else
+PUBLIC S16 PjUlUdxSduStaCfm(pst, suId, staCfm)
+Pst              *pst;
+SuId              suId;
+UdxSduStaCfmInfo *staCfm;
+#endif
+{
+   S16                ret;
+   PjCpjSapCb        *cpjSap;
+   PjCb              *tPjCb;
+   PjCfgInfo         *cfgInfo;
+   CpjSduStaReqInfo  *staReq;  
+   CpjSduStaCfmInfo  *sduStaCfm;
+
+   TRC3(PjUlUdxSduStaCfm)
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+#endif
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef DEBUGP
+   RLOG1(L_DEBUG, "PjUlUdxSduStaCfm(post, suId(%d), ", suId); 
+#endif
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (suId < 0)
+   {
+      /* INNC: ERROR CLASS */
+      RLOG0(L_ERROR, "Invalid suId");
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+   ret = pjDbmFindUlTransIdLst(tPjCb, staCfm->transId, &cfgInfo);
+   if (ret != ROK)
+   {
+      RLOG0(L_ERROR, "Invalid transId");
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,staCfm, sizeof (UdxSduStaCfmInfo));
+      RETVALUE (RFAILED);
+   }
+
+   staReq = cfgInfo->staReq;
+   
+   if (ROK == staCfm->status)
+   {
+      if (pjCfgPrcUlSduSta(tPjCb, staReq, staCfm) != ROK )
+      {
+         RLOG_ARG1(L_ERROR,DBG_UEID,staReq->ueId, 
+             "PjUlUdxSduStaReq ,cellId(%d) pjCfgSecCfg Failed",staReq->cellId);
+         /* Memory leak fix ccpu00135359 */
+         PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,staCfm, sizeof (UdxSduStaCfmInfo));
+         ret = RFAILED;
+      }
+   }
+   else
+   {
+      /* Memory leak fix ccpu00135359 */
+      if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&sduStaCfm, 
+         sizeof (CpjSduStaCfmInfo)) != ROK)
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,staCfm, sizeof (UdxSduStaCfmInfo));
+         PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->staReq, sizeof(CpjSduStaReqInfo));
+         PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+         RETVALUE(RFAILED);
+      }
+      sduStaCfm->ueId   = staCfm->ueId; 
+      sduStaCfm->cellId = staCfm->cellId;
+      sduStaCfm->transId = cfgInfo->uprLyrTransId;
+      sduStaCfm->status = RFAILED;
+      sduStaCfm->reason = staCfm->reason; 
+      sduStaCfm->numRb = staCfm->numRb; 
+
+      RLOG_ARG1(L_DEBUG,DBG_UEID,staCfm->ueId, 
+            "PjUlUdxSduStaCfm- UdxSduStaCfm fail - cellId(%d)",staCfm->cellId);
+
+      PjUiCpjSduStaCfm(&(cpjSap->pst), cpjSap->suId, sduStaCfm); 
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,staCfm, sizeof (UdxSduStaCfmInfo));
+   }
+
+   PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->staReq, sizeof(CpjSduStaReqInfo));
+   PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+
+   RETVALUE(ROK);
+}
+
+#ifdef ANSI
+PUBLIC S16 PjUlUdxDatResumeCfm
+(
+Pst                   *pst,
+SuId                  suId,
+UdxDatResumeCfmInfo   *udxDatResumeCfm
+)
+#else
+PUBLIC S16 PjUlUdxDatResumeCfm(pst, suId, udxDatResumeCfm)
+Pst                   *pst;
+SuId                  suId;
+UdxDatResumeCfmInfo   *udxDatResumeCfm;
+#endif
+{
+   S16                ret;
+   PjCpjSapCb        *cpjSap;
+   PjCb              *tPjCb;
+   PjCfgInfo         *cfgInfo;
+   CpjDatResumeReqInfo  *datResReq;  
+   CpjDatResumeCfmInfo  *datResumeCfmInfo;
+
+   TRC3(PjUlUdxDatResumeCfm)
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+#endif
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef DEBUGP
+   RLOG1(L_DEBUG, "PjUlUdxDatResumeCfm(post, suId(%d), ", suId); 
+#endif
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if (suId < 0)
+   {
+      /* INNC: ERROR CLASS */
+      RLOG0(L_ERROR, "Invalid suId");
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   ret = pjDbmFindUlTransIdLst(tPjCb, udxDatResumeCfm->transId, &cfgInfo);
+   if (ret != ROK)
+   {
+      RLOG0(L_ERROR, "Invalid transId");
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,udxDatResumeCfm, sizeof (UdxDatResumeCfmInfo));
+      RETVALUE (RFAILED);
+   }
+
+   datResReq = cfgInfo->datResReq;
+   
+   pjUtlUlPrcsDatResume (tPjCb, datResReq);
+
+
+   /* Perform processing for filling up cfm structures */
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+   if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&datResumeCfmInfo, 
+      sizeof (CpjDatResumeCfmInfo)) != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,udxDatResumeCfm, sizeof (UdxDatResumeCfmInfo));
+      PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->datResReq, sizeof(CpjDatResumeReqInfo));
+      PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+      RETVALUE(RFAILED);
+   }
+   datResumeCfmInfo->ueId = datResReq->ueId;
+   datResumeCfmInfo->cellId = datResReq->cellId;
+   datResumeCfmInfo->transId = datResReq->transId;
+   datResumeCfmInfo->status = CPJ_CFG_CFM_OK;
+   PjUiCpjDatResumeCfm(&(cpjSap->pst), cpjSap->suId, datResumeCfmInfo);
+
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,udxDatResumeCfm, sizeof (UdxDatResumeCfmInfo));
+   PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->datResReq, sizeof(CpjDatResumeReqInfo));
+   PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+
+   RETVALUE(ROK);
+}
+
+/**
+ * @brief
+ * This function processes Data Forwarding Confirm received from DL.
+ *
+ * Now the UL Module can start forwardng the UL Packets is Application 
+ * has requested for UL Data Forwarding.
+ *
+ *  @param[in] pst      post structure
+ *  @param[in] measType meas Type
+ *  @return S16
+ *      -# Success : ROK
+ *      -# Failure : RFAILED
+ */
+#ifdef ANSI 
+PUBLIC S16 PjUlUdxDatForwardCfm
+(
+ Pst               *pst,
+ SuId              suId,
+ UdxDatFwdCfmInfo  *datFwdCfm
+ )
+#else
+PUBLIC S16 PjUlUdxDatForwardCfm(pst, suId, datFwdCfm)
+ Pst               *pst;
+ SuId              suId;
+ UdxDatFwdCfmInfo  *datFwdCfm;
+#endif
+{
+   PjCb        *tPjCb;
+   PjUlUeCb    *ueCb;
+   PjUlRbCb    *pjRbCb;
+   S16          ret;
+   U8           rbCnt = 0;
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   ret = pjDbmFetchUlUeCb(tPjCb,datFwdCfm->ueId,
+         datFwdCfm->cellId, &ueCb);
+
+   /* Ue Cb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, datFwdCfm->cellId,"UeId[%u] not found",
+            datFwdCfm->ueId);
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo));
+      RETVALUE(ret);
+   }
+
+   /* Forward UL Packets only if Application has requested */
+   if(ueCb->isUlDatFwdReqd == TRUE)
+   {
+      /* Call the UL Pkt Fwd Func for each Rab */
+      for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt++)
+      {
+         if((pjRbCb = ueCb->drbCb[rbCnt]) == NULLP)
+         {
+            continue;
+         }
+         /* UL Data Forwarding done only for AM Mode Bearers 
+          * datQ is in Buffer State and only during Handover */
+         if((pjRbCb->mode == PJ_DRB_AM) && (ueCb->libInfo.state == PJ_STATE_REEST_HO))
+         {
+            pjUlmStartDataFrwdPerRb(tPjCb, pjRbCb);
+         }
+      }
+   }
+
+   PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo));
+   RETVALUE(ROK);
+}
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for Configuration Request on UL
+ *
+ * @b Description:
+ *
+ *        This function handles the configuration on UL after receiving 
+ *        the configuration confirm from DL.
+ *
+ *  @param[in] gCb     PDCP Instance Control block
+ *  @param[in] cfgInfo UL Configuration Info 
+ *  @param[in] cfmInfo Configuration Confirm Info 
+ *  @param[in] cfgCfm  Configuration Confirm Info 
+ *  @param[in] sndCfgCfm  Configuration Confirm Info 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+#ifdef ANSI
+PRIVATE S16 pjHdlCpjUlCfgReq
+(
+PjCb         *gCb,
+PjCfgInfo    *cfgInfo,
+UdxCfgCfmInfo *cfmInfo,
+CpjCfgCfmInfo *cfgCfm,
+Bool           *sndCfgCfm
+)
+#else
+PRIVATE S16 pjHdlCpjUlCfgReq(gCb, cfgInfo, cfmInfo, cfgCfm, sndCfgCfm)
+PjCb         *gCb;
+PjCfgInfo    *cfgInfo;
+UdxCfgCfmInfo *cfmInfo;
+CpjCfgCfmInfo *cfgCfm;
+Bool           *sndCfgCfm;
+#endif
+{
+   CpjCfgReqInfo       *cfg;
+   U8                   idx;
+   Bool                 cfmType = 0;
+   Bool                 startTmr;
+   PjUlUeCb            *ueCb;       /* UE Control Block for storing the
+                                          cfg structure in case of ReEstablishment */ 
+   PjCpjSapCb          *cpjSap;
+
+   cfg = cfgInfo->cfgInfo;
+   startTmr  = FALSE;
+   ueCb      = NULLP;
+
+   /* Fetch UeCb */
+   pjDbmFetchUlUeCb(gCb, cfg->ueId, cfg->cellId, &ueCb);
+  /* KW_FIX : CPJ_MAX_CFG,CPJ_MAX_CFM,UDX_MAX_CFM have the same value , hence checking for only one of them */
+   for (idx = 0; idx < cfg->numEnt && idx < CPJ_MAX_CFG; idx++)
+   {
+      CpjCfmEnt  *entCfgCfm;
+      UdxCfmEnt  *entDlCfgCfm;
+      CpjCfgEnt  *entCfg;
+
+      entCfg  = &(cfg->cfgEnt[idx]);
+      entCfgCfm   = &(cfgCfm->cfmEnt[idx]);
+      entDlCfgCfm = &(cfmInfo->cfmEnt[idx]);
+
+      if (NULL != ueCb)
+      {
+            /* Fill the detault values here */
+         PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, 
+                   CPJ_CFG_CFM_OK,CPJ_CFG_REAS_NONE);
+      }
+      else
+      {
+         RLOG_ARG1(L_INFO, DBG_CELLID, cfg->cellId,"UeId[%u] not found",
+            cfg->ueId);
+         PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, 
+                       CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN);
+         if (entCfg->cfgType !=  CPJ_CFG_ADD)
+         {
+            /* all other requests require ueCb mandatorily */
+            continue;
+         }
+       }
+            
+      switch (entCfg->cfgType)
+      {
+         case CPJ_CFG_ADD:
+            {
+               if (entCfg->m.addCfg.rlcInfo.dir & PJ_DIR_UL)
+               {
+                  U8 isHo;
+                  isHo = cfg->isHo;
+                  /* Add a new RB entity configuration */
+                  if (pjCfgAddUlRb(gCb,cfg->ueId, cfg->cellId, isHo,
+                              entCfg, &ueCb, entCfgCfm) != ROK)
+                  {
+#ifdef DEBUGP
+                      RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId,"UL RB Addition for"
+                            "cellId(%d),rbId(%d) Failed: reason (%d)",
+                            cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
+#endif
+                      PJ_CFG_FILL_CFG_CFM(entCfgCfm,entCfg->rbId,entCfg->rbType, 
+                            CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN);
+                  }
+                  /* Only In case of DRB only we need to set this flag */
+#ifdef PJ_CMP_ASYNC
+                  else if(PJ_DRB == entCfg->rbType)
+                  {
+                     if(entCfg->m.addCfg.hdrCompCfg.hdrCompUsed)
+                     {
+                        cfmType  |=  PJ_CFG_ASYNC_CFM;
+                        startTmr =  TRUE;
+                     }
+                  }
+#endif /* PJ_CMP_ASYNC */
+                  if (entCfg->m.addCfg.rlcInfo.dir & PJ_DIR_DL)
+                  {
+                      if (entDlCfgCfm->status != CPJ_CFG_CFM_OK)
+                      {
+                        PJ_MEM_CPY(entCfgCfm, entDlCfgCfm, 
+                                         sizeof(CpjCfmEnt));      /* KW_FIX */
+                      }
+                  }
+               }
+               else if (entCfg->m.addCfg.rlcInfo.dir & PJ_DIR_DL)
+               {
+                 PJ_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(CpjCfmEnt));       /* KW_FIX */
+               }
+               break;
+            }
+
+         case CPJ_CFG_MODIFY:
+            {
+               if ((entCfg->m.modCfg.bitFlag & 0x01) ||
+                   (entCfg->m.modCfg.hoInfo.isHoPres & CPJ_HO_UL))
+               {
+                  /* Re-configure the existing RB entity configuration */
+                  if (pjCfgReCfgUlRb(gCb,ueCb, entCfg, entCfgCfm) != ROK)
+                  {
+#ifdef DEBUGP
+                     RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId,"RB Config Modify HO"
+                        "for cellId(%d), rbId(%d) Failed :reason (%d)",
+                        cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
+#endif
+                  }
+#ifdef PJ_CMP_ASYNC
+                  else if(PJ_DRB == entCfg->rbType)
+                  {
+                     if(entCfg->m.modCfg.hdrCompCfg.hdrCompUsed)
+                     {
+                        cfmType  |=  PJ_CFG_ASYNC_CFM;
+                        startTmr =  TRUE;
+                     }
+                  }
+#endif /* PJ_CMP_ASYNC */
+                  if ((entCfg->m.modCfg.bitFlag & 0x02) ||
+                     (entCfg->m.modCfg.hdrCompCfg.hdrCompUsed) ||
+                     (entCfg->m.modCfg.hoInfo.isHoPres & CPJ_HO_DL))
+                  {
+                      if (entDlCfgCfm->status != CPJ_CFG_CFM_OK)
+                      {
+                        PJ_MEM_CPY(entCfgCfm, entDlCfgCfm, 
+                                         sizeof(CpjCfmEnt)); 
+                      }
+                  }
+               }
+               else  if (entCfg->m.modCfg.hdrCompCfg.hdrCompUsed) 
+               {
+                  /* Re-configure the existing RB entity configuration */
+                  if (pjCfgReCfgUlRb(gCb,ueCb, entCfg, entCfgCfm) != ROK)
+                  {
+#ifdef DEBUGP
+                     RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId,"UL RB Modify Normal"
+                        " for cellId(%d), rbId(%d) Failed: reason (%d)",
+                        cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
+#endif
+                     if (entCfgCfm->reason == CPJ_CFG_REAS_PDCPID_UNKWN)
+                     {
+                       PJ_MEM_CPY(entCfgCfm, entDlCfgCfm,sizeof(CpjCfmEnt)); 
+                     }
+                  }
+#ifdef PJ_CMP_ASYNC
+                  else if(PJ_DRB == entCfg->rbType)
+                  {
+                     if(entCfg->m.modCfg.hdrCompCfg.hdrCompUsed)
+                     {
+                        cfmType  |=  PJ_CFG_ASYNC_CFM;
+                        startTmr =  TRUE;
+                     }
+                  }
+#endif /* PJ_CMP_ASYNC */
+
+                  if ((entDlCfgCfm->reason != CPJ_CFG_REAS_PDCPID_UNKWN) &&
+                     (entDlCfgCfm->status != CPJ_CFG_CFM_OK))
+                  {
+                    /* send configuration to DL instance */
+                    PJ_MEM_CPY(entCfgCfm, entDlCfgCfm,sizeof(CpjCfmEnt));     /* KW_FIX */
+                  }
+               }
+               else  if ((entCfg->m.modCfg.bitFlag & 0x02) ||
+                     (entCfg->m.modCfg.hoInfo.isHoPres & CPJ_HO_DL))
+               {
+                  /* send configuration to DL instance */
+                  PJ_MEM_CPY(entCfgCfm, entDlCfgCfm,sizeof(CpjCfmEnt));  /* KW_FIX */
+               }
+               break;
+            }
+         case CPJ_CFG_DELETE:
+            {
+               /* Delete the existing RB entity configuration */
+               if (pjCfgDelUlRb(gCb,ueCb,entCfg, entCfgCfm) != ROK)
+               {
+#ifdef DEBUGP
+                  RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "Ul RB Delete for"
+                            "cellId(%d), rbId(%d) Failed: reason (%d)",
+                      cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
+#endif
+               }
+               if ((entDlCfgCfm->status != CPJ_CFG_CFM_OK) || (entCfgCfm->status != CPJ_CFG_CFM_OK))
+               {
+                   PJ_MEM_CPY(entCfgCfm, entDlCfgCfm, 
+                                    sizeof(CpjCfmEnt));   /* KW_FIX */
+               }
+               break;
+            }
+
+         case CPJ_CFG_REESTABLISH:
+            {
+               /* Re-establish the existing RB entity configuration */
+               if (pjCfgReEstUlRb(gCb,ueCb,entCfg, entCfgCfm, entDlCfgCfm) != ROK)
+               {
+                  RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "UL RB Re-establish "
+                        "for cellId(%d), rbId(%d) Failed: reason (%d)",
+                         cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
+
+               }
+               else
+               {
+                  cfmType  |=  PJ_CFG_REEST_ASYNC_CFM;
+                  startTmr = FALSE;
+               }
+               
+               break;
+            }
+         case CPJ_CFG_DELETE_UE:
+            {
+               /* Delete all RB entity configuration under UE */
+               if (pjCfgDelUlUe(gCb,ueCb,entCfg, entCfgCfm) != ROK)
+               {
+#ifdef DEBUGP
+                  RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "UL UE Delete for "
+                       "cellId(%d), rbId(%d) Failed: reason (%d)",
+                      cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
+#endif
+               }
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+               else
+               {
+                  /* Wait for any messages in the Demand q to be processed */
+                  cfmType  |=  PJ_CFG_UEDEL_ASYNC_CFM;
+                  startTmr =  TRUE;
+               }
+#endif /* (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) */
+               if (entDlCfgCfm->status == CPJ_CFG_CFM_OK)
+               {
+                   PJ_MEM_CPY(entCfgCfm, entDlCfgCfm,
+                                    sizeof(CpjCfmEnt));    /* KW_FIX */
+               }
+               break;
+            }
+         default:
+            {
+               PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
+                           CPJ_CFG_CFM_NOK, CPJ_CFG_REAS_INVALID_CFG);
+
+#ifdef DEBUGP
+               RLOG_ARG4(L_ERROR,DBG_UEID,cfg->ueId, "Cfg Req with Invalid Cfg"
+                     "Type cellId(%d), cfgType(%d), rbId(%d)) Failed: reason (%d)",
+                     cfg->cellId, entCfg->cfgType,
+                     cfg->cfgEnt[idx].rbId, CPJ_CFG_REAS_INVALID_CFG);
+#endif
+            }
+      }
+     /* ccpu00137221 : KW Fix */
+      if (NULLP == ueCb)
+      {
+         PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, 
+               CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN);
+      }
+   }
+
+   /* Assign number of entity configuraitons and suId */
+   cfgCfm->transId = cfgInfo->uprLyrTransId;
+   cfgCfm->ueId = cfg->ueId;
+   cfgCfm->cellId = cfg->cellId;
+   cfgCfm->numEnt = cfg->numEnt;
+   /* ccpu00137221 : KW Fix */
+   if (NULLP == ueCb)
+   {
+      RETVALUE(ROK);
+   }
+
+   if (cfmType & PJ_CFG_REEST_ASYNC_CFM)
+   {
+      if (ueCb->libInfo.numReEstCmp > 0)
+      {
+         if (ueCb->libInfo.numReEstCmp > ueCb->libInfo.numReEstDrb)
+         {
+            /* Error Case */
+            ueCb->libInfo.numReEstDrb = 0;
+            ueCb->libInfo.numReEstCmp = 0;
+         } 
+         else
+         {
+            ueCb->libInfo.numReEstDrb -= ueCb->libInfo.numReEstCmp;
+            ueCb->libInfo.numReEstCmp = 0;
+         }
+      }
+      if (ueCb->libInfo.numReEstDrb == 0)
+      {
+#ifdef PJ_ASYNC_CFM
+         pjUtlUlSaveCfmInfo(gCb, ueCb, cfmType, startTmr, ENTPJ, (PTR)cfgCfm, (PTR)cfg);
+#endif
+         pjUtlUlUpdUpSecKeys(gCb, ueCb);
+#ifdef PJ_ASYNC_CFM
+         /* Memory leak fix ccpu00135359 */
+        cpjSap = &(tPjCb->u.ulCb->cpjSap);
+        PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgCfm, sizeof(CpjCfgCfmInfo));
+        *sndCfgCfm = FALSE;
+#endif
+      }
+      else
+      {
+         pjUtlUlSaveCfmInfo(gCb, ueCb, cfmType, startTmr, ENTPJ, (PTR)cfgCfm, (PTR)cfg);
+         cpjSap = &(gCb->u.ulCb->cpjSap);
+         PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgCfm, sizeof(CpjCfgCfmInfo));
+         *sndCfgCfm = FALSE;
+      }
+   }
+   else
+   {
+      if (cfmType != 0)
+      {
+         pjUtlUlSaveCfmInfo(gCb, ueCb, cfmType, startTmr, ENTPJ, (PTR)cfgCfm, (PTR)cfg);
+         /* Memory leak fix ccpu00135359 */
+         cpjSap = &(gCb->u.ulCb->cpjSap);
+         PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgCfm, sizeof(CpjCfgCfmInfo));
+         *sndCfgCfm = FALSE;
+      }
+   }
+
+   RETVALUE(ROK);
+}
+
+
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_uim.c b/src/5gnrpdcp/pj_uim.c
new file mode 100755 (executable)
index 0000000..965e1fa
--- /dev/null
@@ -0,0 +1,2101 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE-PDCP Layer - Upper Interface Functions
+    
+        Type:    C file
+  
+        Desc:    Source code for PDCP Upper Interface Module
+                 This file contains following functions
+      
+        --PjUiCpjBndReq
+        --PjUiCpjUbndReq
+        --PjUiCpjCfgReq
+        --PjUiCpjUeIdChgReq
+        --PjUiCpjReEstReq
+        --PjUiCpjSecCfgReq
+        --PjUiCpjSduStaReq
+     
+
+        --PjUiPjuBndReq
+        --PjUiPjuUbndReq
+        --PjUiPjuDatReq
+        --PjUiPjuSduStaReq 
+
+     File:     pj_uim.c
+
+**********************************************************************/
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=227;
+/** @file pj_uim.c
+@brief PDCP Upper Interface Module 
+*/
+
+\f
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "lpj.h"           /* LPJ define */
+#include "cpj.h"           /* RRC layer */
+#include "pju.h"           /* PDCP service user */
+#include "pj_env.h"        /* RLC environment options */
+#include "pj.h"            /* RLC defines */
+#include "pj_ul.h"
+#include "pj_dl.h"
+#include "pj_err.h"
+#include "pj_udx.h"  /* udx interface */
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "lpj.x"           /* LM(PDCP) */
+#include "cpj.x"           /* RRC layer */
+#include "pju.x"           /* PDCP service user */
+#include "pj.x"
+#include "pj_udx.h"
+#include "pj_udx.x"
+#include "pj_ul.x"
+#include "pj_dl.x"
+#include "pj_lib.x"
+/* kw004.201 Assigned build issue in LTE RLC pj_uim.c */
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif /* __cplusplus */
+
+\f
+
+/*****************************************************************************
+ *                          CPJ INTERFACE
+ ****************************************************************************/
+/**
+ *
+ * @brief 
+ *
+ *        Handler for binding the PDCP upper layer service user with 
+ *        the PDCP layer.
+ *
+ * @b Description:
+ *
+ *        1. This function is used by PDCP user to request for binding to 
+ *        PDCP. @n
+ *        2. This function is called by the CPJ interface to bind 
+ *        PDCP's SAP (identified by spId) with the service user's
+ *        SAP (identified by suId). @n
+ *
+ *  @param[in] pst   Post structure  
+ *  @param[in] suId  Service user SAP ID 
+ *  @param[in] spId  Service provider ID
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiCpjBndReq 
+(
+Pst  *pst,   
+SuId suId,  
+SpId spId   
+)
+#else
+PUBLIC S16 PjUiCpjBndReq (pst, suId, spId)
+Pst *pst;    
+SuId suId;   
+SpId spId;   
+#endif
+{
+   PjCpjSapCb      *cpjSap;            /* pointer to session SAP */
+   S16             ret;                /* return value */
+   PjCb            *tPjCb;
+
+   TRC3(PjUiCpjBndReq)
+
+   ret = ROK;
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)   /* KW_FIX */
+   {
+       RETVALUE(RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   RLOG2(L_DEBUG, "PjUiCpjBndReq(pst, spId(%d), suId(%d))", spId, suId);
+
+  
+
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+
+   /* Verify CPJ SAP State */
+   switch(cpjSap->state)
+   {
+      /* SAP is configured but not bound */
+      case PJ_SAP_CFG:
+      case PJ_SAP_UBND:
+      {
+         /* copy bind configuration parameters in SSAP sap */
+         cpjSap->suId = suId;
+         cpjSap->pst.dstProcId = pst->srcProcId;
+         cpjSap->pst.dstEnt = pst->srcEnt;
+         cpjSap->pst.dstInst = pst->srcInst;
+
+         /* Update the State */
+         cpjSap->state = PJ_SAP_BND;
+
+         RLOG1(L_DEBUG, "PjUiCpjBndReq: state (%d)", cpjSap->state);
+         break;
+      }
+
+      /* SAP is already bound */
+      case PJ_SAP_BND:
+      {
+         /* 
+          * Sap is already bound check source, destination Entity and 
+          * Proc Id
+          */
+         if (cpjSap->pst.dstProcId != pst->srcProcId 
+               || cpjSap->pst.dstEnt != pst->srcEnt
+               || cpjSap->pst.dstInst != pst->srcInst
+               || cpjSap->suId != suId)
+         {
+            PJ_SEND_SAPID_ALARM(tPjCb, spId, LPJ_EVENT_CPJ_BND_REQ, LCM_CAUSE_INV_PAR_VAL);
+
+            RLOG1(L_DEBUG, "PjUiCpjBndReq: SAP already bound -- state(%d)", cpjSap->state);
+            ret = RFAILED;
+         }
+         break;
+      }
+
+     default:
+      {
+         PJ_SEND_SAPID_ALARM(tPjCb,spId, LPJ_EVENT_CPJ_BND_REQ, LCM_CAUSE_INV_STATE);
+         RLOG0(L_ERROR, "Invalid CPJ SAP State in Bind Req");
+         ret = RFAILED;
+         break;
+      }
+   }
+
+   if (ret == ROK)
+   {
+      PjUiCpjBndCfm(&(cpjSap->pst), cpjSap->suId, CM_BND_OK);
+   }
+   else
+   {
+      PjUiCpjBndCfm(&(cpjSap->pst), cpjSap->suId, CM_BND_NOK);
+   }
+
+   RETVALUE(ROK);
+} /* PjUiCpjBndReq */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler for unbinding the RLC upper layer service user CPJ with 
+ *        the RLC layer.
+ *
+ * @b Description:
+ *
+ *        1. This function is used by RLC user to request for unbinding  
+ *        with RLC. @n
+ *        2. This function is called by the CPJ interface to 
+ *        unbind with RLC. @n
+ *
+ *  @param[in] pst     Post structure  
+ *  @param[in] spId    Service provider SAP ID 
+ *  @param[in] reason  Reason for Unbinding 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiCpjUbndReq
+(
+Pst      *pst,            
+SpId     spId,           
+Reason   reason           
+)
+#else
+PUBLIC S16 PjUiCpjUbndReq(pst, spId, reason)
+Pst      *pst;       
+SpId     spId;      
+Reason   reason;      
+#endif
+{
+   PjCpjSapCb  *cpjSap;            /* CPJ SAP control block */
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   S16         ret;                /* Return Value */
+#endif
+   PjCb   *tPjCb;
+
+   TRC3(PjUiCpjUbndReq)
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)   /* KW_FIX */
+   {
+       RETVALUE(RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   RLOG2(L_DEBUG, "PjUiCpjUbndReq(pst, spId(%d), reason(%d))", spId, reason);
+
+   UNUSED(pst);
+   UNUSED(reason);
+
+   /* disable upper sap (CPJ) */
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   ret    = ROK;
+   PJ_GET_AND_VALIDATE_CPJSAP(tPjCb,cpjSap, EPJXXX, "PjUiCPjUbndReq", ret);
+   if ( ret != ROK )
+   {
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   cpjSap->state = PJ_SAP_CFG;
+
+   RETVALUE(ROK);
+} /* CpUiCpjUbndReq */
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for configuring PDCP entities.
+ *
+ * @b Description:
+ *
+ *        This function is used by RRC to configure(add/delete/modify/
+ *        reestalish/delete all RB in a UE) one or more PDCP entities. 
+ *
+ *        - CPJ_CFG_ADD          => pjCfgAddRb
+ *        - CPJ_CFG_MODIFY       => pjCfgReCfgRb
+ *        - CPJ_CFG_DELETE       => pjCfgDelRb
+ *        - CPJ_CFG_REESTABLISH  => pjCfgReEstRb
+ *        - CPJ_CFG_DELETE_UE    => pjCfgDelUe
+ *
+ *  @param[in] pst   -  Post structure  
+ *  @param[in] spId  -  Serive Provider ID 
+ *  @param[in] cfg   -  Configuration information for one or more PDCP entities. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiCpjCfgReq
+(
+Pst             *pst,
+SpId            spId,
+CpjCfgReqInfo   *cfg
+)
+#else
+PUBLIC S16 PjUiCpjCfgReq(pst, spId, cfg)
+Pst            *pst;
+SpId           spId;
+CpjCfgReqInfo  *cfg;
+#endif
+{
+   PjCpjSapCb           *cpjSap;       /* CPJ SAP Control Block */
+   PjUdxUlSapCb         *udxSap;       /* UDX SAP Control Block */ 
+   S16                  ret;           /* Return Value */
+   PjCb                 *tPjCb;
+   PjCfgInfo            *cfgInfo;      /* added here n below */
+   UdxCfgReqInfo        *udxCfgReqInfo;       
+   
+
+   TRC3(PjUiCpjCfgReq)
+
+   ret       = ROK;
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)   /* KW_FIX */
+   {
+       RETVALUE(RFAILED);
+   }
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+#ifndef ALIGN_64BIT
+   RLOG2(L_DEBUG, "PjUiPjuCfgReq(pst, spId(%d), TransId(%ld))", spId, cfg->transId);
+#else
+   RLOG2(L_DEBUG, "PjUiPjuCfgReq(pst, spId(%d), TransId(%d))", spId, cfg->transId);
+#endif
+
+   /* Get the cpjSap */
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret);
+   if (ret != ROK)
+   {
+      /* pj002.201 Freeing from proper region */
+      PJ_PST_FREE(pst->region, pst->pool, cfg, sizeof(CpjCfgReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst,udxCfgReqInfo,sizeof (UdxCfgReqInfo),ret);
+   if(ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_PST_FREE(pst->region, pst->pool, cfg, sizeof(CpjCfgReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+
+   PJ_MEM_CPY(udxCfgReqInfo,cfg,sizeof(UdxCfgReqInfo));
+   PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+
+   if (cfgInfo == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_PST_FREE(pst->region, pst->pool, cfg, sizeof(CpjCfgReqInfo));
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, udxCfgReqInfo, sizeof(UdxCfgReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   cfgInfo->uprLyrTransId = cfg->transId;
+   cfgInfo->transId = ++tPjCb->u.ulCb->transId; 
+   udxCfgReqInfo->transId = cfgInfo->transId;
+   cfgInfo->cfgInfo  = cfg;
+   ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo);
+   if (ret != ROK)
+   {
+      RLOG0(L_ERROR, "Addition to UL transId List Failed.");
+      PJ_PST_FREE(pst->region, pst->pool, cfg, sizeof(CpjCfgReqInfo));
+      PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, udxCfgReqInfo, sizeof(UdxCfgReqInfo));
+      PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+
+      RETVALUE(RFAILED);
+   }
+
+   udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
+   
+   PjUlUdxCfgReq(&(udxSap->pst), udxSap->spId,udxCfgReqInfo); 
+
+   RETVALUE(ret);
+} /* PjUiPjuCfgReq */
+
+/**
+ *@details This primitive is used by RRC to change the UeId for the existing UE
+           context.
+
+ * @param pst     -  Point to the pst structure
+ * @param spId    -  The ID of the service provider SAP in the PDCP layer 
+ * @param transId -  Transaction ID. This field uniquily identifies
+ *                   transaction between RRC and PDCP.
+ * @param ueInfo    -  Old UE Id Info for which the change request has come 
+ * @param newUeInfo -  New UE Id Info for existing UE context 
+ * @return ROK
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiCpjUeIdChgReq
+(
+Pst        *pst, 
+SpId       spId, 
+U32        transId, 
+CpjUeInfo  *ueInfo,
+CpjUeInfo  *newUeInfo
+)
+#else
+PUBLIC S16 PjUiCpjUeIdChgReq(pst,spId,transId,ueInfo,newUeInfo)
+Pst        *pst;
+SpId       spId;
+U32        transId;
+CpjUeInfo  *ueInfo;
+CpjUeInfo  *newUeInfo;
+#endif
+{
+   S16         ret;           /* Return Value */
+   PjCpjSapCb  *cpjSap;       /* CPJ SAP Control Block */
+   PjUdxUlSapCb  *udxSap;     /* UDX SAP Control Block */ 
+   PjCfgInfo   *cfgInfo;      
+
+   UdxUeInfo  *udxUeInfo;        
+   UdxUeInfo  *udxNewUeInfo;
+   PjCb         *tPjCb;
+   
+   TRC3(PjUiCpjUeIdChgReq)
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifndef ALIGN_64BIT
+   RLOG2(L_DEBUG, "PjUiCpjUeIdChgReq(pst, spId(%d), transId(%ld))", spId, transId);
+#else
+   RLOG2(L_DEBUG, "PjUiCpjUeIdChgReq(pst, spId(%d), transId(%d))", spId, transId);
+#endif
+
+   ret = ROK;
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+   
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret);
+   if (ret != ROK)
+   {
+      /* kw002.201 Freeing from proper region */
+      PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo));
+      PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo));
+      RETVALUE(RFAILED);
+   }
+
+   /* Allocate memory for CkwUeInfo */
+   udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxUeInfo, 
+                     sizeof (UdxUeInfo), ret);
+    if(ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      /* Free memory for CkwUeInfo */
+      /* Freeing from proper region */
+      PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo));
+      PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo));
+      RETVALUE(RFAILED);
+   }
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxNewUeInfo, 
+      sizeof (UdxUeInfo), ret);
+   if(ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      /* Free memory for CkwUeInfo */
+      /* Freeing from proper region */
+      PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxUeInfo, sizeof(UdxUeInfo));
+      PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo));
+      PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo));
+      RETVALUE(RFAILED);
+   }
+
+   PJ_MEM_CPY(udxUeInfo,ueInfo, sizeof(UdxUeInfo)); 
+   PJ_MEM_CPY(udxNewUeInfo,newUeInfo, sizeof (UdxUeInfo));
+
+   PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+   if (cfgInfo == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxUeInfo, sizeof(UdxUeInfo));
+      PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxNewUeInfo, sizeof(UdxUeInfo));
+      PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo));
+      PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo));
+      RETVALUE(RFAILED);
+   }
+
+   cfgInfo->uprLyrTransId = transId;
+   cfgInfo->transId = ++tPjCb->u.ulCb->transId; 
+   cfgInfo->ueInfo  = ueInfo;
+   cfgInfo->newUeInfo  = newUeInfo; 
+
+   if((ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo)) != ROK)
+   {
+      RLOG0(L_ERROR, "Addition to UL transId List Failed.");
+      PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxUeInfo, sizeof(UdxUeInfo));
+      PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxNewUeInfo, sizeof(UdxUeInfo));
+      PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo));
+      PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo));
+      RETVALUE(RFAILED);
+   }
+
+   
+   PjUlUdxUeIdChgReq(&(udxSap->pst),udxSap->spId,cfgInfo->transId,
+                                         udxUeInfo,udxNewUeInfo);
+
+   RETVALUE(ROK);
+} /* PjUiCpjUeIdChgReq */
+
+
+/**
+ *@details  
+ * 1. RRC uses this primitive to configure PDCP security parameters.
+ * Integrity protection and/or Ciphering are configured by RRC based on the
+ * selSecAct flag.  @n
+ * 2. Integirty Protection/Ciphering are configured per UE and applicable
+ * to all pdcp entities in that UE. Both Integrity protection and ciphering are
+ * re-configured during re-establishment.  @n
+ *
+ * @param pst     -  Point to the pst structure
+ * @param spId    -  The ID of the service provider SAP in the PDCP layer 
+ * @param secCfg  -  Security Configuration Info per UE.
+ *
+ * @return 
+ *       -# ROK
+ *       -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiCpjSecCfgReq
+(
+Pst              *pst,
+SpId             spId,
+CpjSecCfgReqInfo *secCfg
+)
+#else
+PUBLIC S16 PjUiCpjSecCfgReq(pst,spId,secCfg)
+Pst              *pst;
+SpId             spId;
+CpjSecCfgReqInfo *secCfg;
+#endif
+{
+   S16               ret;           /* Return Value */
+   PjUdxUlSapCb      *udxSap;       /* UDX SAP Control Block */ 
+   PjCb   *tPjCb;
+   PjCfgInfo        *cfgInfo;      
+   UdxSecCfgReqInfo *udxSecCfgReqInfo;
+
+   TRC2(PjUiCpjSecCfgReq)
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)    /* KW_FIX */
+   {
+       RETVALUE(RFAILED);
+   }
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifndef ALIGN_64BIT 
+   RLOG2(L_DEBUG, "PjUiCpjSecCfgReq(pst, spId(%d), TransId(%ld))", spId,
+               secCfg->transId);
+#else
+   RLOG2(L_DEBUG, "PjUiCpjSecCfgReq(pst, spId(%d), TransId(%d))", spId,
+               secCfg->transId);
+#endif
+
+   ret = ROK;
+
+   udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxSecCfgReqInfo,sizeof (UdxSecCfgReqInfo), ret);
+   if(ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   PJ_MEM_CPY(udxSecCfgReqInfo,secCfg,sizeof(UdxSecCfgReqInfo));
+   PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+
+   if (cfgInfo == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+   
+   cfgInfo->uprLyrTransId = secCfg->transId;
+   cfgInfo->transId = ++tPjCb->u.ulCb->transId; 
+   udxSecCfgReqInfo->transId = cfgInfo->transId;
+   cfgInfo->secCfgInfo  = secCfg;
+   ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo);
+   if (ret != ROK)
+   {
+      RLOG0(L_ERROR, "Addition to UL transId List Failed.");
+      RETVALUE(RFAILED);
+   }
+
+   PjUlUdxSecCfgReq(&(udxSap->pst), udxSap->spId,udxSecCfgReqInfo); 
+
+   RETVALUE(ret); 
+}
+
+/**
+ * @details
+ * 1. RRC uses this primitive to re-establish the PDCP entity. @n
+ * 2. This primitive is initiation of re-establishment procedure. @n
+ * 3. This prmitive and corresponding confirmation shall be followed by
+ *    PjUiCpjCfgReq procedure for entire re-establishment procedure to complete.
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used by
+ *                     PDCP to identify its SAP.
+ * @param[in] reEstReq - PDCP re-establishment request structure. 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiCpjReEstReq 
+(
+Pst             *pst, 
+SpId            spId, 
+CpjReEstReqInfo *reEstReq
+)
+#else 
+PUBLIC S16 PjUiCpjReEstReq(pst,spId,reEstReq)
+Pst             *pst;
+SpId            spId;
+CpjReEstReqInfo *reEstReq;
+#endif
+{
+   S16               ret;           /* Return Value */
+   PjCpjSapCb        *cpjSap;       /* CPJ SAP Control Block */
+   PjUdxUlSapCb      *udxSap;     /* UDX SAP Control Block */ 
+   PjCb   *tPjCb;
+   PjCfgInfo         *cfgInfo;      
+   UdxReEstReqInfo   *udxReEstReqInfo;
+   
+   TRC2(PjUiCpjReEstReq);
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)        /* KW_FIX */
+   {
+      PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo));
+      RETVALUE(RFAILED);
+   }
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   RLOG1(L_DEBUG, "PjUiCpjReEstReq(pst, spId(%d))", spId);
+
+   ret = ROK;
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret);
+   if (ret != ROK)
+   {
+      /* pj002.201 Freeing from proper region */  
+      PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxReEstReqInfo, 
+      sizeof (UdxReEstReqInfo), ret);
+   if(ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   PJ_MEM_CPY(udxReEstReqInfo,reEstReq,sizeof(UdxReEstReqInfo));
+
+   PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+   if (cfgInfo == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   cfgInfo->uprLyrTransId = reEstReq->transId;
+   cfgInfo->transId = ++tPjCb->u.ulCb->transId; 
+   udxReEstReqInfo->transId = cfgInfo->transId;
+   cfgInfo->reEstReq  = reEstReq;
+   ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo);
+   if (ret != ROK)
+   {
+      RLOG0(L_ERROR, "Addition to UL transId List Failed.");
+      PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo));
+      PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+      RETVALUE(RFAILED);
+   }
+
+   udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
+   PjUlUdxReEstReq(&(udxSap->pst), udxSap->spId,udxReEstReqInfo); 
+
+   RETVALUE(ROK); 
+}
+
+
+/**
+ * @details
+ * 1. RRC uses this primitive to request count value for all DRBs in a UE. @n
+ * 2. PDCP sends the UL and DL count values in the confirmation of this request. 
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] countReq - PDCP Count Request Information. 
+ *
+ * @return ROK
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiCpjCountReq 
+(
+Pst             *pst, 
+SpId            spId, 
+CpjCountReqInfo *countReq
+)
+#else
+PUBLIC S16 PjUiCpjCountReq(pst,spId,countReq)
+Pst             *pst;
+SpId            spId;
+CpjCountReqInfo *countReq;
+#endif
+{
+   S16               ret;           /* Return Value */
+   PjUdxUlSapCb      *udxSap;       /* UDX SAP Control Block */ 
+   PjCb   *tPjCb;
+   PjCfgInfo       *cfgInfo;     
+   UdxCountReqInfo *udxCountReqInfo;  
+
+   TRC2(PjUiCpjCountReq);
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)    /* KW_FIX */
+   {
+      PJ_PST_FREE(pst->region, pst->pool, countReq, sizeof(CpjCountReqInfo));
+      RETVALUE(RFAILED);
+   }
+  
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   RLOG1(L_DEBUG, "PjUiCpjCountReq(pst, spId(%d))", spId);
+
+   ret = ROK;
+  
+   udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxCountReqInfo, sizeof (UdxCountReqInfo), ret);
+   if(ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   PJ_MEM_CPY(udxCountReqInfo,countReq,sizeof(UdxCountReqInfo));
+   PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+
+   if (cfgInfo == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_PST_FREE(pst->region, pst->pool, countReq, sizeof(CpjCountReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   cfgInfo->uprLyrTransId = countReq->transId;
+   cfgInfo->transId = ++tPjCb->u.ulCb->transId; 
+   udxCountReqInfo->transId = cfgInfo->transId;
+   cfgInfo->cntReq  = countReq;
+   ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo);
+   if (ret != ROK)
+   {
+      RLOG0(L_ERROR, "Addition to UL transId List Failed.");
+      PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, udxCountReqInfo, sizeof(UdxCountReqInfo));
+      PJ_PST_FREE(pst->region, pst->pool, countReq, sizeof(CpjCountReqInfo));
+      PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+      RETVALUE(RFAILED);
+   }
+
+   
+   PjUlUdxCountReq(&(udxSap->pst), udxSap->spId,udxCountReqInfo); 
+
+   RETVALUE(ROK);
+}
+
+/**
+ * 
+ * @details
+ * 1. RRC uses this primitive to request the status of the SDUs for DRBs in an UE. @n
+ * 2. Its used as a reestablishment request during handover.  @n
+ * 3. This primitive is used to forward the handover control Information to the target
+ * eNodeB.
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] sduStaReq - PDCP SDU Status Request Information. 
+ *
+ * @return ROK
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiCpjSduStaReq 
+(
+Pst              *pst, 
+SpId             spId, 
+CpjSduStaReqInfo *staReq
+)
+#else
+PUBLIC S16 PjUiCpjSduStaReq(pst,spId,staReq)
+Pst              *pst;
+SpId             spId;
+CpjSduStaReqInfo *staReq;
+#endif
+{
+
+   S16               ret;           /* Return Value */
+   PjCpjSapCb        *cpjSap;       /* CPJ SAP Control Block */
+   PjUlUeCb          *ueCb;
+   PjUdxUlSapCb      *udxSap;       /* UDX SAP Control Block */ 
+   PjCb              *tPjCb;
+   PjCfgInfo         *cfgInfo;      /* added here n below */
+   UdxSduStaReqInfo  *udxSduStaReq;
+
+   TRC2(PjUiCpjSduStaReq);
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)       /* KW_FIX */
+   {
+      PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));   
+      RETVALUE(RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   RLOG1(L_DEBUG, "PjUiCpjSduStaReq(pst, spId(%d))", spId);
+
+   ret = ROK;
+   cpjSap = NULLP;
+
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret);
+   if (ret != ROK)
+   {
+      /* kw002.201 Freeing from proper region */
+      PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   ret = pjDbmFetchUlUeCb(tPjCb, staReq->ueId, staReq->cellId, &ueCb);
+   /* UeCb is not present */
+   if( ROK != ret || NULLP == ueCb)
+   { 
+      RLOG_ARG1(L_ERROR, DBG_CELLID, staReq->cellId,"UL UeId[%u] not found",
+            staReq->ueId);
+      CpjSduStaCfmInfo  *cfmInfo;
+      /* Memory leak fix ccpu00135359 */
+      cpjSap = &tPjCb->u.ulCb->cpjSap;
+      if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfmInfo, 
+         sizeof (CpjSduStaCfmInfo)) != ROK)
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));
+         RETVALUE(RFAILED);
+      }
+      cfmInfo->ueId = staReq->ueId;
+      cfmInfo->cellId = staReq->cellId;
+      cfmInfo->transId = staReq->transId;
+      cfmInfo->status = CPJ_CFG_CFM_NOK; 
+      cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN;
+
+      /* Caller should return cfm with failure */
+      RLOG_ARG1(L_DEBUG,DBG_UEID,staReq->ueId, "Prc Sdu Sta Req - UE Cb is not"
+            " found in cellId(%d)", staReq->cellId);
+
+      /* Send Failure SduStaCfm */
+      PjUiCpjSduStaCfm(&tPjCb->u.ulCb->cpjSap.pst, 
+                        tPjCb->u.ulCb->cpjSap.suId, cfmInfo);
+
+      PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));
+
+      RETVALUE(RFAILED);
+   }
+   /* Updating UE state to REEST during HO */
+   ueCb->libInfo.numReEstDrb = 0;
+   ueCb->libInfo.state = PJ_STATE_REEST_HO;
+
+   udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
+   ret = ROK;
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxSduStaReq, 
+      sizeof (UdxSduStaReqInfo), ret);
+   if(ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   PJ_MEM_CPY(udxSduStaReq,staReq,sizeof(UdxSduStaReqInfo));
+
+   PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+   if (cfgInfo == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));
+      PJ_PST_FREE(pst->region, pst->pool, udxSduStaReq, sizeof(UdxSduStaReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   cfgInfo->uprLyrTransId = staReq->transId;
+   cfgInfo->transId = ++tPjCb->u.ulCb->transId; 
+   udxSduStaReq->transId = cfgInfo->transId;
+   cfgInfo->staReq  = staReq;
+   ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo);
+   if (ret != ROK)
+   {
+      RLOG0(L_ERROR, "Addition to UL transId List Failed.");
+      PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));
+      PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, udxSduStaReq, sizeof(UdxSduStaReqInfo));
+      PJ_FREE(tPjCb, cfgInfo, sizeof(PjCfgInfo));
+
+      RETVALUE(RFAILED);
+   }
+
+   
+   PjUlUdxSduStaReq(&(udxSap->pst), udxSap->spId,udxSduStaReq); 
+
+   RETVALUE(ret);
+}
+
+
+/**
+ * 
+ * @details
+ * 1. RRC uses this primitive to resume data during Re-establishment and
+ * handover  
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] sduStaReq - PDCP SDU Status Request Information. 
+ *
+ * @return ROK
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiCpjDatResumeReq 
+(
+Pst                   *pst, 
+SpId                  spId, 
+CpjDatResumeReqInfo   *datResReq
+)
+#else
+PUBLIC S16 PjUiCpjDatResumeReq(pst,spId, *dataResReq)
+Pst                   *pst;
+SpId                  spId;
+CpjDatResumeReqInfo   *datResReq;
+#endif
+{
+
+   S16               ret;           /* Return Value */
+   PjCpjSapCb        *cpjSap;       /* CPJ SAP Control Block */
+   PjUdxUlSapCb      *udxSap;       /* UDX SAP Control Block */ 
+   PjUlUeCb          *ueCb;
+   PjCfgInfo         *cfgInfo;      
+   PjCb              *tPjCb;
+   UdxDatResumeInfo  *udxDatResumeInfo;
+   TRC2(PjUiCpjDatResumeReq);
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   RLOG1(L_DEBUG, "PjUiCpjDatResumeReq(pst, spId(%d))", spId);
+
+   ret = ROK;
+   cpjSap = NULLP;
+
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret);
+   if (ret != ROK)
+   {
+      RETVALUE(RFAILED);
+   }
+   ret = pjDbmFetchUlUeCb(tPjCb, datResReq->ueId,
+                                 datResReq->cellId, &ueCb);
+   if (ret != ROK)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, datResReq->cellId,"UL UeId[%u] not found",
+            datResReq->ueId);
+      PJ_PST_FREE(pst->region, pst->pool, datResReq, sizeof(CpjDatResumeReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+    /* Memory leak fix ccpu00135359 */
+   udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
+   ret = ROK;
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxDatResumeInfo, 
+      sizeof (UdxDatResumeInfo), ret);
+   if(ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_PST_FREE(pst->region, pst->pool, datResReq, sizeof(CpjDatResumeReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
+   if (cfgInfo == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_PST_FREE(pst->region, pst->pool, datResReq, sizeof(CpjDatResumeReqInfo));
+      PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, udxDatResumeInfo, sizeof(UdxDatResumeInfo));
+      RETVALUE(RFAILED);
+   }
+
+   cfgInfo->uprLyrTransId = datResReq->transId;
+   cfgInfo->transId = ++tPjCb->u.ulCb->transId; 
+   udxDatResumeInfo->transId = cfgInfo->transId;
+   cfgInfo->datResReq  = datResReq;
+   udxDatResumeInfo->ueId = datResReq->ueId;
+   udxDatResumeInfo->cellId = datResReq->cellId;
+   ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo);
+   if (ret != ROK)
+   {
+      RLOG0(L_ERROR, "Addition to UL transId List Failed.");
+      PJ_PST_FREE(pst->region, pst->pool, datResReq, sizeof(CpjDatResumeReqInfo));
+      PJ_FREE(tPjCb, cfgInfo, sizeof(PjCfgInfo));
+      PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, udxDatResumeInfo, sizeof(UdxDatResumeInfo));
+
+      RETVALUE(RFAILED);
+   }
+   
+   PjUlUdxDatResumeReq(&(udxSap->pst), udxDatResumeInfo); 
+
+   RETVALUE(ret);
+}
+
+/**
+ * 
+ * @details
+ * 1. RRC uses this primitive to start data forwarding during
+ * handover  
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] sduStaReq - PDCP SDU Status Request Information. 
+ *
+ * @return ROK
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiCpjDatForwardReq 
+(
+Pst                 *pst, 
+SpId                spId, 
+CpjDataFwdReqInfo   *dataFwdReq
+)
+#else
+PUBLIC S16 PjUiCpjDatForwardReq(pst,spId, *dataFwdReq)
+Pst                 *pst;
+SpId                spId;
+CpjDataFwdReqInfo   *dataFwdReq;
+#endif
+{
+
+   S16               ret;           /* Return Value */
+   PjCpjSapCb        *cpjSap;       /* CPJ SAP Control Block */
+   PjUdxUlSapCb      *udxSap;       /* UDX SAP Control Block */ 
+   PjUlUeCb          *ueCb;
+   CmLteRnti     ueId;                   /*!< UE ID */
+   CmLteCellId   cellId;                 /*!< Cell ID */
+   UdxDatForwardInfo  *udxDatForwardInfo;
+
+   PjCb              *tPjCb;
+   TRC2(PjUiCpjDatForwardReq);
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   RLOG1(L_DEBUG, "PjUiCpjDatForwardReq(pst, spId(%d))", spId);
+
+   ret = ROK;
+   cpjSap = NULLP;
+
+   ueId = dataFwdReq->ueId;
+   cellId = dataFwdReq->cellId;
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret);
+   if (ret != ROK)
+   {
+      PJ_PST_FREE(pst->region, pst->pool, dataFwdReq, sizeof(CpjDataFwdReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   ret = pjDbmFetchUlUeCb(tPjCb, ueId, cellId, &ueCb);
+   if (ret != ROK)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, cellId,"UL UeId[%u] not found",ueId);
+      PJ_PST_FREE(pst->region, pst->pool, dataFwdReq, sizeof(CpjDataFwdReqInfo));
+      RETVALUE(RFAILED);
+   }
+   /* Store the UL Data Forwarding Req or not in ueCb */
+   ueCb->isUlDatFwdReqd = dataFwdReq->isUlDatFwdReq;
+  
+   ret = ROK;
+   /* Memory leak fix ccpu00135359 */
+   udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxDatForwardInfo, 
+      sizeof (UdxDatForwardInfo), ret);
+   if(ret != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_PST_FREE(pst->region, pst->pool, dataFwdReq, sizeof(CpjDataFwdReqInfo));
+      RETVALUE(RFAILED);
+   }
+
+   /* TODO :- Need to add code for handling request */
+
+   /* Forwarding request to DL over UDX interface */
+   udxDatForwardInfo->ueId = ueId;
+   udxDatForwardInfo->cellId = cellId;
+   udxDatForwardInfo->transId = dataFwdReq->transId;
+  
+   PJ_PST_FREE(pst->region, pst->pool, dataFwdReq, sizeof(CpjDataFwdReqInfo)); 
+   if(ueCb->isUlDatFwdReqd == TRUE)
+   {
+      /* Snd ULFwd - TRUE to DL 
+       * So that DL will not send isLastDatInd Flag to DAM */
+      udxDatForwardInfo->ulFwding = TRUE;
+   }
+   PjUlUdxDatForwardReq(&(udxSap->pst), udxDatForwardInfo); 
+
+   RETVALUE(ret);
+}
+
+\f
+/*****************************************************************************
+ *                          PJU INTERFACE
+ ****************************************************************************/
+/**
+ *
+ * @brief 
+ *
+ *        Handler for binding the PDCP upper layer service user with 
+ *        the PDCP layer.
+ *
+ * @b Description:
+ *
+ *        1. This function is used by PDCP user to request for binding to 
+ *        PDCP. @n
+ *        2. This function is called by the PJU interface to bind 
+ *        PDCP's SAP (identified by spId) with the service user's
+ *        SAP (identified by suId). 
+ *
+ *  @param[in] pst   Post structure  
+ *  @param[in] suId  Service user SAP ID 
+ *  @param[in] spId  Service provider ID
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiPjuBndReq 
+(
+Pst       *pst,    
+SuId      suId,   
+SpId      spId     
+)
+#else
+PUBLIC S16 PjUiPjuBndReq (pst, suId, spId)
+Pst       *pst;    
+SuId      suId;    
+SpId      spId;    
+#endif
+{
+   S16            ret;           /* Return Value */
+   PjPjuSapCb     *pjuSap;       /* SAP Config Block */
+   PjCb   *tPjCb;
+   
+   TRC3(PjUiPjuBndReq)
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)  /* KW_FIX */
+   {
+      RETVALUE(RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   RLOG2(L_DEBUG, "PjUiPjuBndReq(pst, spId(%d), suId(%d))", spId, suId);
+
+   ret = ROK;
+   pjuSap = NULLP;
+
+   /* Validation of input parameters */
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   if(!((spId < (S16) tPjCb->pjGenCfg.maxPjuSaps) && (spId >=0))) 
+   {
+      if(pjuSap != NULLP) 
+      {
+         RLOG0(L_ERROR, "Invalid PJU SAP State in Bind Req");
+         PJ_SEND_SAPID_ALARM(tPjCb,spId, LPJ_EVENT_PJU_BND_REQ, LCM_CAUSE_INV_SAP);
+         RETVALUE(RFAILED); 
+      }
+   }
+#endif
+
+   /* Get Sap control block */
+   if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      pjuSap = (PjPjuSapCb*)(tPjCb->u.ulCb->pjuSap + spId);
+   }
+   else
+   {
+      pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId);
+   }
+
+   /* Verify PJU SAP State */
+   switch(pjuSap->state)
+   {
+      /* SAP is configured but not bound */
+      case PJ_SAP_CFG:
+      case PJ_SAP_UBND:
+      {
+         /* copy bind configuration parameters in SSAP sap */
+         pjuSap->suId          = suId;
+         pjuSap->pst.dstProcId = pst->srcProcId;
+         pjuSap->pst.dstEnt    = pst->srcEnt;
+         pjuSap->pst.dstInst   = pst->srcInst;
+
+         /* Update the State */
+         pjuSap->state = PJ_SAP_BND;
+
+         /* DEBUG_PRINT */
+         RLOG1(L_DEBUG, "PjUiPjuBndReq: state (%d)", pjuSap->state);
+         break;
+      }
+
+      /* SAP is already bound */
+      case PJ_SAP_BND:
+      {
+         /* 
+          * Sap is already bound check source, destination Entity and 
+          * Proc Id
+          */
+         if (pjuSap->pst.dstProcId != pst->srcProcId 
+               || pjuSap->pst.dstEnt != pst->srcEnt
+               || pjuSap->pst.dstInst != pst->srcInst
+               || pjuSap->suId != suId)
+         {
+            RLOG4(L_DEBUG, "Ui Pju Bnd Req suId(%d)<>suId(%d),"
+                  "pst->srcProcId(%d)<>pjuSap->pst.dstProcId(%d)",
+                  suId, pjuSap->suId, pst->srcProcId, pjuSap->pst.dstProcId);
+
+            RLOG4(L_DEBUG,"Ui Pju Bnd Req pst->srcEnt(%d)<>pjuSap->pst.dstEnt"
+                  "(%d),pst->srcInst(%d)<>pjuSap->pst.dstInst(%d))",
+              pst->srcEnt,pjuSap->pst.dstEnt,pst->srcInst,pjuSap->pst.dstInst);
+
+            PJ_SEND_SAPID_ALARM(tPjCb, spId, LPJ_EVENT_PJU_BND_REQ, LCM_CAUSE_INV_PAR_VAL);
+            ret = RFAILED;
+         }
+         break;
+      }
+
+     default:
+      {
+         /* LOG ERROR */
+         RLOG0(L_ERROR, "Invalid PJU SAP State in Bind Req");
+         PJ_SEND_SAPID_ALARM(tPjCb,spId, LPJ_EVENT_PJU_BND_REQ, LCM_CAUSE_INV_STATE);
+         ret = RFAILED;
+         break;
+      }
+   }
+
+   if (ret == ROK)
+   {
+      PjUiPjuBndCfm(&(pjuSap->pst), pjuSap->suId, CM_BND_OK);
+   }
+   else
+   {
+      PjUiPjuBndCfm(&(pjuSap->pst), pjuSap->suId, CM_BND_NOK);
+   }
+
+   RETVALUE(ROK);
+
+} /* PjUiPjuBndReq */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler for unbinding the PDCP upper layer service user with 
+ *        the PDCP layer.
+ *
+ * @b Description:
+ *
+ *        1. This function is used by PDCP user to request for unbinding  
+ *        with PDCP. @n
+ *        2. This function is called by the PJU interface to 
+ *        unbind with PDCP. 
+ *
+ *  @param[in] pst     Post structure  
+ *  @param[in] suId    Service user SAP ID 
+ *  @param[in] reason  Reason for Unbinding 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiPjuUbndReq
+(
+Pst      *pst,   
+SpId     spId,    
+Reason   reason     
+)
+#else
+PUBLIC S16 PjUiPjuUbndReq(pst, spId, reason)
+Pst      *pst;       
+SpId     spId;     
+Reason   reason;      
+#endif
+{
+   PjPjuSapCb  *pjuSap;            /* PJU SAP control block */
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   S16         ret; 
+#endif
+   PjCb   *tPjCb;
+
+   TRC3(PjUiPjuUbndReq)
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)      /* KW_FIX */
+   {
+      RETVALUE(RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+   /* DEBUG_PRINT */
+   RLOG2(L_DEBUG, "PjUiPjuUbndReq(pst, spId(%d), reason(%d))", spId, reason);
+
+   pjuSap = NULLP;
+
+   UNUSED(pst);
+   UNUSED(reason);
+
+   /* Get Sap control block */
+   if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      pjuSap = (PjPjuSapCb*)(tPjCb->u.ulCb->pjuSap + spId);
+   }
+   else
+   {
+      pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId);
+   }
+
+
+#if (ERRCLASS & ERRCLS_INT_PAR)
+   PJ_GET_AND_VALIDATE_PJUSAP(tPjCb, pjuSap, EPJXXX, "PjUiPjuUbndReq", ret);
+   if (ret != ROK )
+   {
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   pjuSap->state = PJ_SAP_CFG;
+
+   RETVALUE(ROK);
+} /* PjUiPjuUbndReq */
+
+/**
+ * @details
+ * This primitive is used by the PDCP service user to request PDCP
+ * for data transfer.
+ *
+ * @param[in] pst    - Pointer to Pst structure.
+ * @param[in] spId  - Service provider ID. This is the reference number
+ * used by PDCP service user (Relay) to identify its SAP. This reference number
+ * will be provided by PDCP in any further primitives sent by PDCP
+ * to the service user.
+ * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP id is used to 
+ * uniquely identify an PDCP entity. 
+ * @param[in] sduId  - SDU ID. 
+ * @param[in] mBuf   - Pointer to data buffer.
+ *
+ * @return ROK
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiPjuDatReq
+(
+Pst            *pst,            
+SpId           spId,               
+CmLtePdcpId    *pdcpId,         
+PjuSduId       sduId,           
+Buffer         *mBuf          
+)
+#else
+PUBLIC S16 PjUiPjuDatReq(pst, spId, pdcpId, sduId, mBuf)
+Pst             *pst;       
+SpId            spId;           
+CmLtePdcpId     *pdcpId;     
+PjuSduId         sduId;   
+Buffer          *mBuf;          
+#endif
+{
+#ifndef NO_ERRCLS
+   S16         ret;           /* Return Value */
+#endif
+   PjDlRbCb   *pjRbCb;       /* RB Control Block */
+   PjDlUeCb   *ueCb;         /* UE Control Block */
+#ifndef CCPU_OPT
+   MsgLen      len;           /* Size of the SDU */
+#endif
+#ifndef NO_ERRCLS
+   PjPjuSapCb  *pjuSap;       /* SAP Config Block */
+#endif
+   PjCb   *tPjCb;
+   U32   count;         /* count for the PDU */
+#ifndef CCPU_OPT
+   PjuDatCfmInfo *datCfm;
+   CmLtePdcpId *tPdcpId;
+   PjPjuSapCb  *tPjuSap;
+#endif /*CCPU_OPT */
+   TRC3(PjUiPjuDatReq)
+
+#ifdef CA_PHY_BRDCM_61765 
+   EXTERN U32 dlrate_pju1;
+   MsgLen len;
+   SFndLenMsg(mBuf, (MsgLen *) &len);
+   dlrate_pju1 += len;
+#endif
+
+   if ((pst->dstInst >= PJ_MAX_PDCP_INSTANCES) || (mBuf == NULLP))      /* KW_FIX */
+   {
+      PJ_PST_FREE(pst->region, pst->pool, pdcpId, sizeof(CmLtePdcpId));
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifndef NO_ERRCLS
+   pjuSap = NULLP;
+#endif
+
+#ifndef NO_ERRCLS
+   ret = ROK;
+   pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId);
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb, spId, pjuSap, ret);
+   if (ret != ROK)
+   {
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+#endif
+   /* Fetch the RbCb */
+   if (pjDbmFetchDlUeCb(tPjCb, pdcpId->ueId, pdcpId->cellId, &ueCb) != ROK)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, pdcpId->cellId,"DL UeId[%u] not found",
+            pdcpId->ueId);
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+   /* Fetch the RbCb */
+   
+   PJ_DBM_FETCH_DL_RBCB(pdcpId->rbId, pdcpId->rbType, ueCb,pjRbCb);
+   if (pjRbCb == NULLP)
+   {     
+      RLOG_ARG2(L_ERROR, DBG_UEID,pdcpId->ueId, "CellId[%u]: DL RbId[%d] not found",
+            pdcpId->cellId, pdcpId->rbId);
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }
+
+   /* Update the total packets received for L2 Measurements */
+   PJ_UPD_L2_DLDISC_PKT_STS(tPjCb,pjRbCb);
+   
+#ifdef PTPJLIB 
+   /* kw003.201 Control for packet administration */
+   if (pjLibPktAdmCtrl(pjRbCb, mBuf) != ROK)
+   {
+      RLOG_ARG2(L_DEBUG,DBG_UEID,pdcpId->ueId, "Pju Dat Req: PDCP pkt dropped for"
+           " cellId(%d),rbId(%d)", pdcpId->cellId, pdcpId->rbId);
+      PJ_FREE_BUF(mBuf);
+      gPdcpStats.numPdcpSdusDiscarded++;
+      PJ_UPD_L2_DLDISC_STS(tPjCb, pjRbCb);
+      {
+#ifdef CA_PHY_BRDCM_61765
+         EXTERN U32 gDbgPdcpDropCnt;
+         gDbgPdcpDropCnt++;
+#endif
+      }
+      RETVALUE(RFAILED);
+   }
+#endif
+#ifndef CCPU_OPT
+   SFndLenMsg(mBuf, &len);
+   if ( len > PJ_MAX_SDU_SIZE )
+   {
+#if (ERRCLASS & ERRCLS_INT_PAR)
+      RLOG_ARG2(L_ERROR, DBG_RBID, pjRbCb->rbId , "Processing DL Sdu failed, PDU size [%lu] > MAX_LEN [%lu]",
+         len, PJ_MAX_SDU_SIZE);
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+      if ( pjRbCb->dlCb.cfmReqd)
+      {
+         if (pjRbCb->rbType == PJ_SRB)
+            tPjuSap   = (PjPjuSapCb*)(tPjCb->pjuSap + PJ_SRB_SAP);
+         else
+            tPjuSap   = (PjPjuSapCb*)(tPjCb->pjuSap + PJ_DRB_SAP);
+
+    datCfm = &datCfmTmp;
+    tpdcpId = &tpdcpIdTmp;
+
+         datCfm->cfmSta[datCfm->numSdus].sduId = sduId;
+         datCfm->cfmSta[datCfm->numSdus].status = PJU_MAX_SDU_SIZ_EXCEED;
+         datCfm->numSdus++;
+         tPdcpId->rbId   = pjRbCb->rbId;
+         tPdcpId->rbType = pjRbCb->rbType;
+         tPdcpId->ueId   = pjRbCb->ueCb->key.ueId;
+         tPdcpId->cellId = pjRbCb->ueCb->key.cellId;
+         PjUiPjuDatCfm(&(tPjuSap->pst), tPjuSap->suId, tPdcpId, datCfm);
+      }
+
+      tPjCb->pjGenSts.numCmpFails++;
+
+      PJ_FREE_BUF(mBuf);
+      RETVALUE(RFAILED);
+   }   
+#endif
+
+   if((pjRbCb->state != PJ_STATE_NORMAL) && (pjRbCb->rbType != PJ_SRB))
+   {
+#ifdef PRE_DEF_UE_CTX_HO      
+      pjRbCb->state = PJ_STATE_NORMAL;
+#endif       
+      if(pjRbCb->dlCb.dlPktQ.count < 500)
+      {
+/*         MSPD_DBG(" Queuing the Packets in Reestablish/Ho state ");*/
+         pjDlmEnqueueDlPkt(tPjCb, pjRbCb, PJ_DATA_NRM_PKT, NULL, sduId, mBuf); 
+         RETVALUE(ROK);
+      }
+      else
+      {
+         PJ_FREE_BUF(mBuf);
+         gPdcpStats.numPdcpSdusDiscarded++;
+         PJ_UPD_L2_DLDISC_STS(tPjCb, pjRbCb);
+         RETVALUE(RFAILED);
+      }
+   }
+   PJ_DLM_UPD_VAR(pjRbCb,count);
+   pjDlmProcessSdus(tPjCb, pjRbCb, mBuf, sduId,count);
+
+   /* kw005.201 ccpu00117318, updated statistics */
+   RETVALUE(ROK);
+} /* PjUiPjuDatReq */
+
+
+#ifdef FLAT_BUFFER_OPT
+/**
+ * @details
+ * This primitive is used by the PDCP service user to request PDCP
+ * for data transfer.
+ *
+ * @param[in] pst    - Pointer to Pst structure.
+ * @param[in] spId  - Service provider ID. This is the reference number
+ * used by PDCP service user (Relay) to identify its SAP. This reference number
+ * will be provided by PDCP in any further primitives sent by PDCP
+ * to the service user.
+ * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP id is used to 
+ * uniquely identify an PDCP entity. 
+ * @param[in] sduId  - SDU ID. 
+ * @param[in] mBuf   - Pointer to Flat buffer.
+ *
+ * @return ROK
+ */
+
+#ifdef ANSI
+PUBLIC S16 PjUiPjuDatReqFB
+(
+Pst            *pst,            
+SpId           spId,               
+CmLtePdcpId    *pdcpId,         
+PjuSduId       sduId,           
+FlatBuffer         *mBuf          
+)
+#else
+PUBLIC S16 PjUiPjuDatReqFB(pst, spId, pdcpId, sduId, mBuf)
+Pst             *pst;       
+SpId            spId;           
+CmLtePdcpId     *pdcpId;     
+PjuSduId         sduId;   
+FlatBuffer          *mBuf;          
+#endif
+{
+   PjDlRbCb   *pjRbCb;       /* RB Control Block */
+   PjDlUeCb   *ueCb;         /* UE Control Block */
+#ifndef CCPU_OPT
+   MsgLen      len;          /* Size of the SDU */
+#endif
+#ifndef NO_ERRCLS
+   PjPjuSapCb     *pjuSap;       /* SAP Config Block */
+#endif
+   PjCb           *tPjCb = NULLP;/* KW_FIX */
+   PjTxEnt        *txEnt=NULLP;
+#ifndef NO_ERRCLS
+   S16         ret;          /* Return Value */
+   PjUeKey  key;
+#endif
+
+#ifdef L2_PDCP_OPTMZ   
+   U8       hashKey;          /* Computed HashKey */
+   PjBuf       *buf; 
+#endif 
+   TRC3(PjUiPjuDatReqFB)
+
+   if ((pst->dstInst >= PJ_MAX_PDCP_INSTANCES) || (mBuf == NULLP))      /* KW_FIX */
+   {
+      /* PJ_FREE_FLAT_BUF(tPjCb, mBuf); */
+      RETVALUE(RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifndef NO_ERRCLS
+   ret = ROK;
+   pjuSap = NULLP;
+#endif
+
+#ifdef DEBUGP
+   /* DEBUG_PRINT */
+   RLOG1(L_DEBUG, "PjUiPjuDatReq(pst, spId(%d))", spId);
+#endif
+
+#ifndef NO_ERRCLS
+   pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId);
+   /* Validate SAP ID under ERRORCLS */
+   PJ_VALDATE_SAP(tPjCb, spId, pjuSap, ret);
+   if (ret != ROK)
+   {
+      PJ_FREE_FLAT_BUF(tPjCb, mBuf);
+      RETVALUE(RFAILED);
+   }
+#endif
+   /* Fetch the UeCb */
+   if (pjDbmFetchDlUeCb(tPjCb, pdcpId->ueId, pdcpId->cellId, &ueCb) != ROK)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, pdcpId->cellId,"DL UeId[%u] not found",
+            pdcpId->ueId);
+      PJ_FREE_FLAT_BUF(tPjCb, mBuf);
+      RETVALUE(RFAILED);
+   }
+   /* Fetch the RbCb */
+   PJ_DBM_FETCH_DL_RBCB(pdcpId->rbId, pdcpId->rbType, ueCb,pjRbCb);
+   
+   if (pjRbCb == NULLP)
+   {     
+      RLOG_ARG2(L_ERROR, DBG_UEID,pdcpId->ueId, "CellId[%u]: DL RbId[%d] not found",
+            pdcpId->cellId, pdcpId->rbId);
+      PJ_FREE_FLAT_BUF(tPjCb, mBuf);
+      RETVALUE(RFAILED);
+   }
+
+   /* Update the total packets received for L2 Measurements */
+   PJ_UPD_L2_DLDISC_PKT_STS(tPjCb,pjRbCb);
+
+#ifdef PTPJLIB 
+   /* kw003.201 Control for packet administration */
+   
+   if (pjLibPktAdmCtrl(pjRbCb, NULL) != ROK)
+   {
+      RLOG_ARG2(L_DEBUG,DBG_UEID,pdcpId->ueId,"PDCP pkt Q is Full & pkt dropped"
+            " for cellId(%d), rbId(%d)", pdcpId->cellId, pdcpId->rbId);
+      PJ_FREE_FLAT_BUF(tPjCb, mBuf);
+      gPdcpStats.numPdcpSdusDiscarded++;
+      PJ_UPD_L2_DLDISC_STS(tPjCb, pjRbCb);
+      RETVALUE(RFAILED);
+   }
+#endif
+
+   if((ueCb->libInfo.state != PJ_STATE_NORMAL) && (pjRbCb->rbType != PJ_SRB))
+   {
+      if(pjRbCb->dlCb.dlPktQ.count < 500)
+      {
+         pjDlmEnqueueDlPktFB(tPjCb, pjRbCb, PJ_DATA_NRM_PKT, NULL, sduId, mBuf); 
+         RETVALUE(ROK);
+      }
+      else
+      {
+         PJ_FREE_FLAT_BUF(tPjCb, mBuf);
+         gPdcpStats.numPdcpSdusDiscarded++;
+         PJ_UPD_L2_DLDISC_STS(tPjCb, pjRbCb);
+         RETVALUE(RFAILED);
+      }
+   }
+
+   PJ_ALLOC(tPjCb, txEnt, sizeof(PjTxEnt));
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if (txEnt == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      PJ_FREE_FLAT_BUF(gCb,sdu);
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_RES */ 
+   PJ_DLM_UPD_VAR(pjRbCb,txEnt->count);     
+   PJ_DLM_GET_SN(pjRbCb,txEnt->count,txEnt->sn);
+   pjRbCb->dlCb.count = txEnt->count; 
+   txEnt->state = PJ_SDU_RECEIVED;
+   txEnt->sduId = sduId;
+   txEnt->fb   = *mBuf;
+   txEnt->pdu   = NULLP;
+   txEnt->sdu   = NULLP;
+   /* Insert TxEnt into the transmission buffer */
+#ifndef L2_PDCP_OPTMZ
+   pjDbmInsTxEnt(tPjCb, &(pjRbCb->dlCb.txBuf), txEnt); 
+   /* kw005.201 added support for L2 Measurement */
+#else
+   if (pjRbCb->ueCb->secInfo.secAct &&  pjRbCb->ueCb->secInfo.cipherInfo.algoType != 0)   /* If its not NULL Ciphering and Security is enabled */
+   {
+   txEnt->datCfmEnt.node = NULLP;
+   txEnt->reEstPktEnt.node = NULLP;
+   txEnt->sduSubmitEnt.node = (PTR)NULLP;
+
+   buf=&(pjRbCb->dlCb.txBuf);
+   hashKey = (U8)PJ_HASH_FN(buf, txEnt->count); /*KW_FIX*/
+
+   txEnt->lstEnt.node = (PTR)txEnt;
+   cmLListAdd2Tail(&buf->datQ[hashKey], &txEnt->lstEnt);
+   buf->numEntries ++;
+   /* No Need to add TxEnt in DataCfm Quee as no Cfm from RLC */
+   if (pjRbCb->mode == PJ_DRB_AM) 
+   {
+      txEnt->datCfmEnt.node = (PTR)txEnt;
+      cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.datCfmQ, &txEnt->datCfmEnt);
+   }
+   txEnt->state  = PJ_PDU_SUBMITTED;
+   }
+   else 
+   {
+   pjDbmInsTxEnt(tPjCb, &(pjRbCb->dlCb.txBuf), txEnt); 
+   }
+#endif 
+
+#ifndef RGL_SPECIFIC_CHANGES
+#ifdef MSPD
+   {
+      extern U32 dlrate_pju;
+      dlrate_pju += mBuf->len;
+   }
+#endif
+#endif
+   pjDlmHdlCmp(tPjCb, pjRbCb, txEnt);
+   /*pjDlmProcessSdusFB(tPjCb, pjRbCb, mBuf, sduId, sn, txHfn);*/
+
+   /* kw005.201 ccpu00117318, updated statistics */
+   RETVALUE(ROK);
+} /* PjUiPjuDatReqFB */
+#endif
+
+/**
+ * 
+ * @details
+ * This primitive is used by PDCP user to forward the SDUs along with its SN
+ * as part of handover (SDUs forwarded from PDCP on source eNB via X2-U 
+ * Interface to the PDCP on target eNB)
+ *
+ * @param[in] pst    - Pointer to Pst structure.
+ * @param[in] spId   - Service provider ID. This is the reference number
+ * used by PDCP service user (Relay) to identify its SAP. This reference number
+ * will be provided by PDCP in any further primitives sent by PDCP
+ * to the service user.
+ * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP id is used to 
+ * uniquely identify a PDCP entity. 
+ * @param[in] datFwdReq - Pointer to data forward information structure.
+ *
+ *  @return ROK.
+ */
+#ifdef ANSI
+PUBLIC S16 PjUiPjuDatFwdReq 
+(
+Pst              *pst, 
+SpId             spId, 
+CmLtePdcpId      *pdcpId, 
+PjuDatFwdReqInfo *datFwdReq
+)
+#else
+PUBLIC S16 PjUiPjuDatFwdReq(pst,spId,pdcpId,datFwdReq)
+Pst              *pst;
+SpId             spId;
+CmLtePdcpId      *pdcpId;
+PjuDatFwdReqInfo *datFwdReq;
+#endif
+{
+
+   S16         ret;           /* Return Value */
+   PjPjuSapCb  *pjuSap;       /* SAP Config Block */
+   PjCb   *tPjCb;
+
+   TRC3(PjUiPjuDatFwdReq)
+   /* ccpu00137221 : KW Fix */
+   if ( NULLP == datFwdReq )
+   {
+      /* Log an error */
+#if (ERRCLASS & ERRCLS_INT_PAR)
+      if (pst->dstInst < PJ_MAX_PDCP_INSTANCES)
+      {
+         tPjCb = PJ_GET_PJCB(pst->dstInst);
+         if (tPjCb != NULLP)
+         {
+            RLOG0(L_ERROR, "Hndl DatFwdReq failed ,tPjCb is NULLP");
+         }
+      }
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+      RETVALUE(RFAILED);
+   }
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, 
+                 (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
+      PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
+      RETVALUE(RFAILED);
+   }
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   ret = ROK;
+   pjuSap = NULLP;
+   RLOG1(L_DEBUG, "PjUiPjuDatFwdReq(pst, spId(%d))", spId);
+
+   if (( datFwdReq->dir == PJ_DIR_DL )  &&
+       (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_DL))
+     
+   {
+      PjDlUeCb      *dlUeCb;         /* UE Control Block */
+      PjDlRbCb      *dlRbCb;       /* RB Control Block */
+      pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId);
+      /* Validate SAP ID under ERRORCLS */
+      PJ_VALDATE_SAP(tPjCb, spId, pjuSap, ret);
+      if (ret != ROK)
+      {
+         /* Freeing from proper region */
+         PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, 
+                    (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
+         PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
+         RETVALUE(RFAILED);
+      }
+
+      if (pjDbmFetchDlUeCb(tPjCb, pdcpId->ueId, pdcpId->cellId, &dlUeCb) != ROK)
+      {
+         RLOG_ARG1(L_ERROR, DBG_CELLID, pdcpId->cellId,"DL UeId[%u] not found",
+            pdcpId->ueId);
+         /* Freeing from proper region */
+         PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, 
+                    (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
+         PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
+         RETVALUE(RFAILED);
+      }
+      /* Fetch the RbCb */
+      PJ_DBM_FETCH_DL_RBCB(pdcpId->rbId, pdcpId->rbType, dlUeCb,dlRbCb);
+      if (dlRbCb == NULLP) 
+      {
+         RLOG_ARG2(L_ERROR, DBG_UEID,pdcpId->ueId, "CellId[%u]: DL RbId[%d] not found",
+            pdcpId->cellId, pdcpId->rbId);
+         /* Freeing from proper region */
+         PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, 
+                    (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
+         PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
+
+         RETVALUE(RFAILED);
+      }
+     
+      if (dlRbCb->state == PJ_STATE_HO)
+      {
+          pjDlmEnqueueDlPkt(tPjCb,dlRbCb, PJ_DATA_FWD_PKT, datFwdReq, 0, NULLP);
+      }
+      else
+      {
+        ret = pjDlmHndlDatFwdReq(tPjCb, dlRbCb, datFwdReq); 
+      }
+
+      PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, 
+                 (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
+      PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
+
+   }
+   else  if (( datFwdReq->dir == PJ_DIR_UL )  &&
+             (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL))
+   {
+      PjUlRbCb      *ulRbCb;       /* RB Control Block */
+      PjUlUeCb      *ulUeCb;
+      pjuSap = (PjPjuSapCb*)(tPjCb->u.ulCb->pjuSap + spId);
+      /* Validate SAP ID under ERRORCLS */
+      pjuSap->state = PJ_SAP_BND;
+      PJ_VALDATE_SAP(tPjCb, spId, pjuSap, ret);
+      if (ret != ROK)
+      {
+         /* Freeing from proper region */
+         PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, 
+                    (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
+         PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
+         RETVALUE(RFAILED);
+      }
+
+      if (pjDbmFetchUlUeCb(tPjCb, pdcpId->ueId, pdcpId->cellId, &ulUeCb) != ROK)
+      {
+         RLOG_ARG1(L_ERROR, DBG_CELLID, pdcpId->cellId,"UL UeId[%u] not found",
+            pdcpId->ueId);
+         /* Freeing from proper region */
+         PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, 
+                    (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
+         PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
+         RETVALUE(RFAILED);
+      }
+      /* Fetch the RbCb */
+      PJ_DBM_FETCH_UL_RBCB(pdcpId->rbId, pdcpId->rbType, ulUeCb,ulRbCb);
+      if (ulRbCb == NULLP)
+      {
+         RLOG_ARG2(L_ERROR, DBG_UEID,pdcpId->ueId, "CellId[%u]: UL RbId[%d] not found",
+            pdcpId->cellId, pdcpId->rbId);
+         /* Freeing from proper region */
+         PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, 
+                    (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
+         PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
+
+         RETVALUE(RFAILED);
+      }
+     
+      ret = pjUlmHdlDatFwdReq(tPjCb, ulRbCb, datFwdReq);
+      PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, 
+                   (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
+      PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
+   }
+  
+   /* Freeing from proper region */
+
+   if ( ret != ROK )
+   {
+        /* Log an error */
+#if (ERRCLASS & ERRCLS_INT_PAR)
+      RLOG0(L_ERROR, "pjDlm/pjUlm HndlDatFwdReq failed");
+#endif /* ERRCLASS & ERRCLS_INT_PAR */
+
+   }
+   RETVALUE(ret);
+}
+
+
+/**
+ * @brief Handler for Bind request from RRM towards CL.
+ *
+ * @details
+ *
+ *     Function : YsUiCpjKdfReq
+ *     
+ *     This function handles the bind request from RRM.
+ *     
+ *           
+ *  @param[in]  Pst  *pst
+ *  @param[in]  SuId suId
+ *  @param[in]  SpId spId
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ **/
+#ifdef ANSI
+PUBLIC S16 PjUiCpjKdfReq
+(
+Pst  *pst,
+SpId spId,
+CpjCfgTransId        transId,
+CpjKdfReqInfo  *kdfReqInfo
+)
+#else
+PUBLIC S16 PjUiCpjKdfReq(pst, suId, spId)
+Pst  *pst;
+SuId suId;
+SpId spId;
+#endif
+{
+   S16           ret;
+   CpjKdfCfmInfo *kdfCfmInf;
+   PjCb          *tPjCb;
+   Pst           cfmPst;
+   PjCpjSapCb    *cpjSap;
+
+
+   TRC2(PjUiCpjKdfReq)
+
+   ret = ROK;
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)      /* KW_FIX */
+   {
+      RETVALUE(RFAILED);
+   }
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   /* Memory leak fix ccpu00135359 */
+   cpjSap = &(tPjCb->u.ulCb->cpjSap);
+   if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&kdfCfmInf, 
+      sizeof (CpjKdfCfmInfo)) != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   cfmPst.dstInst = pst->srcInst;
+   cfmPst.dstEnt  = pst->srcEnt;
+   cfmPst.dstProcId = pst->srcProcId;
+   cfmPst.srcInst = pst->dstInst;
+   cfmPst.srcEnt = pst->dstEnt;
+   cfmPst.srcProcId = pst->dstProcId;
+   cfmPst.selector = 0;
+   cfmPst.region = tPjCb->init.region;
+   cfmPst.pool = tPjCb->init.pool;
+   cfmPst.prior = PRIOR0;
+   cfmPst.route = RTESPEC;
+
+   RLOG1(L_DEBUG, "Key derivation request for Key type %d",
+            kdfReqInfo->keyDerType);
+
+   switch(kdfReqInfo->keyDerType)
+   {
+      case CPJ_KDF_TYPE1:
+         kdfCfmInf->keyDerType = CPJ_KDF_TYPE1;
+         ret = pjLibObdPrcKenbCfg(tPjCb, &(kdfReqInfo->u.kEnbInf), 
+               &(kdfCfmInf->u.kEnbInf));
+         break;
+
+      case CPJ_KDF_TYPE2:
+         kdfCfmInf->keyDerType = CPJ_KDF_TYPE2;
+         ret = pjLibObdPrcKenbStarCfg(tPjCb, &(kdfReqInfo->u.kEnbStarInf),
+               &(kdfCfmInf->u.kEnbStarInf));
+         break;
+
+      case CPJ_KDF_TYPE3:
+         break;
+      default:
+         break;
+   }
+   /* Send Cfg confirm */
+   if(ret != ROK)
+   {
+      PjUiCpjKdfCfm(&cfmPst, PJ_KDF_SAP,
+            transId, kdfCfmInf, CPJ_CFG_CFM_NOK);
+   }// Sudhanshu WR Change
+   else
+   {
+      PjUiCpjKdfCfm(&cfmPst, PJ_KDF_SAP,
+            transId, kdfCfmInf, CPJ_CFG_CFM_OK);
+   }
+
+
+   SPutSBuf (pst->region, pst->pool, (Data *)kdfReqInfo,
+         sizeof(CpjKdfReqInfo));
+   kdfReqInfo = NULLP;
+
+   RETVALUE(ret);
+
+}  /* PjUiCpjKdfReq */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_ul.h b/src/5gnrpdcp/pj_ul.h
new file mode 100755 (executable)
index 0000000..f9b6f9e
--- /dev/null
@@ -0,0 +1,106 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:     LTE PDCP file 
+    
+        Type:     C include file
+  
+        Desc:     This file contain the hash definations for PDCP
+        File:     pj_ul.h
+  
+*********************************************************************21*/
+/** @file pj_ul.h
+@brief PDCP Hash definitions
+*/
+
+#ifndef __PJ_ULH__
+#define __PJ_ULH__
+#define PJ_MAX_NUM_OF_BITS 4096
+
+#define PJ_DBM_FETCH_UL_RBCB(_rbId, _rbType, _ueCb, _rbCb)     \
+{                                                           \
+   _rbCb = (_rbType==CM_LTE_SRB)?_ueCb->srbCb[_rbId]:_ueCb->drbCb[_rbId];\
+}
+
+/* HO_FIX: Changed the success value to ROK as RRC expects
+           ROK or RFAILED */
+#define  PJ_FILL_UL_SDU_CFM_INFO(_cb,_cfmInfo,_tempDlStaInfo,_ueCb)                    \
+{                                                                 \
+   U8 _rbCnt;                                                     \
+   U8 _numRb = 0;                                                 \
+   PjUlHoCfmInfo *_hoCfmInfo;                                       \
+   CpjSduStaInfo  *_staInfo;                                      \
+   Bool _rbPres;                                                  \
+   _cfmInfo->ueId    = _ueCb->key.ueId;                           \
+   _cfmInfo->cellId  = _ueCb->key.cellId;                         \
+   _cfmInfo->transId = _ueCb->hoInfo->transId;                    \
+   for(_rbCnt = 0; _rbCnt < PJ_MAX_DRB_PER_UE && _numRb < CPJ_MAX_DRB; _rbCnt++)          \
+   {                                                              \
+       _rbPres     = FALSE;                                       \
+      _hoCfmInfo   =  &_ueCb->hoInfo->hoCfmInfo[_rbCnt];          \
+      _staInfo     =  &_cfmInfo->sduStaInfo[_numRb];              \
+      if(_hoCfmInfo->pres == TRUE)                                \
+      {                                                           \
+      _rbPres = TRUE;                                             \
+      _staInfo->rbId  =  _hoCfmInfo->rbId;                        \
+      _staInfo->dir   |= _hoCfmInfo->dir;                         \
+      _staInfo->ulSduStaInfo.numBits   =  _hoCfmInfo->numBits; \
+      _staInfo->ulSduStaInfo.ulBitMap  =  _hoCfmInfo->ulBitMap;\
+      _staInfo->ulSduStaInfo.count     =  _hoCfmInfo->count;   \
+      _hoCfmInfo->ulBitMap          =  NULLP;                  \
+      }                                                        \
+      if(tempDlStaInfo[_rbCnt].dlSduStaInfo.hoPres == TRUE)  \
+      {                                                                \
+       _rbPres = TRUE;                                                 \
+       _staInfo->rbId  =  _tempDlStaInfo[_rbCnt].rbId;        \
+       _staInfo->dir   |= _tempDlStaInfo[_rbCnt].dir;                         \
+       _staInfo->dlSduStaInfo.count = _tempDlStaInfo[_rbCnt].dlSduStaInfo.count; \
+      }                                                        \
+      if(_rbPres != TRUE)                                      \
+      {                                                        \
+         continue;                                             \
+      }                                                        \
+      else                                                     \
+      {                                                        \
+        _numRb++;                                              \
+      }                                                        \
+  }                                                              \
+   _cfmInfo->numRb = _numRb;                                   \
+   _cfmInfo->status = ROK;                                     \
+   _cfmInfo->reason = CPJ_CFG_REAS_NONE;                          \
+   PJ_FREE(_cb,_ueCb->hoInfo->hoCfmInfo,                          \
+              (PJ_MAX_DRB_PER_UE * sizeof(PjUlHoCfmInfo)));       \
+   PJ_FREE(_cb,_ueCb->hoInfo, sizeof(PjUlHoInfo));                \
+}
+
+#define PJ_DBM_DELETE_UL_RBCB(_cb, _rbCb)                           \
+{                                                           \
+   /* Free memory for rbCb */                               \
+   PJ_FREE(_cb, _rbCb, sizeof(PjUlRbCb));                            \
+   PJ_LMM_RB_STS_DEC(_cb);                                     \
+}
+
+#endif /* __PJH__ */
+\f  
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_ul.x b/src/5gnrpdcp/pj_ul.x
new file mode 100755 (executable)
index 0000000..d1fe840
--- /dev/null
@@ -0,0 +1,781 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE PDCP file 
+    
+        Type:    C include file
+  
+        Desc:    This file contains all the data structures and 
+                 prototypes for LTE PDCP.
+        File:    pj_ul.x
+  
+*********************************************************************21*/
+/** @file pj_ul.x
+@brief PDCP Product Structures, prototypes
+*/
+
+#ifndef __PJ_UL_X__
+#define __PJ_UL_X__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/** @struct PjRbCb 
+RLC RB control block */
+typedef struct pjUlUeCb PjUlUeCb;
+typedef struct pjUlRbCb PjUlRbCb;               /* PDCP RB control block */
+
+/** @addtogroup dldata */
+/*@{*/
+
+/**
+ *  @brief
+ *  PDCP SDU Status Information for a DRB mapped to RLC AM.
+ */
+
+typedef struct pjUlHoCfmInfo
+{
+   U8          rbId;                     /*!< RB ID */
+   Bool        pres;                     /*!< Is handover info present for this RB */
+   U8          dir;                      /*!< Direction of the RB */
+   U8          res1;
+   U8          numBits;                  /*!< Number of bits in UL bitmap */
+   U8          res2[3];
+   U8          *ulBitMap;                /*!< Status Report bitmap of PDUs */
+   U32         count;                    /*!< UL Count value with FMS */
+}PjUlHoCfmInfo;
+
+/**
+ *  @brief
+ *  Handover information maintainned during processing of SduStaReq
+ */
+typedef struct pjUlHoInfo
+{
+   U32             transId;                   /*!< Transaction ID */
+   UdxSduStaCfmInfo *staCfm;                  /*!< SduStaCfm received from DL */
+   PjUlHoCfmInfo   *hoCfmInfo;                /*!< SDU Status Confirm */
+}PjUlHoInfo;
+
+/** @defgroup uldata UL Module Info 
+*/
+/** @addtogroup uldata */
+/*@{*/
+
+/** @struct PjRxEnt
+PDCP Rx Entry - PDU received from RLC */
+typedef struct pjRxEnt
+{
+   CmLList     lstEnt;                      /*!< List entry for PDU */
+   CmLList     datPktEnt;                   /*!< List entry for PDU */
+   U8          state;                       /*!< PDU state */
+   Bool        discFlag;                    /*!< Whether entry can be discarded 
+                                                 after processing */
+   Bool        dupEntry;                    /*!< Duplicate Entry, These entries
+                                                 are not inserted */
+   Bool        res;                         /*!< Reserved */
+   U32         count;                       /*!< COUNT associated with this PDU */
+   Buffer      *mBuf;                       /*!< Buffer to store the pdu during processing */
+#ifdef SS_RBUF 
+   PjUlRbCb    *rbCb;
+#endif
+   Bool        isOutSeq;                    /*!< flag to tell whether this is a in-sequence packet or not */
+}PjRxEnt;
+
+/** @struct PjUlCb 
+PDCP uplink control block */
+typedef struct pjUlCb
+{
+
+   U32         rxNext;                       /*next expected pdcp pdu counter */
+   U32         rxDeliv;                      /*next delivered pdu count to the upper layer*/
+   U32         rxReord;                      /* Holds the count value of Data PDU which triggered t-Reordering */
+   Bool        outOfOrderDelivery;           /*Out of Delivery is configured or not*/
+   Bool        staRepReqd;                  /*!< Flag to indicate if status report 
+                                                 is required */
+   Bool        discReqd;                    /*!< Flag to indicate if the PDU can
+                                                 be discarded during Integrity
+                                                 failure */
+   Bool        transCmp;                    /*!< Whether transmission of PDUs from RLC
+                                                 during reestablishment is complete */ 
+   U8          state;                       /*!< RB state for the UL entity */
+   PjBuf       recBuf;                      /*!< Reception buffer */
+   U32         nxtSubCnt;                   /*!< Count of next SDU to be submitted 
+                                                 to the upper layer. Used in SRB, DRBUM */
+   U32         nxtSubDeCmp;                 /*!< Count of next PDU to be submitted 
+                                                 to the decompression unit */
+   
+   U32         obdPdu;                      /*!< Count of the Pdu sent for offboarding  */
+   U32         firstReEstCnt;               /*!< Count of the first PDU received after
+                                                 reestablishment was triggered */ 
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+   CmTimer     obdTmr;                      /*!< Offboard timer */
+   U32         obdCnt;                    /*!< OBD Count */
+#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
+   CmLListCp   ulPktLst;                   /*!< Queues the message during
+                                             Re-establishment/Handover */ 
+   U32         fmsCount;                    /*!< To store the Count value (FMS + HFN) at the time Out-Of-Sequence */
+   /* Added for UL UU  LOSS */
+#ifdef LTE_L2_MEAS
+   PjSn        nxtSubSn;                     /*!< PDCP SN to be submitted to UL next */
+#endif
+   CmTimer     tReordTmr;                      /*!< t-Reorder timer */
+}PjUlCb;
+/*@}*/
+
+
+/** @struct PjRbCb 
+PDCP RB control block */
+struct pjUlRbCb
+{
+   CmLteRbId   rbId;                        /*!< RB Id for PDCP Cb */
+   U8          rbType;                      /*!< RB Type : 0 - PJ_SRB, 1 - PJ_DRB */
+   CmLteRlcMode mode;                       /*!< Mapped RLC entity's mode */
+   U8          dir;                         /*!< Direction for UL/DL/biderctional */
+   U8          snLen;                       /*!< Sequence number length */
+   U8          state;                       /*!< RB state - Used only for DRBs*/
+   PjSn        firstSn;                     /*!< SN of the first message sent
+                                                 for Integrity Protection */
+   PjRohc      rohc;                        /*!< ROHC Information */ 
+   PjCmpCxt    cmpCxt;                      /*!< Context for ROHC */
+   PTR         cmpCxtId;                    /*!< Context Id for ROHC */ 
+/* pj005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+   U8          qci;                         /*!< QCI value associated with rb */
+   PjL2MeasRbCb rbL2Cb;                     /*!< L2 Meas Cb for RB */
+#endif /* LTE_L2_MEAS */
+/** @defgroup dldata DL Module Info 
+*/
+   PjUlCb      ulCb;                        /*!< Uplink PDCP RbCb */ 
+   PjUlUeCb      *ueCb;                       /*!< Pointer to the UE in which RB is present */
+   PjSec         secInfo;                   /*!< Security Info */
+   U16           reOrdrTmrVal;              /* t-Reordering timer value in ms*/
+};
+
+
+/** @struct PjUeCb
+UE control block */
+struct pjUlUeCb
+{
+   CmHashListEnt ueHlEnt;                   /*!< Hash list entry for UeCb */
+   Inst          inst; 
+   PjUeKey       key;                       /*!< Hash list key for UeCb */
+   U8            numSrbs;
+   U8            numDrbs;
+   PjUlRbCb        *srbCb[PJ_MAX_SRB_PER_UE]; /*!< SRB RbCbs within a UE */ 
+   PjUlRbCb        *drbCb[PJ_MAX_DRB_PER_UE]; /*!< DRB RbCbs within a UE */ 
+   PjSec         secInfo;                   /*!< Security Info */
+   PjUlHoInfo     *hoInfo;                   /*!< SDU Status Confirm */
+   PjLibInfo     libInfo;                   /*!< Hook Info - to wait for
+                                                 Init Cfm */
+/* pj005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+   U16           numActRb[LPJ_MAX_QCI]; /* number of RBs Active */
+#endif /* LTE_L2_MEAS */
+   Bool          isUlDatFwdReqd;       /*!< To identify whether App rqstd for UL Data Fwding or not */
+};
+
+typedef struct pjUlPkt
+{
+   CmLList lnk;
+   PjSn    sn;
+   Buffer  *pdu;
+   U8      type;
+} PjUlPkt;
+
+/* CFG Module */
+EXTERN S16 pjCfgAddUlRb ARGS ((PjCb *gCb,CmLteRnti  ueId,CmLteCellId  cellId,U8 isHo,
+             CpjCfgEnt  *entCfg,PjUlUeCb **ueCb, CpjCfmEnt  *entCfm ));
+
+EXTERN S16 pjCfgReCfgUlRb ARGS ((PjCb *gCb,PjUlUeCb *ueCb,
+                          CpjCfgEnt *entCfg, CpjCfmEnt *entCfm));
+
+EXTERN S16 pjCfgDelUlRb ARGS ((PjCb *gCb,PjUlUeCb *ueCb,
+                        CpjCfgEnt *entCfg,CpjCfmEnt *entCfm));
+
+EXTERN S16 pjCfgReEstUlRb ARGS ((
+PjCb             *gCb,
+PjUlUeCb         *ueCb,
+CpjCfgEnt         *entCfg,
+CpjCfmEnt         *entCfm,
+UdxCfmEnt         *entDlCfgCfm 
+));
+
+EXTERN S16 pjCfgDelUlUe ARGS ((
+PjCb             *gCb,
+PjUlUeCb         *ueCb,
+CpjCfgEnt         *entCfg,
+CpjCfmEnt         *entCfm
+));
+
+EXTERN S16 pjCfgPrcSecUlCfg ARGS ((
+PjCb             *gCb,
+CpjSecCfgReqInfo *secCfg,
+CpjSecCfgCfmInfo *cfgCfm
+));
+
+EXTERN S16 pjCfgUlUeIdChng ARGS((
+PjCb      *gCb,
+CpjUeInfo *ueInfo,
+CpjUeInfo *newUeInfo,
+CmStatus  *status
+));
+
+EXTERN S16 pjCfgPrcUlCount ARGS ((
+PjCb                  *gCb,
+CpjCountReqInfo       *countReq,
+CpjCountCfmInfo       *countCfm,
+UdxCountCfmInfo       *cntCfm
+));
+
+EXTERN S16  pjCfgDelPjUlRbCb ARGS ((
+PjCb                  *gCb,
+PjUlUeCb               *ueCb,
+PjUlRbCb                 *rbCb
+));
+
+EXTERN S16 pjUtlUlCipherClose ARGS((
+PjCb     *gCb,
+Void     *cpCxtId                  /* Context Id for Ciphering to be closed */
+));
+
+EXTERN S16 pjUtlUlIntClose ARGS((
+PjCb     *gCb,
+Void     *intCxtId                 /* Integration CxtId to be closed */
+));
+
+EXTERN  S16 pjCfgUlReEstReq ARGS ((
+PjCb                  *gCb,
+CpjReEstReqInfo *reEstReq,
+CpjReEstCfmInfo   *reEstCfm
+));
+/* DB Module */
+EXTERN S16 pjDbmInsRxEnt  ARGS ((
+PjCb        *gCb,
+PjBuf       *buf,             
+PjRxEnt     *rxEnt,
+Bool        dupFlag
+));
+EXTERN S16 pjDbmBufInit ARGS ((
+PjCb        *gCb,
+PjBuf       *buf,          
+U8          numBins          
+));
+EXTERN PjRxEnt* pjDbmGetRxEnt ARGS ((
+PjCb        *gCb,
+PjBuf       *buf,        
+U32          count      
+));
+EXTERN PjRxEnt* pjDbmGetRxEntSn ARGS ((
+PjCb        *gCb,
+PjBuf       *buf,      
+U16          sn          
+));
+EXTERN S16 pjDbmDelRxEnt  ARGS ((
+PjCb        *gCb,
+PjBuf       *buf,    
+U32         count     
+));
+EXTERN S16 pjDbmRxDelAll ARGS((
+PjCb        *gCb,
+PjBuf *buf       
+));
+EXTERN S16 pjDbmRxDeInit ARGS ((
+PjCb        *gCb,
+PjBuf *buf       
+));
+
+EXTERN S16 pjDbmUlDeInit ARGS ((
+PjCb        *gCb
+));
+
+EXTERN S16 pjDbmFetchUlUeCb ARGS ((
+PjCb        *gCb,
+CmLteRnti         ueId,       /* UE Identifier */
+CmLteCellId       cellId,     /* Cell Identifier */
+PjUlUeCb            **ueCb       /* UE Control Block */
+));
+
+EXTERN S16 pjDbmCreateUlUeCb ARGS ((
+PjCb        *gCb,
+CmLteRnti         ueId,       /* UE Identifier */
+CmLteCellId       cellId,     /* Cell Identifier */
+PjUlUeCb            **ueCb       /* UE Control Block */
+));
+EXTERN  PjUlRbCb* pjDbmCreateUlRbCb ARGS ((
+PjCb        *gCb,
+U8      rbId,
+U8      rbType,
+PjUlUeCb  *ueCb,
+U8      rb
+));
+
+EXTERN S16 pjDbmFetchUlRbCb ARGS ((
+PjCb           *gCb,
+CmLteRlcId     rlcId,      /* RLC Identifier */
+PjUlRbCb       **rbCb       /* RB Cb */
+));
+
+EXTERN  S16 pjDbmDelUlRbCb ARGS ((
+PjCb        *gCb,
+U8      rbId,
+U8      rbType,
+PjUlRbCb   **rbCb,
+U8      rb,
+PjUlUeCb      *ueCb
+));
+
+EXTERN S16 pjDbmDelUlUeCb  ARGS((
+PjCb        *gCb,
+PjUlUeCb      *ueCb,       /* UE Identifier */
+Bool        abortFlag    /* Abort Flag */
+));
+
+EXTERN S16 PjDbmDelAllUlUe ARGS((PjCb *gCb));
+EXTERN S16 pjDbmDelAllUlRb ARGS((
+PjCb        *gCb,
+PjUlRbCb         **rbCbLst,              /* RB Cb list */
+U8             numRbCb                 /* Number of rbCbs */
+));
+EXTERN S16 pjDbmDelAllUlUe ARGS ((  
+PjCb  *gCb
+));
+
+EXTERN S16 pjDbmUlInit  ARGS (( PjCb *gCb));
+EXTERN S16 pjDbmUlShutdown ARGS((PjCb *gCb));
+EXTERN S16 pjDbmAddUlTransIdLst ARGS((PjCb *gCb,PjCfgInfo  *cfg));
+EXTERN S16 pjDbmFindUlTransIdLst ARGS((PjCb *gCb,U32 transId,
+                                      PjCfgInfo   **cfg));
+EXTERN S16 pjDbmDelUlTransIdLst ARGS((PjCb *gCb,PjCfgInfo  **cfg));
+EXTERN S16 pjDbmDelAllUlTransIdLst ARGS((PjCb  *gCb));
+
+EXTERN S16 pjUtlUlUpdUpSecKeys ARGS(( PjCb *gCb, PjUlUeCb *ueCb));
+EXTERN S16 pjUtlUlUpdCpSecKeys ARGS(( PjCb *gCb, PjUlUeCb *ueCb));
+EXTERN S16 pjUtlUlHdlRbReEstComplete ARGS((PjCb *gCb, PjUlRbCb *pjRbCb));
+
+
+EXTERN S16 pjUtlUlCmpReset ARGS(( 
+PjCb        *gCb,
+PjUlRbCb      *pjRbCb                 /* Context to be reset for compression */
+));
+
+/* UTL Module */
+EXTERN S16 pjUtlUlCmpInit ARGS((
+PjCb        *gCb,
+PjUlRbCb   *pjRbCb                  /* PDCP RbCb */
+));
+EXTERN S16 pjUtlUlIntInit ARGS((
+PjCb        *gCb,
+PjUlUeCb   *ueCb                   /* UE CB Ptr */
+));
+EXTERN S16 pjUtlUlCpInit ARGS((
+PjCb        *gCb,
+PjUlUeCb   *ueCb                    /* UE CB Ptr */
+));
+EXTERN S16 pjUtlUlUpInit ARGS((
+PjCb        *gCb,
+PjUlUeCb   *ueCb                    /* UE CB Ptr */
+));
+
+EXTERN S16 pjUtlUlCmpReq ARGS((
+PjCb        *gCb,
+PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
+Buffer   *mBuf,                   /* SDU to be compressed */
+Buffer   **opSdu,                 /* Compressed SDU */
+U32      count                    /* COUNT - transaction Id */
+));
+EXTERN S16 pjUtlUlIntProtReq ARGS((
+PjCb        *gCb,
+PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
+PjSecInp secInp ,                 /* Input parameters for integrity */ 
+Buffer   *mBuf,                   /* SDU to be compressed */
+U32      *macI                    /* Message authentication code for the SDU */
+));
+EXTERN S16 pjUtlDeCmpReq ARGS((
+PjCb        *gCb,
+PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
+U32      count,                   /* COUNT - transaction Id */
+Buffer   *mBuf,                   /* SDU to be compressed */
+Buffer   **opSdu                  /* Compressed SDU */
+));
+EXTERN S16 pjUtlIntVerReq ARGS((
+PjCb        *gCb,
+PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
+PjSecInp secInp ,                 /* Input parameters for integrity */ 
+Buffer   *mBuf,                   /* SDU to be compressed */
+U32      macI,                    /* MAC-I to be verified with */
+Status   *status                  /* Integrity verification status */
+));
+EXTERN S16 pjUtlDecipherReq ARGS((
+PjCb        *gCb,
+PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
+U32        count,                  /* count of packet */ 
+Buffer     *mBuf,                   /* Data to be deciphered */
+Buffer   **opSdu                  /* Deciphered SDU */
+));
+EXTERN S16 pjUtlSndFeedback ARGS((
+PjCb        *gCb,
+PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
+Buffer   *feedback                /* ROHC Feedback */
+));
+EXTERN S16 pjUtlUlReEstSrb1 ARGS((
+PjCb        *gCb,
+PjUlRbCb      *pjRbCb                    /* PDCP Control Block Pointer */
+));
+EXTERN S16 pjUtlUlReEstStart ARGS((
+PjCb        *gCb,
+PjUlUeCb         *ueCb,          /* UE Control Block Pointer */
+CpjCfgReqInfo  *cfgReq         /* CfgReq for Reestablishment */
+));
+EXTERN S16 pjUtlUlReEstHOStart ARGS((
+PjCb        *gCb,
+PjUlUeCb      *ueCb,           /* Number of RBs undergoing reestablishment*/ 
+U32         transId,        /* Transaction id of Sdu Status cfm */
+U32         *waitForHoTrig 
+));
+EXTERN S16 pjUtlUlReEstReconfig ARGS((
+PjCb        *gCb,
+PjUlUeCb       *ueCb           /* UE Control Block */ 
+));
+EXTERN S16 pjUtlUlReEstUl ARGS((
+PjCb        *gCb,
+PjUlUeCb       *ueCb           /* UE Control Block */ 
+));
+EXTERN S16 pjUtlUlSndReEstCfgCfm ARGS((
+PjCb        *gCb,
+PjUlUeCb       *ueCb           /* UE Control Block */ 
+));
+EXTERN S16 pjUtlUlSndSduStaCfm ARGS((
+PjCb        *gCb,
+PjUlUeCb       *ueCb         /* UE Control Block */ 
+));
+EXTERN S16 pjUtlUlShutdown ARGS((
+PjCb        *gCb
+));
+EXTERN Void pjUtlUlFreeRb ARGS((
+PjCb        *gCb,
+PjUlRbCb *pjRbCb
+));
+/* kw005.201 added function to send data forward indication mesage */
+EXTERN S16 pjUtlUlSndDatFwdInd ARGS((
+PjCb        *gCb,
+PjUlRbCb           *pjRbCb,
+PjuDatFwdIndInfo *datFwdInd
+));
+EXTERN S16 pjUtlUlSndUlStaRep ARGS ((  
+PjCb             *gCb,
+PjUlRbCb         *pjRbCb,
+Buffer           *sta
+));
+
+EXTERN S16 pjUtlUlHdlObdInitCfm ARGS((
+PjCb        *gCb,
+PjUlUeCb    *ueCb,           /* Pointer to UeCb */ 
+U16         txIdx,           /* Transaction Index for UeCb */
+U8          cfmType,         /* Confirm type */
+U8          maskVal          /* mask value */
+));
+EXTERN S16 pjUtlUlHdlInitObdTmrExp ARGS((
+PjCb      *gCb,
+PjUlUeCb *ueCb
+));
+
+EXTERN S16 pjCfgPrcUlSduSta ARGS((
+PjCb        *gCb,
+CpjSduStaReqInfo *staReq,
+UdxSduStaCfmInfo *staCfm
+));
+
+EXTERN S16 pjUtlUlSaveCfmInfo  ARGS((
+PjCb        *gCb,
+PjUlUeCb      *ueCb,           /* Pointer to UeCb */ 
+U8          cfmType,         /* Confirm type */
+Bool        startTmr,        /* Whether to start timer */
+U8          entity,          /* Confirm type */
+PTR         cfmPtr,          /* Pointer to the structure for confirm */
+PTR         cfgPtr           /* Pointer to the structure for request */
+));
+
+/* UL Module */
+EXTERN S16 pjUlmHdlSrbPkt ARGS((
+PjCb        *gCb,
+PjUlRbCb *pjRbCb,               /* !< PDCP Control Block */  
+Buffer *pdu                   /* !< PDU Buffer */ 
+));
+EXTERN S16 pjUlmHndlDlStaRep ARGS ((    
+PjCb     *gCb,
+PjUlRbCb   *pjRbCb,
+PjSn     fmc,
+Buffer   *staPdu
+));
+
+#ifndef XEON_SPECIFIC_CHANGES
+EXTERN U32 pjMsCheckSpaccQueue ARGS((
+Bool isUl
+));
+#else
+EXTERN U32 pjMsCheckSpaccQueue ARGS((
+         Void
+         ));
+#endif
+
+EXTERN S16 pjUlmHdlDrbPkt ARGS((
+PjCb        *gCb,
+PjUlRbCb *pjRbCb,               /* !< PDCP Control Block */      
+Buffer *pdu,                   /* !< PDU Buffer */ 
+Bool    isOutOfSeq               /* !< To indicate whether this packet is in-sequence or not */
+));
+EXTERN S16 pjUlmProcessSrb ARGS((
+PjCb        *gCb,
+PjUlRbCb   *pjRbCb,           /* !< PDCP Control Block */   
+PjSn     sn,               /* !< SN value of PDU */           
+Buffer   *pdu              /* !< PDU message buffer */           
+));
+EXTERN S16 pjUlmProcessDrbUm ARGS((
+PjCb        *gCb,
+PjUlRbCb   *pjRbCb,          /* !< PDCP Control Block */   
+PjSn     sn,               /* !< SN value of PDU */           
+Buffer   *pdu              /* !< PDU message buffer */           
+));
+EXTERN S16 pjUlmProcessDrbAm ARGS((
+PjCb        *gCb,
+PjUlRbCb   *pjRbCb,           /* !< PDCP Control Block */   
+PjSn     sn,               /* !< SN value of PDU */           
+Buffer   *pdu,              /* !< PDU message buffer */           
+Bool     isOutOfSeq           /* !< To indicate whether packet received is in-sequence or not */
+));
+EXTERN S16 pjUlmHdlDecipher ARGS((
+PjCb        *gCb,
+PjUlRbCb     *pjRbCb,        /* !< PDCP Control Block */  
+PjRxEnt    *rxEnt          /* !< Rx Entry */
+));
+EXTERN S16 pjUlmHdlIntVer ARGS((
+PjCb        *gCb,
+PjUlRbCb     *pjRbCb,        /* !< PDCP Control Block */  
+PjRxEnt    *rxEnt          /* !< Rx Entry */
+));
+EXTERN S16 pjUlmHdlDeCmp ARGS((
+PjCb        *gCb,
+PjUlRbCb     *pjRbCb,        /* !< PDCP Control Block */  
+PjRxEnt    *rxEnt          /* !< Rx Entry */
+));
+EXTERN S16 pjUlmDeliverSrb ARGS((
+PjCb        *gCb,
+PjUlRbCb *pjRbCb,          /* !< PDCP Control Block */     
+PjRxEnt *rxEnt           /* !< Recption Buffer Entry   */            
+));
+EXTERN S16 pjUlmDeliverDrbUm ARGS((
+PjCb        *gCb,
+PjUlRbCb *pjRbCb,        /* !< PDCP Control Block */                  
+PjRxEnt *rxEnt         /* !< Recption Buffer Entry   */             
+));
+EXTERN S16 pjUlmDeliverDrbAm ARGS((
+PjCb        *gCb,
+PjUlRbCb *pjRbCb,           /* !< PDCP Control Block */                  
+PjRxEnt *rxEnt            /* !< Recption Buffer Entry   */             
+));
+EXTERN S16 pjUlmReEstSrb ARGS((
+PjCb        *gCb,
+PjUlRbCb *pjRbCb       /*!< PDCP control block  */
+));
+EXTERN S16 pjUlmReEstDrbAm ARGS((
+PjCb        *gCb,
+PjUlRbCb *pjRbCb       /*!< PDCP control block  */
+));
+EXTERN S16 pjUlmBldStaRep ARGS((
+PjCb        *gCb,
+PjUlRbCb    *pjRbCb,             /* !< PDCP Control Block */  
+PjSn         fmc,                /* !< First Missing count */  
+U8          *staRep,             /* !< Status Report */       
+U16         bMapLen              /* !< Bitmap Length */
+));
+EXTERN S16 pjUlmHdlDatFwdReq ARGS((
+PjCb        *gCb,
+PjUlRbCb         *pjRbCb,        /* !< PDCP ID */        
+PjuDatFwdReqInfo   *datFwdReq    /* !< DatFwdReq Info */
+));                                             
+EXTERN S16 pjUlmSubmitForDecmp ARGS((
+PjCb       *gCb,
+PjUlRbCb   *pjRbCb,        /* !< PDCP Control Block */  
+PjRxEnt    *rxEnt          /* Ptr To Rx Entry */
+));
+
+EXTERN Void pjUlmHdlObdTmrExpiry ARGS(( 
+PjCb       *gCb,
+PjUlRbCb     *pjRbCb         /* !< PDCP Control Block */
+));
+
+EXTERN Void pjUlmHdlErrUpdates ARGS((
+PjCb       *gCb,
+PjUlRbCb     *pjRbCb,        /* !< PDCP Control Block */  
+U32         errCnt         /* !< Count of PDU that raises the error */
+));
+
+EXTERN Void pjLimDatInd ARGS((
+PjCb        *gCb,
+PjUlRbCb      *pjRbCb,
+Buffer      *mBuf,
+Bool        isOutOfSeq
+));
+
+EXTERN Void pjLimReEstCmpInd ARGS((
+PjUlRbCb      *pjRbCb         
+));
+
+#ifdef LTE_L2_MEAS
+S16 pjUtlL2MeasUlInit(PjCb *gCb);
+
+EXTERN Void pjUtlResetUlL2MeasCntr ARGS((
+PjCb         *gCb,
+PjL2MeasCb   *measCb,
+U8           measType
+));
+
+EXTERN S16 pjUtlSndUlL2MeasNCfm ARGS ((PjCb *gCb, 
+                                PjL2MeasCfmEvt *measCfmEvt));
+
+EXTERN Void pjUtlPlcMeasDatInUlL2Sts ARGS((PjL2Cntr *, PjL2MeasRbCb *, U8));
+#endif
+
+EXTERN  S16 pjDbmFetchPjUlRbCb ARGS ((
+PjUlUeCb   *ueCb,
+U8         rbId,
+U8         rbType,
+PjUlRbCb   **pjRbCb         
+));
+
+EXTERN S16 pjUtlUlSndUlRohcFdbk ARGS ((
+PjCb        *gCb,
+PjUlRbCb           *pjRbCb,
+Buffer      *fbPkt
+));
+
+EXTERN S16 pjUtlUlResetBuffrdPkts ARGS ((
+PjCb        *gCb,
+PjUlRbCb    *pjRbCb
+));
+
+EXTERN  S16 pjUtlReEstProcUlRb ARGS ((
+PjCb            *tPjCb,
+PjUlUeCb        *ueCb,
+CpjCfgReqInfo   *cfg
+));
+
+EXTERN S16 pjUtlCheckOnlySrbPresent ARGS((
+PjCb        *tPjCb,            /* Pdcp UL control block */
+CmLtePdcpId pdcpId,            /* PDCP Id*/
+U32         *waitForReEstTrig /* wait for reestablishment trigger */
+));
+
+EXTERN Void pjUlmReEstCmpInd ARGS((
+PjCb   *tPjCb,
+PjUlRbCb *tRbCb        /* !< RB control block */  
+));
+
+EXTERN S16 PjUlUdxDlStaRep ARGS((  
+Pst *pst,                       /* Post structure */
+SpId spId,                      /* Service provider ID */
+UdxDlStaRepInfo *staRep           /*PDCP Status Report*/
+));
+
+EXTERN S16 PjUlUdxUlStaRep ARGS ((  
+Pst *pst,                       /* Post structure */
+SpId spId,                      /* Service provider ID */
+UdxUlStaRepInfo *staRep           /*PDCP Status Report*/
+));
+
+EXTERN S16 pjUtlStartUlReEst ARGS ((
+PjCb            *gCb,
+CpjReEstReqInfo *reEstReq,
+CpjReEstCfmInfo *reEstCfm
+));
+
+EXTERN S16 pjUtlUlPrcsDatResume ARGS ((
+PjCb       *gCb,
+CpjDatResumeReqInfo  *datResReq
+));
+
+EXTERN S16 pjUlmStartDataFrwdPerRb ARGS((
+PjCb       *gCb,
+PjUlRbCb    *pjRbCb
+));
+
+EXTERN Void pjUlmProcessUlPktQ ARGS ((
+PjCb       *gCb,
+PjUlRbCb   *pjRbCb           /* !< PDCP Control Block */
+));
+
+EXTERN S16 pjUtlUlGetRbCb ARGS ((
+PjCb          *gCb,
+CmLtePdcpId   *pdcpId,
+PjUlRbCb      **rbCb,
+U8            *retCause
+));
+
+EXTERN Void pjUtlEmptyUlPktList ARGS((
+PjCb *gCb, 
+PjUlRbCb *pjRbCb
+));
+
+EXTERN S16 pjUtlUlReEstHO ARGS((
+PjCb          *gCb,
+PjUlUeCb      *ueCb         
+));
+
+EXTERN S16 pjDbmFetchUlUeCb ARGS((
+PjCb              *gCb,
+CmLteRnti         ueId,    
+CmLteCellId       cellId, 
+PjUlUeCb          **ueCb  
+));
+EXTERN S16 pjUlmHndlDatFwdReq ARGS((
+PjCb               *gCb,
+PjUlRbCb           *pjRbCb,
+PjuDatFwdReqInfo   *datFwdReq
+));
+EXTERN Void dumpPDCPUlRbInformation ARGS ((
+PjUlRbCb* ulRbCb,
+U16 ueId
+));
+
+EXTERN void DumpPDCPUlDebugInformation ARGS ((
+Void
+));
+
+EXTERN Void pjDeInitDeCipherQ(Void);
+
+EXTERN  Void pjUlmHdlReordTmrExpiry ARGS((
+PjCb          *tPjCb,/*pjCb structure */
+PjUlRbCb     *pjRbCb
+));
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __PJX__ */
+
+\f  
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_ul_ex_ms.c b/src/5gnrpdcp/pj_ul_ex_ms.c
new file mode 100755 (executable)
index 0000000..32d00d8
--- /dev/null
@@ -0,0 +1,658 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+
+   Name:    LTE-PDCP Layer - System Services Interface Functions
+
+   Type:    C file
+
+   Desc:    C source code for the interface to System Services of LTE-PDCP
+
+   File:    pj_ul_ex_ms.c
+
+*********************************************************************21*/
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=243;
+/** @file pj_ul_ex_ms.c
+  @brief PDCP System Services Interface
+ */
+
+
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "kwu.h"           /* KWU defines */
+#include "cpj.h"           /* CPJ defines */
+#include "pju.h"           /* PJU defines */
+#include "lpj.h"           /* LPJ defines */
+#include "pj_err.h"        /* Err defines */
+#include "pj_env.h"        /* RLC environment options */
+#include "pj.h"            /* RLC defines */
+#include "pj_udx.h"
+#include "pj_dl.h"        
+#include "pj_lib.h"
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "kwu.x"           /* KWU */
+#include "cpj.x"           /* CPJ defines */
+#include "pju.x"           /* PJU defines */
+#include "lpj.x"           /* LPJ defines */
+#include "pj.x"
+#include "pj_udx.x"
+#include "pj_dl.x"        
+#include "pj_lib.x"
+#ifdef TENB_STATS
+#ifndef L2_L3_SPLIT
+#include "pj_tenb_stats.x"   
+#else
+#include "l2_tenb_stats.x"
+#endif
+#endif
+#if (defined(TENB_STATS) && !(defined(L2_L3_SPLIT)))
+#include "l2_tenb_stats.x"   
+#endif
+
+EXTERN Void pjMsNativeSpaccProcessUlOutput(Void);
+EXTERN Void EgTLSendMsg(Bool);
+/***********************************************************************
+  System Service Interface Functions
+ ***********************************************************************/
+/**
+ *
+ * @brief
+ *
+ *    <b> Activates Initialization </b>
+ *
+ *    @b Description:
+ *    This function is invoked by system services to initialize the LTE-PDCP
+ *    layer. This is an entry point used by LTE_PDCP layer to initialize its
+ *    global variables, before becoming operational.
+ *
+ *    Allowable values for parameters are specified in ssi.h.
+ *
+ *    @param[in] ent    - Specify the entity id of the LTE-RLC task.
+ *    @param[in] inst   - Specify the entity id of the LTE-RLC task.
+ *    @param[in] region - Specifies the memory region from which
+ *                         LTE-PDCP should allocate structures and buffers.
+ *    @param[in] reason - Specifies the reason for calling this
+ *                         initialization function.
+ *
+ *  @return  S16
+ *      -# ROK
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlActvInit
+(
+ Ent    ent,                 /* entity */
+ Inst   inst,                /* instance */
+ Region region,              /* region */
+ Reason reason               /* reason */
+ )
+#else
+PUBLIC S16 pjUlActvInit(ent, inst, region, reason)
+  Ent    ent;                 /* entity */
+  Inst   inst;                /* instance */
+  Region region;              /* region */
+  Reason reason;              /* reason */
+#endif
+{
+   PjCb   *tPjCb;
+   TRC3(pjUlActvInit)
+         
+   if (inst >= PJ_MAX_PDCP_INSTANCES)
+   {
+       /* intance greater than MAX instances */ 
+       RETVALUE(RFAILED); 
+   }
+
+   if (pjCb[inst] != NULLP)
+   {
+      RETVALUE (RFAILED);
+   }
+
+   if (SGetSBuf(region, 0, (Data **)&tPjCb,
+            (Size)sizeof (PjCb)) != ROK)
+   {
+      RETVALUE(RFAILED);
+   }
+   /* Initialize kwCb */
+   PJ_MEM_SET(tPjCb, 0, sizeof(PjCb));
+
+   /* Initialize task configuration parameters */
+   /* We will take only entity name */
+   tPjCb->init.ent     = ent;           /* entity */
+   tPjCb->init.inst    = inst;          /* instance */
+   tPjCb->init.region  = region;        /* static region */
+   tPjCb->init.pool    = 0;             /* static pool */
+   tPjCb->init.reason  = reason;        /* reason */
+   tPjCb->init.cfgDone = FALSE;         /* configuration done */
+   tPjCb->init.acnt    = TRUE;          /* enable accounting */
+   tPjCb->init.usta    = TRUE;          /* enable unsolicited status */
+   tPjCb->init.trc     = FALSE;         /* enable trace */
+#ifdef DEBUGP
+   tPjCb->init.dbgMask = 0x00000;
+#endif
+   tPjCb->init.procId  = SFndProcId();
+
+   pjCb[inst] = tPjCb;
+#if (defined(TENB_STATS) && !(defined(L2_L3_SPLIT)))
+   TSL2AllocStatsMem(tPjCb->init.region, tPjCb->init.pool); 
+#endif
+
+  RETVALUE(ROK);
+} /* pjActvInit */
+
+\f
+/**
+ *
+ * @brief
+ *
+ *  <b> Activation Task </b>
+ *
+ *  @b Description:
+ *  Processes events received for LTE-PDCP layer via System Services from
+ *  other layers.
+ *
+ *  @param[in] pst   - Pst Structure
+ *  @param[in] mBuf  - Message Buffer
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlActvTsk
+(
+Pst *pst,              /* pst structure */
+Buffer *mBuf            /* message buffer */
+)
+#else
+PUBLIC S16 pjUlActvTsk(pst, mBuf)
+Pst *pst;              /* pst structure */
+Buffer *mBuf;           /* message buffer */
+#endif
+{
+   S16 ret = ROK;
+
+   TRC3(pjUlActvTsk);
+
+   switch(pst->srcEnt)
+   {
+      case ENTSM:
+         {
+            switch(pst->event)
+            {
+#ifdef LCLPJ
+               case LPJ_EVT_CFG_REQ:
+                  {
+                     ret = cmUnpkLpjCfgReq(PjMiLpjCfgReq, pst, mBuf);
+                     break;
+                  }
+
+               case LPJ_EVT_CNTRL_REQ:
+                  {
+                     ret = cmUnpkLpjCntrlReq(PjMiLpjCntrlReq, pst, mBuf);
+                     break;
+                  }
+
+               case LPJ_EVT_STS_REQ:
+                  {
+                     ret = cmUnpkLpjStsReq(PjMiLpjStsReq, pst, mBuf);
+                     break;
+                  }
+
+               case LPJ_EVT_STA_REQ:
+                  {
+                     ret = cmUnpkLpjStaReq(PjMiLpjStaReq, pst, mBuf);
+                     break;
+                  }
+                  /* kw005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+               case LPJ_EVT_L2MEAS_REQ:
+                  {
+                     ret = cmUnpkLpjL2MeasReq(PjMiLpjL2MeasReq, pst, mBuf);
+                     break;
+                  }
+               case LPJ_EVT_L2MEAS_SEND_REQ:
+                 {
+
+                    ret = cmUnpkLpjL2MeasSendReq(PjMiLpjL2MeasSendReq, pst, mBuf); 
+  
+                     break;
+                 }
+               case LPJ_EVT_L2MEAS_STOP_REQ:
+                 {
+                     ret = cmUnpkLpjL2MeasStopReq(PjMiLpjL2MeasStopReq, pst, mBuf);
+                     break;
+                 }
+#endif
+
+               default:
+                  {
+                     RLOG1(L_ERROR, "Received Invalid Event[%d] from SM", pst->event);
+                     ret = RFAILED;
+                     break;
+                  }
+#endif  /* LCLPJ */
+            }
+            break;
+         }
+
+      case ENTWR:
+         {
+            switch(pst->event)
+            {
+
+               case EVTCPJKDFREQ:
+               {
+                   cmUnpkCpjKdfReq(PjUiCpjKdfReq, pst, mBuf);
+                  break;
+               }
+
+            default:
+                  SPutMsg(mBuf);
+                   RLOG1(L_ERROR, "Received Invalid Event[%d] from APP", pst->event);
+                  ret = RFAILED;
+                  break;
+            }
+            break;
+         }
+
+      case ENTPJ:
+         {
+            switch(pst->event)
+            {
+#ifdef LCUDX
+            case EVTUDXBNDCFM:
+                  {
+                     cmUnpkPjUdxBndCfm(PjUlUdxBndCfm, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXCFGCFM:
+                  {
+                     cmUnpkPjUdxCfgCfm(PjUlUdxCfgCfm, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXREESTCFM:
+                  {
+                     cmUnpkPjUdxReEstCfm(PjUlUdxReEstCfm, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXSECCFGCFM:
+                  {
+                     cmUnpkPjUdxSecCfgCfm(PjUlUdxSecCfgCfm, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXUEIDCHGCFM:
+                  {
+                     cmUnpkPjUdxUeIdChgCfm(PjUlUdxUeIdChgCfm, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXCOUNTCFM:
+                  {
+                     cmUnpkPjUdxCountCfm(PjUlUdxCountCfm, pst, mBuf);
+                     break;
+                  }
+
+            case EVTUDXSDUSTACFM:
+                  {
+                     cmUnpkPjUdxSduStaCfm(PjUlUdxSduStaCfm, pst, mBuf);
+                     break;
+                  }
+            case EVTUDXDATRESUMECFM:
+                  {
+                     cmUnpkPjUdxDatResumeCfm(PjUlUdxDatResumeCfm, pst, mBuf);
+                     break;
+                  }
+            case EVTUDXDATFRWDCFM:
+                  {
+                     cmUnpkPjUdxDatForwardCfm(PjUlUdxDatForwardCfm, pst, mBuf);
+                     break; 
+                  }                  
+#endif /* LCCPJ */
+              default:
+                  SPutMsg(mBuf);
+                  RLOG1(L_ERROR, "Received Invalid Event[%d] from PDCP DL", pst->event);
+                  ret = RFAILED;
+                  break;
+
+            }
+            break;
+         }
+
+
+      case ENTNH:
+         {
+            switch(pst->event)
+            {
+#ifdef LCCPJ
+            case EVTCPJBNDREQ:
+                  {
+                     cmUnpkCpjBndReq(PjUiCpjBndReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTCPJUBNDREQ:
+                  {
+                     cmUnpkCpjUbndReq(PjUiCpjUbndReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTCPJCFGREQ:
+                  {
+                     cmUnpkCpjCfgReq(PjUiCpjCfgReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTCPJREESTREQ:
+                  {
+                     cmUnpkCpjReEstReq(PjUiCpjReEstReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTCPJSECCFGREQ:
+                  {
+                     cmUnpkCpjSecCfgReq(PjUiCpjSecCfgReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTCPJUEIDCHGREQ:
+                  {
+                     cmUnpkCpjUeIdChgReq(PjUiCpjUeIdChgReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTCPJCOUNTREQ:
+                  {
+                     cmUnpkCpjCountReq(PjUiCpjCountReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTCPJSDUSTAREQ:
+                  {
+                     cmUnpkCpjSduStaReq(PjUiCpjSduStaReq, pst, mBuf);
+                     break;
+                  }
+              case EVTCPJSTARTDATAFWDREQ: /* Start Data Forwarding Request from RRC user for Source eNB during HO */
+                  {
+                      cmUnpkCpjStartDataFwdReq(PjUiCpjDatForwardReq, pst, mBuf);
+                      break;
+                  }
+              case EVTCPJDATRESUMEREQ: /* Data Resume Request from RRC user during Re-establishment */
+                  {
+                      cmUnpkCpjDatResumeReq(PjUiCpjDatResumeReq, pst, mBuf);
+                      break;
+                  }
+#endif /* LCCPJ */
+#ifdef LCPJU 
+            case EVTPJUBNDREQ:
+                  {
+                     cmUnpkPjuBndReq(PjUiPjuBndReq, pst, mBuf);
+                     break;
+                  }
+
+            case EVTPJUUBNDREQ:
+                  {
+                     cmUnpkPjuUbndReq(PjUiPjuUbndReq, pst, mBuf);
+                     break;
+                  }
+
+              case EVTPJUDATFWDREQ:
+                  {
+                     cmUnpkPjuDatFwdReq(PjUiPjuDatFwdReq, pst, mBuf);
+                     break;
+                  }
+#endif
+              default:
+                  SPutMsg(mBuf);
+                  RLOG1(L_ERROR, "Received Invalid Event[%d] from RRC",pst->event);
+                  ret = RFAILED;
+                  break;
+
+            }
+            break;
+         }
+    case ENTPX:
+         {
+            switch(pst->event)
+            {
+#ifdef LCPJU
+               case EVTPJUBNDREQ:
+                  {
+                     cmUnpkPjuBndReq(PjUiPjuBndReq, pst, mBuf);
+                     break;
+                  }
+
+               case EVTPJUUBNDREQ:
+                  {
+                     cmUnpkPjuUbndReq(PjUiPjuUbndReq, pst, mBuf);
+                     break;
+                  }
+
+               case EVTPJUDATREQ:
+                  {
+                     cmUnpkPjuDatReq(PjUiPjuDatReq, pst, mBuf);
+                     break;
+                  }
+
+               case EVTPJUDATFWDREQ:
+                  {
+                     cmUnpkPjuDatFwdReq(PjUiPjuDatFwdReq, pst, mBuf);
+                     break;
+                  }
+#endif
+               default:
+                  SPutMsg(mBuf);
+                  RLOG1(L_ERROR, "Received Invalid Event[%d] from Relay", pst->event);
+                  ret = RFAILED;
+                  break;
+            }
+            break;
+         }
+   
+      case ENTOC:
+         {
+            switch(pst->event)
+            {
+#ifdef PJ_CMP_ASYNC
+               /* Compression Confirmations */
+               case OBD_EVT_CMP_INIT_CFM:
+                  ret = cmUnpkLibObdCmpInitCfm(PjLibObdCmpInitCfm, pst, mBuf);
+                  break;
+
+               case OBD_EVT_DECMP_CFM:
+                  ret = cmUnpkLibObdDecmpCfm(PjLibObdDecmpCfm, pst, mBuf);
+                  break;
+#endif /* PJ_CMP_ASYNC */
+               default:
+                  SPutMsg(mBuf);
+                  RLOG1(L_ERROR, "Received Invalid Event[%d] from Offboard Compression",pst->event);
+                  ret = RFAILED;
+                  break;
+            }
+            break;
+         }
+
+      case ENTOS:
+         {
+            switch(pst->event)
+            {
+#ifdef PJ_SEC_ASYNC
+                  /* Integrity Confirmations */
+               case OBD_EVT_INT_INIT_CFM:
+                  ret = cmUnpkLibObdIntInitCfm(PjLibObdIntInitCfm, pst, mBuf);
+                  break;
+
+               case OBD_EVT_INT_VER_CFM:
+                  ret = cmUnpkLibObdIntVerCfm(PjLibObdIntVerCfm, pst, mBuf);
+                  break;
+
+                  /* Ciphering Confirmations */
+               case OBD_EVT_CP_INIT_CFM:
+                  ret = cmUnpkLibObdCpInitCfm(PjLibObdCpInitCfm, pst, mBuf); /* TODO - Only Dl path? */
+                  break;
+
+               case OBD_EVT_UP_INIT_CFM:
+                  ret = cmUnpkLibObdUpInitCfm(PjLibObdUpInitCfm, pst, mBuf); /* TODO - Only Dl path? */
+                  break;
+
+               case OBD_EVT_DECIPHER_CFM:
+                  ret = cmUnpkLibObdDecipherCfm(PjLibObdDecipherCfm, pst, mBuf);
+                  break;
+#endif /* PJ_SEC_ASYNC */
+               default:
+                  SPutMsg(mBuf);
+                  RLOG1(L_ERROR, "Received Invalid Event[%d] from Offboard Security",pst->event);
+                  ret = RFAILED;
+                  break;
+            }
+            break;
+         }
+      case ENTKW:
+         {
+            switch(pst->event)
+            {
+#ifdef LCKWU
+               case KWU_EVT_BND_CFM:     /* Bind request */
+                  {
+                     ret = cmUnpkKwuBndCfm(PjLiKwuBndCfm, pst, mBuf );
+                     break;
+                  }
+
+               case KWU_EVT_DAT_IND:    /* Coomon Channel Data request */
+                  {
+                     ret = cmUnpkKwuDatInd(PjLiKwuDatInd, pst, mBuf);
+                     break;
+                  }
+
+               case KWU_EVT_REEST_CMP_IND:    /* Dedicated Channel Status Response */
+                  {
+                     ret = cmUnpkKwuReEstCmpInd(PjLiKwuReEstCmpInd, pst, mBuf);
+                     break;
+                  }
+#ifdef LTE_L2_MEAS
+               case KWU_EVT_DAT_ACK_IND:    /* Harq status indication */
+                  {
+                     ret = cmUnpkKwuDatAckInd(PjLiKwuDatAckInd, pst, mBuf);
+                     break;
+                  }
+#endif
+               default:
+                  {
+                     SPutMsg(mBuf);
+                     RLOG1(L_ERROR, "Received Invalid Event[%d] from RLC", pst->event);
+                     ret = RFAILED;
+                     break;
+                   }
+
+#endif  /* LCRGU */
+            }
+            break;
+         }
+#if (defined(TENB_STATS) && !(defined(L2_L3_SPLIT)))
+      case ENTTF:
+         {
+            switch(pst->event)
+            {
+               case TENBSTATSINIT:
+               {
+                  PjCb *tPjCb;
+                  tPjCb = PJ_GET_PJCB(pst->dstInst);
+                  TSL2SendStatsToApp(&(tPjCb->pjGenCfg.lmPst), 0);
+                  SPutMsg(mBuf);
+                  break;
+               }
+               default:
+               {
+                  printf("\n ERROR Invalid Event[%d] from CL to PDCPUL\n", 
+                         pst->event);
+                  SPutMsg(mBuf);
+                  break;
+               }
+            }
+            break;
+         }
+#endif
+#if (defined(TENB_AS_SECURITY) && defined(UL_DL_SPLIT))
+      case ENTYS:
+         {
+            switch(pst->event)
+            {
+               case EVTPJUTTIIND:
+               {
+                  pjMsNativeSpaccProcessUlOutput();
+                  SPutMsg(mBuf);
+
+#ifndef SS_RBUF
+                     EgTLSendMsg(FALSE); /* Arg FALSE is req if ENB_CPU_OVERLOAD_CONTROL is enabled,
+                                            just to control the num of pkts to be sent over the socket*/
+#else
+                     EgTLSendMsg();
+#endif
+                  break;
+               } 
+            }
+            break;
+         }
+#endif
+      default:
+         {
+            RLOG1(L_ERROR, "Received Invalid Src Entity[%d]", pst->event);
+            SPutMsg(mBuf);
+            ret = RFAILED;
+            break;
+         }
+   }
+
+   SExitTsk();
+
+   RETVALUE(ret);
+} /* pjActvTsk */
+
+\f  
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_ul_utl.c b/src/5gnrpdcp/pj_ul_utl.c
new file mode 100755 (executable)
index 0000000..6c60117
--- /dev/null
@@ -0,0 +1,2844 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/**********************************************************************
+
+     Name:     LTE-PDCP Layer 
+  
+     Type:     C file
+  
+     Desc:     Source code for PDCP Utility Module
+
+               This file contains following functions:
+
+                  --PjLibObdCmpCfm
+                  --PjLibObdIntProtCfm
+                  --PjLibObdCipherCfm
+                  --PjLibObdDecipherCfm
+                  --PjLibObdIntVerCfm
+                  --PjLibObdDecmpCfm
+                  -- pjUtlCmpReq
+                  -- pjUtlCipherReq
+                  -- pjUtlIntProtReq
+  
+     File:     pj_ul_utl.c
+
+**********************************************************************/
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_FILE_ID=251;
+static int RLOG_MODULE_ID=1024;
+
+/** @file gp_pj_utl.c
+@brief PDCP Utility Module 
+*/
+
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "cpj.h"                /* CPJ defines */
+#include "pju.h"                /* PJU defines */
+#include "lpj.h"                /* LPJ defines */
+
+#include "pj_env.h"        /* RLC environment options */
+#include "pj.h"            /* RLC defines */
+#include "pj_ul.h"
+#include "pj_dl.h"
+#include "pj_err.h"        /* Error defines */
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "cpj.x"                /* CPJ */
+#include "pju.x"                /* PJU */
+#include "lpj.x"                /* LPJ */
+#include "pj.x"
+#include "pj_udx.h"          /* LIB */
+#include "pj_udx.x"          /* LIB */
+#include "pj_ul.x"
+#include "pj_dl.x"
+#include "pj_lib.x"          /* LIB */
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif /* __cplusplus */
+
+PRIVATE S16 pjUtlUlHdlSecInitCfm ARGS((PjCb *gCb,PjUlUeCb *ueCb, 
+              U16 txIdx,PjAsyncCfm *asyncCfm, CpjSecCfgCfmInfo *secCfgCfm,CpjReEstCfmInfo *reEstCfm));
+PRIVATE S16 pjUtlUlHdlCmpInitCfm ARGS((PjCb *gCb,PjUlUeCb *ueCb, 
+              U16 txIdx,PjAsyncCfm *asyncCfm, CpjCfgCfmInfo *cfgCfm));
+#ifdef INTEL_SW_SEC
+EXTERN S16 PjLibObdSwDecipherReq(PjLibTrans *libTrans, Buffer *mBuf, PjCb *gCb, Buffer **opSdu);
+#endif
+/********************************************************************
+ *    Utility Handler for Sending to Offboarding unit               *
+ *******************************************************************/
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler for opening the context with the compression unit (either 
+ *        synchronous or asynchronous) for RB within an UE.
+ *
+ * @b Description:
+ *
+ *        This function opens the context with the compression unit per RB per
+ *        UE, by sending ROHC configuration elements using synchronous / asynchronous 
+ *        function calls with relevant input parameters.
+ *
+ *
+ *  @param[in]  pjRbCb   PDCP RbCb
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlUlCmpInit
+(
+PjCb       *gCb,
+PjUlRbCb   *pjRbCb                  /* PDCP RbCb */
+)
+#else
+PUBLIC S16 pjUtlUlCmpInit(pjRbCb)
+PjCb       *gCb;
+PjUlRbCb   *pjRbCb;                 /* PDCP RbCb */
+#endif
+{
+   TRC3(pjUtlUlCmpInit)
+
+   RLOG2(L_DEBUG, "pjUtlUlCmpInit(pjRbCb(%d,%d))",
+                    pjRbCb->rbId, pjRbCb->rbType);
+#ifdef PJ_CMP_ASYNC
+
+   pjRbCb->ueCb->libInfo.tCmpInitBitMask |= (1 << (pjRbCb->rbId - 1));
+   pjRbCb->ueCb->libInfo.tLibInitBitMask |= PJ_LIB_COMP_BIT_MASK;
+   pjRbCb->cmpCxt.cfgTxId  =  pjRbCb->ueCb->libInfo.nxtAvlbTxId;
+
+   PjLibObdCmpInitReq(&gCb->pjGenCfg.obdPst.cmpPst, 
+                                    pjRbCb->cmpCxt, pjRbCb->rohc);
+#else
+   pjLibCmpInitReq(pjRbCb->cmpCxt, pjRbCb->rohc, &(pjRbCb->cmpCxtId));
+#endif  /* PJ_CMP_ASYNC */
+
+   RETVALUE(ROK);
+
+} /* end of pjUtlCmpInit */
+\f
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for opening the context with the Integration unit (either 
+ *        synchronous or asynchronous) for all SRBs of an UE.
+ *
+ * @b Description:
+ *
+ *        This function opens the context with the security algo unit per UE
+ *        for Integration protection/verification by sending the configured
+ *        Integrity Info using synchronous / asynchronous function calls with 
+ *        relevant input parameters.
+ *
+ *  @param[in]  pjRbCb     Pointer to RB control Block
+ *
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlUlIntInit
+(
+PjCb     *gCb,
+PjUlUeCb   *ueCb                   /* UE CB Ptr */
+)
+#else
+PUBLIC S16 pjUtlUlIntInit(ueCb)
+PjCb     *gCb;
+PjUlUeCb   *ueCb;                   /* UE CB Ptr */
+#endif
+{
+
+#ifndef PJ_SEC_ASYNC
+   Void *ctxId = NULL;   /* KW_FIX */
+#else
+   U8  txIdx;
+   U32 *libInitBitMask = NULLP;
+#endif
+   S32 ret=ROK;
+
+   TRC3(pjUtlUlIntInit)
+
+   RLOG2(L_DEBUG, "pjUtlUlIntInit(ueCb(%d,%d))",
+                    ueCb->key.ueId, ueCb->key.cellId);
+
+#ifdef PJ_SEC_ASYNC
+
+   if(ueCb->libInfo.state == PJ_STATE_REEST)
+   {
+      for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
+      {
+         if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
+               (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM))
+         {
+            libInitBitMask =  &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask;
+            break;
+         }
+      }
+   }
+   else if(ueCb->libInfo.state == PJ_STATE_NORMAL)
+   {
+      libInitBitMask =  &ueCb->libInfo.tLibInitBitMask;
+   }
+
+   if(libInitBitMask)
+   {
+      (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_INT_BIT_MASK;
+   }
+
+   ret = PjLibObdIntInitReq(&gCb->pjGenCfg.obdPst.secPst, 
+                           ueCb->secInfo.secCxt, ueCb->secInfo.intInfo);
+#else
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTNACES
+   pjLibIntInitReq(gCb->u.ulCb->instHndl, ueCb->secInfo.intInfo,&ctxId);
+#else
+   pjLibIntInitReq(gCb, ueCb->secInfo.intInfo,&ctxId);
+#endif
+   ueCb->secInfo.cpIntSessCxtId        =  ctxId;
+#else
+   pjLibIntInitReq(ueCb->secInfo.secCxt, ueCb->secInfo.intInfo,&(ctxId));
+   ueCb->secInfo.intCxtId    =  ctxId;
+#endif   
+#endif /* PJ_SEC_ASYNC */
+
+   RETVALUE(ret);
+
+} /* end of pjUtlIntInit */
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler for opening the context with the Ciphering unit (either 
+ *        synchronous or asynchronous) for SRBs of an UE.
+ *
+ * @b Description:
+ *
+ *        This function opens the context with the security algo unit per UE
+ *        for ciphering / deciphering by key by sending the configured
+ *        Ciphering Info with control plane key using synchronous / asynchronous 
+ *        function calls with relevant input parameters.
+ *
+ *  @param[in]  pjRbCb     Pointer to RB control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlUlCpInit
+(
+PjCb     *gCb,
+PjUlUeCb   *ueCb                    /* UE CB Ptr */
+)
+#else
+PUBLIC S16 pjUtlUlCpInit(ueCb)
+PjCb     *gCb;
+PjUlUeCb   *ueCb;                   /* UE CB Ptr */
+#endif
+{
+
+#ifndef PJ_SEC_ASYNC
+   Void *ctxId = NULL;       /* KW_FIX */
+#else
+   U8  txIdx;
+   U32 *libInitBitMask = NULLP;
+#endif
+   S16   ret = ROK;
+
+   TRC3(pjUtlUlCpInit)
+
+   RLOG2(L_DEBUG, "pjUtlCpInit(ueCb(%d,%d))",
+                    ueCb->key.ueId, ueCb->key.cellId);
+
+#ifdef PJ_SEC_ASYNC
+
+   if(ueCb->libInfo.state == PJ_STATE_REEST)
+   {
+      for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
+      {
+         if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
+               (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM))
+         {
+            libInitBitMask =  &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask;
+            break;
+         }
+      }
+   }
+   else if(ueCb->libInfo.state == PJ_STATE_NORMAL)
+   {
+      libInitBitMask =  &ueCb->libInfo.tLibInitBitMask;
+   }
+
+   if(libInitBitMask)
+   {
+      (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_CP_CIP_BIT_MASK;
+   }
+   ret = PjLibObdCpInitReq(&gCb->pjGenCfg.obdPst.secPst, ueCb->secInfo.secCxt, 
+         ueCb->secInfo.cipherInfo.algoType, ueCb->secInfo.cipherInfo.cpKey);
+#else
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+   ret = pjLibCpInitReq(gCb->u.ulCb->instHndl, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
+                  ueCb->secInfo.cipherInfo.cpKey, &ctxId);
+#else
+   ret = pjLibCpInitReq(gCb, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
+                  ueCb->secInfo.cipherInfo.cpKey, &ctxId);
+#endif
+   ueCb->secInfo.cpCiphSessCxtId = ctxId;
+#else
+   ret = pjLibCpInitReq(ueCb->secInfo.secCxt, (U8)ueCb->secInfo.cipherInfo.algoType,
+                  ueCb->secInfo.cipherInfo.cpKey, &ctxId);  /*KW_FIX*/
+   ueCb->secInfo.cpCxtId = ctxId;
+#endif /* INTEL_QAT_DP */
+#endif /* PJ_SEC_ASYNC */
+
+   RETVALUE(ret);
+
+} /* end of pjUtlCpInit */
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for opening the context with the Ciphering unit (either 
+ *        synchronous or asynchronous) for DRBs of an UE.
+ *
+ * @b Description:
+ *
+ *        This function opens the context with the security algo unit per UE
+ *        for ciphering / deciphering by sending the configured
+ *        Ciphering Info with user plane key using synchronous / asynchronous 
+ *        function calls with relevant input parameters.
+ *
+ *  @param[in]  pjRbCb     Pointer to RB control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlUlUpInit
+(
+PjCb     *gCb,
+PjUlUeCb   *ueCb                    /* UE CB Ptr */
+)
+#else
+PUBLIC S16 pjUtlUpInit(gCb,ueCb)
+PjCb     *gCb;
+PjUlUeCb   *ueCb;                   /* UE CB Ptr */
+#endif
+{
+
+#ifndef PJ_SEC_ASYNC
+   Void* ctxId = NULL;  /* KW_FIX */
+#else
+   U8  txIdx;
+   U32 *libInitBitMask = NULLP;
+#endif
+
+   TRC3(pjUtlUlUpInit)
+
+   RLOG2(L_DEBUG, "pjUtlUpInit(ueCb(%d,%d))",
+                    ueCb->key.ueId, ueCb->key.cellId);
+
+#ifdef PJ_SEC_ASYNC
+
+   if(ueCb->libInfo.state == PJ_STATE_REEST)
+   {
+      for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
+      {
+         if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
+               (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM))
+         {
+            libInitBitMask =  &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask;
+            break;
+         }
+      }
+   }
+   else if(ueCb->libInfo.state == PJ_STATE_NORMAL)
+   {
+      libInitBitMask =  &ueCb->libInfo.tLibInitBitMask;
+   }
+
+   if(libInitBitMask)
+      (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_UP_CIP_BIT_MASK;
+
+   ret = PjLibObdUpInitReq(&gCb->pjGenCfg.obdPst.secPst, ueCb->secInfo.secCxt, 
+         ueCb->secInfo.cipherInfo.algoType, ueCb->secInfo.cipherInfo.upKey);
+#else
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+   pjLibUpInitReq(gCb->u.ulCb->instHndl, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType, 
+                              ueCb->secInfo.cipherInfo.upKey, &ctxId);
+#else
+   pjLibUpInitReq(gCb, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType, 
+                              ueCb->secInfo.cipherInfo.upKey, &ctxId);
+#endif
+   ueCb->secInfo.upCiphSessCxtId= ctxId; 
+#else
+   pjLibUpInitReq(ueCb->secInfo.secCxt, (U8)ueCb->secInfo.cipherInfo.algoType, 
+                              ueCb->secInfo.cipherInfo.upKey, &ctxId); /*KW_FIX*/
+   ueCb->secInfo.upCxtId = ctxId;
+#endif /* INTEL_QAT_DP */
+#endif /* PJ_SEC_ASYNC */
+
+   RETVALUE(ROK);
+
+} /* end of pjUtlUpInit */
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for resetting the context with the compression unit (either 
+ *        synchronous or asynchronous) for RB within an UE.
+ *
+ * @b Description:
+ *
+ *        This function resets the context with the compression unit per RB per
+ *        UE by using synchronous / asynchronous function calls.
+ *
+ *
+ *  @param[in] cmpCxtId     Context to be reset for compression 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlUlCmpReset
+(
+PjCb        *gCb,
+PjUlRbCb      *pjRbCb                 /* Context to be reset for compression */
+)
+#else
+PUBLIC S16 pjUtlUlCmpReset(pjRbCb)
+PjCb        *gCb;
+PjUlRbCb      *pjRbCb;                 /* Context to be reset for compression */
+#endif
+{
+   TRC3(pjUtlUlCmpReset)
+
+   RLOG2(L_DEBUG, "pjUtlUlCmpReset(pjRbCb(%d,%d))",
+                    pjRbCb->rbId, pjRbCb->rbType);
+
+#ifdef PJ_CMP_ASYNC
+   PjLibObdCmpResetReq(&gCb->pjGenCfg.obdPst.cmpPst, pjRbCb->cmpCxtId);
+#else
+   pjLibCmpResetReq(pjRbCb->cmpCxtId);
+#endif
+
+   RETVALUE(ROK);
+
+} /* end of pjUtlCmpReset */
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for closing the UL context with the Ciphering unit (either 
+ *        synchronous or asynchronous) for SRBs of an UE.
+ *
+ * @b Description:
+ *
+ *        This function closes an existing UL context with the security algo unit per UE
+ *        for ciphering / deciphering with control plane key using synchronous / asynchronous 
+ *        function calls with relevant input parameters.
+ *
+ *
+ *  @param[in] cpCxtId          Context Id for Ciphering to be closed 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI      
+PUBLIC S16 pjUtlUlCipherClose
+(
+PjCb     *gCb,
+Void      *cpCxtId                  /* Context Id for Ciphering to be closed */
+)
+#else
+PUBLIC S16 pjUtlUlCipherClose(cpCxtId)
+PjCb     *gCb;
+Void     *cpCxtId;                 /* Context Id for Ciphering to be closed */
+#endif
+{
+   S16   ret = ROK;
+   TRC3(pjUtlUlCipherClose)
+   RLOG0(L_DEBUG, "pjUtlUlCipherClose");
+#ifndef PJ_SEC_ASYNC
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+   ret = PjLibObdCipherCloseReq(gCb->u.ulCb->instHndl, cpCxtId);
+#else
+   ret = PjLibObdCipherCloseReq(gCb->instHndl, cpCxtId); 
+#endif
+#else
+   PjLibObdCipherCloseReq(cpCxtId);
+#endif
+#else
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+   ret = PjLibObdCipherCloseReq(gCb->u.ulCb->instHndl, cpCxtId);
+#else
+   ret = PjLibObdCipherCloseReq(gCb->instHndl, cpCxtId); 
+#endif
+#else
+   PjLibObdCipherCloseReq(&gCb->pjGenCfg.obdPst.secPst, cpCxtId);
+#endif
+#endif
+   RETVALUE(ret);
+} /* end of pjUtlCipherClose */
+/**
+ *
+ * @brief 
+ *
+ *        Handler for closing the UL context with the Integration unit (either 
+ *        synchronous or asynchronous) for all RBs of an UE.
+ *
+ * @b Description:
+ *
+ *        This function closes an existing UL context with the security algo unit per UE
+ *        for Integration protection/verification using synchronous / asynchronous function 
+ *        calls with relevant input parameters.
+ *
+ *
+ *  @param[in] intCxtId        Integration CxtId to be closed 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI   
+PUBLIC S16 pjUtlUlIntClose
+(
+PjCb     *gCb,
+Void      *intCxtId                 /* Integration CxtId to be closed */
+)
+#else
+PUBLIC S16 pjUtlUlIntClose(intCxtId)
+PjCb     *gCb;
+Void     *intCxtId;                /* Integration CxtId to be closed */
+#endif
+{
+   S16   ret = ROK;
+   TRC3(pjUtlUlIntClose)
+   RLOG0(L_DEBUG, "pjUtlUlIntClose");
+   
+#ifdef TENB_AS_SECURITY
+#ifdef INTEL_QAT_DP
+#ifdef QAT_TWO_INSTANCE
+   ret = PjLibObdIntCloseReq(gCb->u.ulCb->instHndl,intCxtId);
+#else
+   ret = PjLibObdIntCloseReq(gCb->instHndl,intCxtId);
+#endif
+#endif
+#else
+#ifdef PJ_SEC_ASYNC
+   PjLibObdIntCloseReq(&gCb->pjGenCfg.obdPst.secPst,intCxtId);
+#else   
+   PjLibObdIntCloseReq(intCxtId);
+#endif
+#endif
+   RETVALUE(ret);
+} /* end of pjUtlIntClose */
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for redirecing deciphering request to either synchronous
+ *        or asynchronous module.
+ *
+ * @b Description:
+ *
+ *        This function sends deciphering request as either synchronous or
+ *        asynchronous function calls with relevant input parameters.
+ *
+ *  @param[in]   pjRbCb           PDCP RbCb 
+ *  @param[in]   secInp           Input parameters for deciphering 
+ *  @param[in]   mBuf             Data to be deciphered 
+ *  @param[in]   opSdu            Deciphered SDU 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+/* Uday */
+#ifdef TENB_AS_SECURITY
+#ifdef ANSI
+PUBLIC S16 pjUtlDecipherReq
+(
+PjCb       *gCb,
+PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
+U32        count,
+Buffer     *mBuf,                    /* Data to be deciphered */
+Buffer   **opSdu                  /* Deciphered SDU */
+)
+#else
+PUBLIC S16 pjUtlDecipherReq(gCb, pjRbCb, count, mBuf, opSdu)
+PjCb       *gCb;
+PjUlRbCb   *pjRbCb;                 /* PDCP RbCb */
+U32        count;
+Buffer     *mBuf;                   /* Data to be deciphered */
+Buffer   **opSdu;                  /* Deciphered SDU */
+#endif
+{
+   S16 ret = ROK;
+   PjUlUeCb *ulUeCb;
+   PjLibTrans  libTrans;
+#ifdef PJ_SEC_ASYNC
+   Void      *cxtId = NULLP;    /* Context Identifier */
+#endif
+   TRC3(pjUtlDecipherReq)
+
+#ifdef PJ_SEC_ASYNC
+   if (pjRbCb->rbType == PJ_SRB)
+   {
+      cxtId = pjRbCb->ueCb->secInfo.cpCxtId;
+   }
+   else
+   {
+      cxtId = pjRbCb->ueCb->secInfo.upCxtId;
+   } 
+#endif
+   ulUeCb = pjRbCb->ueCb;
+   libTrans.pdcpInstance = gCb->init.inst;
+   libTrans.count = count;
+   libTrans.rbId = pjRbCb->rbId - 1;
+   libTrans.dir = PJ_SEC_DIR_UL;
+   libTrans.rbType = pjRbCb->rbType;
+   libTrans.snLen = pjRbCb->snLen;
+   libTrans.ciphAlgoType = ulUeCb->secInfo.cipherInfo.algoType;
+   libTrans.ueCb = (PTR)ulUeCb;
+   libTrans.ueId = ulUeCb->key.ueId;
+   libTrans.cellId = ulUeCb->key.cellId;
+   if(PJ_SRB == pjRbCb->rbType)
+   {
+      libTrans.key = ulUeCb->secInfo.cipherInfo.cpKey;
+#ifdef INTEL_QAT_DP
+      libTrans.sessCxtId = ulUeCb->secInfo.cpCiphSessCxtId;
+#ifdef QAT_TWO_INSTANCE
+      libTrans.instHndl = gCb->u.ulCb->instHndl;
+#else
+      libTrans.instHndl = gCb->instHndl;
+#endif
+#endif
+   }
+   else
+   {
+      libTrans.key = ulUeCb->secInfo.cipherInfo.upKey;
+#ifdef INTEL_QAT_DP
+      libTrans.sessCxtId = ulUeCb->secInfo.upCiphSessCxtId;
+#ifdef QAT_TWO_INSTANCE
+      libTrans.instHndl = gCb->u.ulCb->instHndl;
+#else
+      libTrans.instHndl = gCb->instHndl;
+#endif
+#endif
+   }
+   
+#ifdef PJ_SEC_ASYNC
+   /* Start the timer if it is not started already */
+   if((pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE)
+   {
+      pjRbCb->ulCb.obdPdu   =  secInp.count;
+      pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
+   }
+   ret = PjLibObdDecipherReq(&(gCb->pjGenCfg.obdPst.secPst), 
+                                 cxtId, secInp, libTrans, mBuf);  
+#else
+#ifdef INTEL_QAT_DP
+    /* TODO: 3rd arg is unused can be removed */
+       ret = PjLibObdDecipherReq(&libTrans, mBuf, opSdu);
+#else
+#ifndef INTEL_SW_SEC
+   ret = PjLibObdDecipherReq(&libTrans, mBuf, opSdu);
+#else
+   ret = PjLibObdSwDecipherReq(&libTrans, mBuf, gCb,opSdu);
+#endif
+#endif
+#endif
+   RETVALUE(ret);
+} /* end of pjUtlDecipherReq */
+#else
+#ifdef ANSI
+PUBLIC S16 pjUtlDecipherReq
+(
+PjCb       *gCb,                  /* Cell Cb */
+PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
+U32        count,
+Buffer   *mBuf,                   /* Data to be deciphered */
+Buffer   **opSdu                  /* Deciphered SDU */
+)
+#else
+PUBLIC S16 pjUtlDecipherReq(gCb, pjRbCb, count, mBuf, opSdu)
+PjCb       *gCb;
+PjUlRbCb   *pjRbCb;                 /* PDCP RbCb */
+U32        count;
+Buffer   *mBuf;                   /* Data to be deciphered */
+Buffer   **opSdu;                 /* Deciphered SDU */
+#endif
+{
+   S16 ret = ROK;
+#ifdef PJ_SEC_ASYNC
+   PjLibTrans libTrans; /* Transaction Id for deciphering */
+#else
+   PjSecInp   secInp;
+#endif /* PJ_SEC_ASYNC */
+   PTR        cxtId;    /* Context Identifier */
+   TRC3(pjUtlDecipherReq)
+   if (pjRbCb->rbType == PJ_SRB)
+   {
+      cxtId = (PTR)pjRbCb->ueCb->secInfo.cpCxtId;
+   }
+   else
+   {
+      cxtId = (PTR)pjRbCb->ueCb->secInfo.upCxtId;
+   } 
+#ifdef PJ_SEC_ASYNC
+   /* Assign transId and cxtId */
+   libTrans.count  = count;
+   /* kw005.201 ccpu00114955 corrected the RB ID calculation */
+   libTrans.rbId   = pjRbCb->rbId - 1;
+   libTrans.rbType = pjRbCb->rbType;
+   libTrans.ueCb   = pjRbCb->ueCb;
+   /* Start the timer if it is not started already */
+   if((pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE)
+   {
+      pjRbCb->ulCb.obdPdu   =  secInp.count;
+      pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
+   }
+   ret = PjLibObdDecipherReq(&gCb->pjGenCfg.obdPst.secPst, 
+                                 cxtId, secInp, libTrans, mBuf);  
+#else
+   secInp.count = count;
+   secInp.rbId  = pjRbCb->rbId - 1;
+   secInp.dir = 0;
+   ret = pjLibDecipherReq(cxtId, secInp, mBuf, opSdu);
+#endif
+   RETVALUE(ret);
+} /* end of pjUtlDecipherReq */
+#endif
+/**
+ *
+ * @brief 
+ *
+ *        Handler for redirecing Integration request to either synchronous
+ *        or asynchronous module.
+ *
+ * @b Description:
+ *
+ *        This function sends Intergrity verification request as either synchronous or
+ *        asynchronous function calls with relevant input parameters.
+ *
+ *  @param[in]   pjRbCb        PDCP RbCb 
+ *  @param[in]   secInp        Input parameters for integrity 
+ *  @param[in]   mBuf          SDU to be compressed 
+ *  @param[out]  status        Integrity verification status 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef TENB_AS_SECURITY
+#ifdef ANSI
+PUBLIC S16 pjUtlIntVerReq
+(
+PjCb     *gCb,
+PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
+PjSecInp secInp ,                 /* Input parameters for integrity */ 
+Buffer   *mBuf,                   /* SDU to be compressed */
+U32      macI,                    /* MAC-I to be verified with */
+Status   *status                  /* Integrity verification status */
+)
+#else
+PUBLIC S16 pjUtlIntVerReq(pjRbCb, secInp, mBuf, macI, status)
+PjCb     *gCb;
+PjUlRbCb   *pjRbCb;                 /* PDCP RbCb */
+PjSecInp secInp;                 /* Input parameters for integrity */ 
+Buffer   *mBuf;                   /* SDU to be compressed */
+U32      macI;                    /* MAC-I to be verified with */
+Status   *status;                 /* Integrity verification status */
+#endif
+{
+   S16 ret = ROK;
+   PjUlUeCb *ulUeCb;
+   PjLibTrans  libTrans;
+#ifdef PJ_SEC_ASYNC
+   Void       *cxtId;    /* Context Identifier */
+#endif
+   TRC3(pjUtlIntVerReq)
+
+#ifdef PJ_SEC_ASYNC
+   cxtId = pjRbCb->ueCb->secInfo.intCxtId;
+#endif
+   ulUeCb = pjRbCb->ueCb;
+   libTrans.pdcpInstance = gCb->init.inst;
+   libTrans.count = secInp.count;
+   libTrans.rbId = pjRbCb->rbId - 1;
+   libTrans.dir = secInp.dir;
+   libTrans.rbType = pjRbCb->rbType;
+   libTrans.intAlgoType = ulUeCb->secInfo.intInfo.algoType;
+   libTrans.ueCb = (PTR)ulUeCb;
+   libTrans.ueId = ulUeCb->key.ueId;
+   libTrans.cellId = ulUeCb->key.cellId;
+   libTrans.key = (U8*)&ulUeCb->secInfo.intInfo.intKey[0];
+   PJ_SEC_FILL_FRESH(libTrans.fresh, libTrans.rbId);
+
+#ifdef INTEL_QAT_DP
+   libTrans.sessCxtId = ulUeCb->secInfo.cpIntSessCxtId;
+#ifdef QAT_TWO_INSTANCE
+   libTrans.instHndl = gCb->u.ulCb->instHndl;
+#else
+   libTrans.instHndl = gCb->instHndl;
+#endif
+#endif
+#ifdef PJ_SEC_ASYNC
+   /* Start the timer if it is not started already */
+   if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE)
+   {
+      pjRbCb->ulCb.obdPdu   =  secInp.count;
+      pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
+   }
+   ret = PjLibObdIntVerReq(&(gCb->pjGenCfg.obdPst.secPst), cxtId, 
+                                       secInp, libTrans, mBuf, macI);  
+#else
+#ifdef INTEL_SW_INTEG
+   ret = PjLibObdIntVerReq(gCb, &libTrans, mBuf, macI);
+#else
+   ret = PjLibObdIntVerReq(&libTrans, mBuf, macI);
+#endif
+#endif
+   RETVALUE(ret);
+
+} /* end of pjUtlIntVerReq */
+#else
+#ifdef ANSI
+PUBLIC S16 pjUtlIntVerReq
+(
+PjCb     *gCb,
+PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
+PjSecInp secInp ,                 /* Input parameters for integrity */ 
+Buffer   *mBuf,                   /* SDU to be compressed */
+U32      macI,                    /* MAC-I to be verified with */
+Status   *status                  /* Integrity verification status */
+)
+#else
+PUBLIC S16 pjUtlIntVerReq(gCb, pjRbCb, secInp, mBuf, macI, status)
+PjCb     *gCb;
+PjUlRbCb   *pjRbCb;                 /* PDCP RbCb */
+PjSecInp secInp;                 /* Input parameters for integrity */ 
+Buffer   *mBuf;                   /* SDU to be compressed */
+U32      macI;                    /* MAC-I to be verified with */
+Status   *status;                 /* Integrity verification status */
+#endif
+{
+   S16 ret = ROK;
+#ifdef PJ_SEC_ASYNC
+   PjLibTrans libTrans; /* Transaction Id for deciphering */
+#endif /* PJ_SEC_ASYNC */
+   PTR cxtId;    /* Context Identifier */
+
+   TRC3(pjUtlIntVerReq)
+
+   cxtId = (PTR)pjRbCb->ueCb->secInfo.intCxtId;
+
+#ifdef PJ_SEC_ASYNC
+   /* Assign transId and cxtId */
+   libTrans.count  = secInp.count;
+   libTrans.rbId   = pjRbCb->rbId - 1;
+   libTrans.rbType = pjRbCb->rbType;
+   libTrans.ueCb   = pjRbCb->ueCb;
+
+   /* Start the timer if it is not started already */
+   if((pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE)
+   {
+      pjRbCb->ulCb.obdPdu   =  secInp.count;
+      pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
+   }
+
+   ret = PjLibObdIntVerReq(&gCb->pjGenCfg.obdPst.secPst, cxtId, 
+                                       secInp, libTrans, mBuf, macI);  
+#else
+   /* ccpu00142570 */
+   ret = pjLibIntVerReq(cxtId, secInp, mBuf, macI, status);
+#endif
+
+   RETVALUE(ret);
+
+} /* end of pjUtlIntVerReq */
+#endif
+
+
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Utility function that processes the CfgReq with type as
+ *        REESTABLISH sent from RRC.
+ *
+ * @b Description:
+ *
+ *        This function 
+ *        1. Marks the state of the RBs as PJ_STATE_REEST.
+ *        2. Calculates the number of RBs undergoing reestablishment.
+ *
+ *  @param[in] ueCb     UE Control Block Pointer.
+ *  @param[in] numEnt   Number of entities undergoing reestablishment
+ *  @param[in] cfgEnt   List of entities configured.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlUlReEstSrb1
+(
+PjCb       *gCb,
+PjUlRbCb   *pjRbCb                    /* PDCP Control Block Pointer */
+)
+#else
+PUBLIC S16 pjUtlUlReEstSrb1(pjRbCb)
+PjCb       *gCb;
+PjUlRbCb   *pjRbCb;                   /* PDCP Control Block Pointer */
+#endif
+{
+   PjUlUeCb   *ueCb;
+
+   TRC2(pjUtlReEstSrb1)
+
+   RLOG2(L_DEBUG, "pjUtlReEstSrb1(pjRbCb(%d,%d))",
+                    pjRbCb->rbId, pjRbCb->rbType);
+
+   ueCb     = pjRbCb->ueCb;
+
+   ueCb->libInfo.state  =  PJ_STATE_REEST;
+
+   /* SRB Reconfiguration we can update the control Plane keys and
+      the Integrity Keys in the OBD module */
+
+   pjUtlUlUpdCpSecKeys(gCb,ueCb);
+
+   /* Perform  uplink reestablishment of SRB1 */
+   pjUlmReEstSrb(gCb,pjRbCb);
+
+   /* Start security reconfiguration if SRB1 is the only RB */
+   if ((ueCb->numSrbs == 1) && (ueCb->numDrbs == 0))
+   {
+     pjUtlUlUpdUpSecKeys(gCb,ueCb);
+   }
+
+   RETVALUE(ROK);
+} /* pjUtlReEstSrb1 */
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Handler to start reestablishment processing
+ *
+ * @b Description:
+ *
+ *        This function 
+ *        1. Marks the state of the RBs as PJ_STATE_REEST_HO.
+ *        2. Calculates the number of RBs undergoing reestablishment.
+ *
+ *  @param[in] ueCb    Number of RBs undergoing reestablishment
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlUlReEstHO
+(
+PjCb          *gCb,
+PjUlUeCb      *ueCb           /* Number of RBs undergoing reestablishment*/ 
+)
+#else
+PUBLIC S16 pjUtlUlReEstHO(gCb,ueCb) 
+PjCb          *gCb;
+PjUlUeCb      *ueCb;           /* Number of RBs undergoing reestablishment*/ 
+#endif
+{
+   U8             rbCnt;
+   PjUlRbCb     **rbCbLst;
+   PjUlRbCb      *pjRbCb;
+
+   TRC2(pjUtlUlReEstHO); 
+
+#ifdef ALIGN_64BIT
+   RLOG2(L_DEBUG, "pjUtlReEstHOStart(ueCb(%d,%d)))",
+                ueCb->key.ueId, ueCb->key.cellId);
+#else
+   RLOG2(L_DEBUG, "pjUtlReEstHOStart(ueCb(%d,%d))",
+                ueCb->key.ueId, ueCb->key.cellId);
+#endif
+
+   /* Perform initialisations on the HO Info structure */
+   PJ_ALLOC(gCb,ueCb->hoInfo, sizeof(PjUlHoInfo));
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if (ueCb->hoInfo == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+   PJ_ALLOC(gCb,ueCb->hoInfo->hoCfmInfo, 
+              sizeof(PjUlHoCfmInfo) *  PJ_MAX_DRB_PER_UE );
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if (ueCb->hoInfo->hoCfmInfo == NULLP )
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      /*ccpu00136858 */      
+      PJ_PST_FREE(gCb->u.ulCb->cpjSap.pst.region, gCb->u.ulCb->cpjSap.pst.pool, ueCb->hoInfo, sizeof(PjUlHoInfo));
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+   /* Initialise the reestablishment states for the RBs */
+   rbCbLst      = ueCb->drbCb;
+   for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt ++)
+   {
+      /* Check of rbCb available */
+      if( (pjRbCb = rbCbLst[rbCnt]) == NULLP)
+      {
+         continue;
+      }
+      /* Fetch the rbCb and intialise the states */
+      pjRbCb->state  =  PJ_STATE_REEST_HO;
+      ueCb->libInfo.numReEstDrb++;
+
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+       pjRbCb->ulCb.obdCnt   = 0;
+       pjRbCb->ulCb.transCmp = 0;
+       if(pjRbCb->mode == PJ_DRB_AM)
+       {
+          pjRbCb->ulCb.firstReEstCnt   =   pjRbCb->ulCb.rxDeliv;
+       }
+#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
+
+   }/* for(rbCnt .. */ 
+
+   RETVALUE(ROK);
+
+} /* pjUtlReEstHOStart */
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to apply the new security algorithms and 
+ *        reset the compression unit.
+ *
+ * @b Description:
+ *
+ *        This function 
+ *        1. Creates new contexts for Control Plane Ciphering and Integrity.
+ *        2. Closes the old contexts for Control Plane Ciphering and Integrity.
+ *
+ *  @param[in] ueCb   UE Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlUlUpdUpSecKeys
+(
+PjCb       *gCb,
+PjUlUeCb   *ueCb           /* UE Control Block */ 
+)
+#else
+PUBLIC S16 pjUtlUlUpdUpSecKeys(gCb,ueCb)
+PjCb         *gCb;
+PjUlUeCb     *ueCb;           /* UE Control Block */ 
+#endif
+{
+   Void     *tmpUpCxt;
+
+   TRC2(pjUtlUlUpdUpSecKeys);
+
+   RLOG2(L_DEBUG, "pjUtlUlUpdUpSecKeys(ueCb(%d,%d))",
+                ueCb->key.ueId, ueCb->key.cellId);
+
+   if(ueCb->secInfo.secAct == TRUE)
+   {
+      /* Initialisation is done first followed by closure since we
+       * do not want the same ctxId to be returned for the new init.
+       * In ASYNC case, we drop packets if they are returned from a
+       * different ctxId. */
+
+#ifdef INTEL_QAT_DP
+      tmpUpCxt  = ueCb->secInfo.upCiphSessCxtId; 
+#else
+      tmpUpCxt  = ueCb->secInfo.upCxtId; 
+#endif
+      pjUtlUlUpInit(gCb,ueCb);
+      pjUtlUlCipherClose(gCb,tmpUpCxt);
+   }
+
+   RETVALUE(ROK);
+} /* pjUtlUlUpdUpSecKeys */
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to apply the new security algorithms and 
+ *        reset the compression unit.
+ *
+ * @b Description:
+ *
+ *        This function 
+ *        1. Creates new contexts for Control Plane Ciphering and Integrity.
+ *        2. Closes the old contexts for Control Plane Ciphering and Integrity.
+ *
+ *  @param[in] ueCb   UE Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlUlUpdCpSecKeys
+(
+PjCb       *gCb,
+PjUlUeCb   *ueCb           /* UE Control Block */ 
+)
+#else
+PUBLIC S16 pjUtlUlUpdCpSecKeys(gCb,ueCb)
+PjCb         *gCb;
+PjDlUeCb     *ueCb;           /* UE Control Block */ 
+#endif
+{
+   Void     *tmpIntCxt;
+   Void     *tmpCpCxt;
+
+   TRC2(pjUtlDlUpdCpSecKeys);
+
+   RLOG2(L_DEBUG, "pjUtlUlUpdCpSecKeys(ueCb(%d,%d))",
+                ueCb->key.ueId, ueCb->key.cellId);
+
+   if(ueCb->secInfo.secAct == TRUE)
+   {
+      /* Initialisation is done first followed by closure since we
+       * do not want the same ctxId to be returned for the new init.
+       * In ASYNC case, we drop packets if they are returned from a
+       * different ctxId. */
+#ifdef INTEL_QAT_DP
+      tmpIntCxt = ueCb->secInfo.cpIntSessCxtId;  
+      tmpCpCxt  = ueCb->secInfo.cpCiphSessCxtId;         
+
+#else
+      tmpIntCxt = ueCb->secInfo.intCxtId;  
+      tmpCpCxt  = ueCb->secInfo.cpCxtId;    
+#endif
+
+      pjUtlUlCpInit(gCb,ueCb);
+      pjUtlUlIntInit(gCb,ueCb);
+
+      pjUtlUlIntClose(gCb,tmpIntCxt);
+      pjUtlUlCipherClose(gCb,tmpCpCxt);
+   }
+
+   RETVALUE(ROK);
+} /* pjUtlDlUpdCpSecKeys */
+
+/**
+ *
+ * @brief 
+ *
+ *        Function to handle the REESTABLISHMENT COMPLETE 
+ *        for each uplink RB
+ *
+ * @b Description:
+ *
+ *        This function 
+ *
+ *  @param[in] ueCb   UE Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlUlHdlRbReEstComplete
+(
+PjCb         *gCb,
+PjUlRbCb     *pjRbCb           /*RB Control Block */ 
+)
+#else
+PUBLIC S16 pjUtlUlHdlRbReEstComplete(ueCb, pjRbCb)
+PjCb         *gCb;
+PjUlRbCb     *pjRbCb;          /* RB Control Block */ 
+#endif
+{
+   PjUlUeCb      *ueCb;
+
+   TRC2(pjUtlUlHdlRbReEstComplete);
+
+   RLOG1(L_DEBUG, "pjUtlUlHdlRbReEstComplete(rbCb(%d)",
+                pjRbCb->rbId);
+
+   ueCb = pjRbCb->ueCb;
+   if (ueCb->libInfo.numReEstDrb == 0)
+   {
+      ueCb->libInfo.numReEstCmp++;
+      RETVALUE(ROK);
+   }
+   else
+   {
+      ueCb->libInfo.numReEstDrb--;  
+   }
+
+   if (ueCb->libInfo.numReEstDrb == 0)
+   {
+      if (ueCb->libInfo.state == PJ_STATE_REEST)
+      {
+         /* Since we have received all the packets in uplink
+            we can update the user keys */
+         pjUtlUlUpdUpSecKeys(gCb, ueCb);
+
+#ifdef PJ_ASYNC_CFM
+        RETVALUE(ROK);
+#endif
+        pjUtlUlSndReEstCfgCfm(gCb,ueCb);
+      }
+      else if (ueCb->libInfo.state == PJ_STATE_REEST_HO)
+      {
+         pjUtlUlSndSduStaCfm(gCb,ueCb);
+      }
+   }
+   RETVALUE(ROK);
+
+} /* pjUtlUlHdlRbReEstComplete */
+
+/**
+ *
+ * @brief 
+ *
+ *        Function to sent the REESTABLISHMENT COMPPLETE 
+ *        to the RRC.
+ *
+ * @b Description:
+ *
+ *        This function 
+ *        1. Sends a ReEstablishment Confirm for normal reestablishment.
+ *        2. Sends a SDU status confirm for handover reestablishment.
+ *
+ *  @param[in] ueCb   UE Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlUlSndReEstCfgCfm
+(
+PjCb         *gCb,
+PjUlUeCb       *ueCb           /* UE Control Block */ 
+)
+#else
+PUBLIC S16 pjUtlUlSndReEstCfgCfm(ueCb)
+PjCb         *gCb;
+PjUlUeCb       *ueCb;           /* UE Control Block */ 
+#endif
+{
+   CpjCfgCfmInfo *cfgCfmInfo;
+   U8             txIdx;
+   PjAsyncCfm    *asyncCfm    = NULLP;
+   PjCpjSapCb    *cpjSap;
+
+   TRC2(pjUtlSndReEstCfgCfm);
+
+   RLOG2(L_DEBUG, "pjUtlSndReEstCfgCfm(ueCb(%d,%d))",
+                ueCb->key.ueId, ueCb->key.cellId);
+
+   /* Pick up the confirm info */
+   for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
+   {
+      if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
+         (ueCb->libInfo.asyncCfm[txIdx]->cfmType & PJ_CFG_REEST_ASYNC_CFM))
+      {
+         asyncCfm =  ueCb->libInfo.asyncCfm[txIdx];
+         break;
+      }
+   }
+
+   /* its a reestablishment with only srb1 configured */
+   if(asyncCfm == NULLP)
+   {
+      RETVALUE(ROK);
+   }
+   /* Memory leak fix ccpu00135359 */
+   cpjSap = &(gCb->u.ulCb->cpjSap);
+   if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfgCfmInfo,
+      sizeof (CpjCfgCfmInfo)) != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   PJ_FILL_REEST_CFG_CFM_INFO(cfgCfmInfo, asyncCfm);
+   PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+   PjUiCpjCfgCfm(&gCb->u.ulCb->cpjSap.pst, gCb->u.ulCb->cpjSap.suId, cfgCfmInfo);         
+
+   RETVALUE(ROK);
+} /* pjUtlSndReEstCfgCfm */
+/**
+ *
+ * @brief Handler to store the confirms while we wait for the init
+ *        confirms from the off-board.
+ *       
+ *
+ * @b Description
+ *        This function is invoked during security config request,
+ *        reestablishment request and config request if the libraries
+ *        are off-boarded. This stores the entries in a confirm list
+ *        while waiting for the confirm from the offboard.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+
+#ifdef ANSI
+PUBLIC S16 pjUtlUlSaveCfmInfo
+(
+PjCb        *gCb,
+PjUlUeCb      *ueCb,           /* Pointer to UeCb */ 
+U8          cfmType,         /* Confirm type */
+Bool        startTmr,        /* Start Timer */
+U8          entity,          /* Confirm type */
+PTR         cfmPtr,          /* Pointer to the structure for confirm */
+PTR         cfgPtr           /* Pointer to the structure for request */
+)
+#else
+PUBLIC S16 pjUtlUlSaveCfmInfo(ueCb, cfmType, startTmr, entity, cfmPtr, cfgPtr)
+PjCb        *gCb;
+PjUlUeCb      *ueCb;           /* Pointer to UeCb */ 
+U8          cfmType;         /* Confirm type */
+Bool        startTmr;        /* Start Timer */
+U8          entity;          /* Confirm type */
+PTR         cfmPtr;          /* Pointer to the structure for confirm */
+PTR         cfgPtr;          /* Pointer to the structure for request */
+#endif
+{
+   S16               ret;        /* Return value            */
+   CpjSecCfgCfmInfo  *secCfm;    /* Security confirm        */
+   CpjReEstCfmInfo   *reEstCfm;  /* Reestablishment confirm */
+   CpjCfgCfmInfo     *cfgCfm;    /* Config confirm          */
+   U16               txId;       /* Transaction Id          */
+   PjAsyncCfm        *tAsyncCfm; /* Pointer to the async Cfm*/
+   CpjCfgReqInfo     *cfgReq;    /* Pointer to the config request */
+   U8                cfmIdx;     /* index for loopoing */
+
+
+   TRC3(pjUtlSaveCfmInfo)
+
+   RLOG_ARG4(L_DEBUG,DBG_UEID,  ueCb->key.ueId,
+         "pjUtlSaveCfmInfo cellId(%d),cfmType(%d),startTmr(%d),entity(%d))",
+         ueCb->key.cellId, cfmType, startTmr, entity);
+
+   /* Initialisations */
+   ret      = ROK;
+   secCfm   = NULLP;
+   reEstCfm = NULLP;
+   cfgCfm   = NULLP;
+   cfgReq   = NULLP;
+   txId     = ueCb->libInfo.nxtAvlbTxId;
+
+   if(txId == PJ_MAX_ASYNC_CFM)
+   {
+      /* The entire list is full, have to return negative confirms */
+      RETVALUE(RFAILED);
+   }
+
+   /* is entry already present */
+   if(ueCb->libInfo.asyncCfm[txId] != NULLP)
+   {
+      RETVALUE(RFAILED);
+   }
+
+   /* Allocate the structure */
+   PJ_ALLOC(gCb,ueCb->libInfo.asyncCfm[txId],  sizeof(PjAsyncCfm));
+   if(ueCb->libInfo.asyncCfm[txId]== NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   /* Initialise the structure */
+   tAsyncCfm   =   ueCb->libInfo.asyncCfm[txId];
+   tAsyncCfm->libInitBitMask   =   ueCb->libInfo.tLibInitBitMask;
+   tAsyncCfm->cmpInitBitMask   =   ueCb->libInfo.tCmpInitBitMask;
+   tAsyncCfm->entity           =   entity;
+   tAsyncCfm->startTmr         =   startTmr;
+
+   ueCb->libInfo.tLibInitBitMask =  0; 
+   ueCb->libInfo.tCmpInitBitMask =  0; 
+   
+   /* Assign the values */
+   if(cfmType  ==   PJ_SEC_ASYNC_CFM)
+   {
+      secCfm   =  (CpjSecCfgCfmInfo *)cfmPtr;
+      tAsyncCfm->cfmType =  cfmType;
+      tAsyncCfm->ueId    = secCfm->ueId;
+      tAsyncCfm->cellId  = secCfm->cellId;
+      tAsyncCfm->transId = secCfm->transId;
+   }
+   else if(cfmType  ==   PJ_REEST_ASYNC_CFM)
+   {
+      reEstCfm   =  (CpjReEstCfmInfo *)cfmPtr;
+      tAsyncCfm->cfmType =  cfmType;
+      tAsyncCfm->ueId    = reEstCfm->ueId;
+      tAsyncCfm->cellId  = reEstCfm->cellId;
+      tAsyncCfm->transId = reEstCfm->transId;
+   }
+   else if((cfmType  & PJ_CFG_ASYNC_CFM)  ||
+           (cfmType  & PJ_CFG_REEST_ASYNC_CFM)||
+           (cfmType  & PJ_CFG_UEDEL_ASYNC_CFM))
+   {
+      if(entity   == ENTPJ)
+      {
+         cfgCfm   =  (CpjCfgCfmInfo *)cfmPtr;
+         cfgReq   =  (CpjCfgReqInfo *)cfgPtr;
+
+         tAsyncCfm->cfmType = cfmType;
+         tAsyncCfm->ueId    = cfgCfm->ueId;
+         tAsyncCfm->cellId  = cfgCfm->cellId;
+         tAsyncCfm->transId = cfgCfm->transId;
+         tAsyncCfm->numEnt  = cfgReq->numEnt;
+
+         for ( cfmIdx = 0; cfmIdx < cfgReq->numEnt; cfmIdx++ )
+         {
+            tAsyncCfm->cfmEnt[cfmIdx].status  = cfgCfm->cfmEnt[cfmIdx].status;
+            tAsyncCfm->cfmEnt[cfmIdx].reason  = cfgCfm->cfmEnt[cfmIdx].reason;
+            tAsyncCfm->cfmEnt[cfmIdx].rbId    = cfgCfm->cfmEnt[cfmIdx].rbId;
+            tAsyncCfm->cfmEnt[cfmIdx].rbType  = cfgCfm->cfmEnt[cfmIdx].rbType;
+            tAsyncCfm->cfmEnt[cfmIdx].cfgType = cfgReq->cfgEnt[cfmIdx].cfgType;
+         }
+      }
+      else if(entity == ENTPJ)
+      {
+         CpjCfgCfmInfo  *pjCfgCfm;       /* Configuraiton Confirm */
+         pjCfgCfm   =  (CpjCfgCfmInfo *)cfmPtr;
+
+         tAsyncCfm->cfmType = cfmType;
+         tAsyncCfm->transId = pjCfgCfm->transId;
+         tAsyncCfm->ueId    = pjCfgCfm->ueId;
+         tAsyncCfm->cellId  = pjCfgCfm->cellId;
+         tAsyncCfm->numEnt  = pjCfgCfm->numEnt;
+
+         for ( cfmIdx = 0; cfmIdx < pjCfgCfm->numEnt; cfmIdx++ )
+         {
+            tAsyncCfm->cfmEnt[cfmIdx].status  = 
+                                 pjCfgCfm->cfmEnt[cfmIdx].status;
+            tAsyncCfm->cfmEnt[cfmIdx].reason  = 
+                                 pjCfgCfm->cfmEnt[cfmIdx].reason;
+            tAsyncCfm->cfmEnt[cfmIdx].rbId    = 
+                                 pjCfgCfm->cfmEnt[cfmIdx].rbId;
+            tAsyncCfm->cfmEnt[cfmIdx].rbType  = 
+                                 pjCfgCfm->cfmEnt[cfmIdx].rbType;
+         }
+      }
+   }
+
+   /* Start timer */
+   /* Timer should not be started when SEC is SYNC for ReEst Req
+    * and for the subsequent config req for REEST. The config req
+    * after reest req can still start the timer in the case comp being
+    * async and sec being sync if it also adds a RB and a compInit has
+    * to be sent . 
+    * */
+
+   if(tAsyncCfm->startTmr  == TRUE)
+   {
+      if((pjChkTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR)) == FALSE)
+      {
+         pjStartTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR);
+         ueCb->libInfo.crntTmrTxId  =  ueCb->libInfo.nxtAvlbTxId;
+      }
+   }
+
+   /* update nxtAvlbTxId to the next empty slot */
+   for(cfmIdx = 0; cfmIdx < PJ_MAX_ASYNC_CFM; cfmIdx++)
+   {
+      ueCb->libInfo.nxtAvlbTxId = 
+        (U16)((ueCb->libInfo.nxtAvlbTxId + 1) % PJ_MAX_ASYNC_CFM); /*KW_FIX*/
+
+      if(ueCb->libInfo.asyncCfm[ueCb->libInfo.nxtAvlbTxId] == NULLP)
+      {
+         break;
+      }
+   }
+
+   /* Cant find an empty slot ? */
+   if(cfmIdx == PJ_MAX_ASYNC_CFM)
+   {
+      ueCb->libInfo.nxtAvlbTxId = PJ_MAX_ASYNC_CFM;
+   }
+
+   RETVALUE(ret);
+}/* pjUtlSaveCfmInfo */
+\f
+/**
+ *
+ * @brief Handler to store update the bitmaks and send confirms if necessary.
+ *       
+ *
+ * @b Description
+ *        This function is invoked when receiving a InitCfm from Offboard.
+ *        It updates the bit masks and checks if it is necesary to send a 
+ *        confirm.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+
+#ifdef ANSI
+PUBLIC S16 pjUtlUlHdlObdInitCfm
+(
+PjCb        *gCb,
+PjUlUeCb      *ueCb,           /* Pointer to UeCb */ 
+U16         txIdx,           /* Transaction Index for UeCb */
+U8          cfmType,         /* Confirm type */
+U8          maskVal          /* mask value */
+)
+#else
+PUBLIC S16 pjUtlUlHdlObdInitCfm(ueCb, txIdx, cfmType, maskVal)
+PjCb        *gCb;
+PjUlUeCb      *ueCb;           /* Pointer to UeCb */ 
+U16         txIdx;           /* Transaction Index for UeCb */
+U8          cfmType;         /* Confirm type */
+U8          maskVal;         /* mask value */
+#endif
+{
+   CpjSecCfgCfmInfo *secCfgCfm;   /* Security config confirm */
+   CpjReEstCfmInfo  *reEstCfm;    /* Reest config confirm */
+   PjAsyncCfm       *asyncCfm;
+   CpjCfgCfmInfo    *cfgCfm;
+   U8               idx;
+   S16              ret;
+   TRC3(pjUtlUlHdlObdInitCfm)
+
+   RLOG_ARG4(L_DEBUG,DBG_UEID,  ueCb->key.ueId, 
+         "pjUtlHdlUlObdInitCfm(ueCb(%d,%d),txIdx(%d),cfmType(%d),maskVal(%d))",
+           ueCb->key.cellId, txIdx, cfmType, maskVal);
+
+   /* Initialisations */
+   secCfgCfm   =  NULLP;
+   reEstCfm    =  NULLP;
+   cfgCfm      =  NULLP;
+   asyncCfm    =  NULLP;
+   ret         =  ROK;
+
+   if((txIdx  == PJ_MAX_ASYNC_CFM) ||
+      (ueCb->libInfo.asyncCfm[txIdx] == NULLP))
+   {
+      RETVALUE(RFAILED);
+   }
+
+   asyncCfm =  ueCb->libInfo.asyncCfm[txIdx];
+
+   if(cfmType & PJ_SEC_INIT_CFM)
+   {
+      /* Update bit mask and check if all confirms have been received */
+      asyncCfm->libInitBitMask ^= (maskVal);
+      ret = pjUtlUlHdlSecInitCfm(gCb,ueCb,txIdx,asyncCfm,secCfgCfm,reEstCfm);
+   }
+   else if(cfmType  & PJ_CMP_INIT_CFM)
+   {
+      /* Check if all confirms have been received */
+      asyncCfm->cmpInitBitMask &= ~(1 << (maskVal - 1));
+
+      /* Update the status and reason for the received CmpInitCfm */
+      for ( idx = 0; idx < asyncCfm->numEnt; idx++ )
+      {
+         if ( asyncCfm->cfmEnt[idx].rbId == maskVal)
+         {
+            asyncCfm->cfmEnt[idx].status = CPJ_CFG_CFM_OK;
+            asyncCfm->cfmEnt[idx].reason = CPJ_CFG_REAS_NONE;
+            break;
+         }
+      }
+
+      ret = pjUtlUlHdlCmpInitCfm(gCb,ueCb,txIdx,asyncCfm,cfgCfm);
+   }
+
+   RETVALUE(ret);
+}/* pjUtlHdlUlObdInitCfm */
+\f
+/**
+ *
+ * @brief Handler for init off-board timer expiry.
+ *
+ *
+ * @b Description
+ *        This function is called when the off-board timer expires for
+ *        a Init Req of a channel (either for ciphering/integrity/compression).
+ *        This function sends a confirm with failure for SecCfgReq if the
+ *        state of the RB is normal. It sends a confirm with failure
+ *        for config request(only for RBs with Re-establishment Req, a failure 
+ *        is stored in the confirm) if the state of the RB is re-establishment.
+ *
+ *  @param[in] ueCb    UE control block.
+ *
+ *
+ *  @return  S16
+ *      -# ROK
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUtlUlHdlInitObdTmrExp
+(
+PjCb     *gCb,
+PjUlUeCb *ueCb
+)
+#else
+PUBLIC S16 pjUtlUlHdlInitObdTmrExp(ueCb)
+PjCb     *gCb;
+PjUlUeCb *ueCb;
+#endif
+{
+   S16               ret;           /* Return Value */
+   CpjSecCfgCfmInfo  *secCfgCfm;    /* Security Cfg Confirm Info */
+   CpjCfgCfmInfo     *cfgCfm;       /* Config Confirm Info */
+   CpjReEstCfmInfo   *reEstCfm;     /* Reest config confirm */
+   CpjCfgCfmInfo     *pjCfgCfm;
+   PjLibInfo         *libInfo;      /* Off-board Info */
+   PjAsyncCfm        *asyncCfm;     /* Async Cfm Info */
+   PjCpjSapCb        *cpjSap;       /* CPJ SAP Control Block */
+   U16               txIdx;         /* Tx Idx */
+   U16               idx;           /* Index for looping */
+   U16               cfgIdx;
+
+   TRC3(pjUtlHdlInitObdTmrExp)
+
+   RLOG2(L_DEBUG, "pjUtlHdlInitObdTmrExp(ueCb(%d,%d))",
+                ueCb->key.ueId, ueCb->key.cellId);
+
+   ret       = ROK;
+   cpjSap    = &(gCb->u.ulCb->cpjSap);
+   secCfgCfm = NULLP;
+   libInfo   = &ueCb->libInfo;
+   txIdx     = libInfo->crntTmrTxId;
+
+   /* Restart the timer */
+   PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx);
+
+   /* Shouldnt happen, nevertheless, check */
+   if( txIdx >= PJ_MAX_ASYNC_CFM || libInfo->asyncCfm[txIdx] == NULLP)
+   {
+      RETVALUE(ROK);
+   }
+
+   asyncCfm =  libInfo->asyncCfm[txIdx];
+
+   /* Security confirm */
+   if(asyncCfm->cfmType & PJ_SEC_ASYNC_CFM)
+   {
+      PJ_ALLOC(gCb,secCfgCfm, sizeof(CpjSecCfgCfmInfo));
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      if (secCfgCfm == NULLP)
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+      PJ_FILL_SEC_CFM_INFO(secCfgCfm, asyncCfm);
+      secCfgCfm->status = CPJ_CFG_CFM_NOK;
+      secCfgCfm->reason = CPJ_CFG_REAS_OBD_TIMEOUT;
+
+      PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+      PjUiCpjSecCfgCfm(&(cpjSap->pst), cpjSap->suId, secCfgCfm);
+   }
+
+   /* Configuration confirms */
+   else if ((asyncCfm->cfmType & PJ_CFG_ASYNC_CFM) ||
+            (asyncCfm->cfmType & PJ_CFG_REEST_ASYNC_CFM))
+   {
+      PJ_FILL_TIMEOUT_CFG_CFM_INFO(gCb,cfgCfm, asyncCfm);
+
+      PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+      PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm);
+   }
+   else if (asyncCfm->cfmType & PJ_REEST_ASYNC_CFM)
+   {
+      /* Send ReEstCfm */
+      PJ_ALLOC(gCb,reEstCfm, sizeof(CpjReEstCfmInfo));
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      if (reEstCfm == NULLP)
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         RETVALUE(RFAILED);
+      }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+      PJ_FILL_REEST_CFM_INFO(reEstCfm, asyncCfm, LCM_PRIM_NOK);
+
+      PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+      PjUiCpjReEstCfm(&gCb->u.ulCb->cpjSap.pst, 
+                       gCb->u.ulCb->cpjSap.suId, reEstCfm);
+
+      /* Send the config confirm also if any exists */
+      cfgIdx   =  (U16)(txIdx + 1);  /*KW_FIX*/
+
+      for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++, cfgIdx++)
+      {
+         cfgIdx %=   PJ_MAX_ASYNC_CFM;
+         if((libInfo->asyncCfm[cfgIdx] != NULLP) &&
+            (libInfo->asyncCfm[cfgIdx]->cfmType & PJ_CFG_REEST_ASYNC_CFM))
+         {
+            break;
+         }
+      }
+
+      /* This scenario occurs when only SRB1 is configured */
+      if(idx == PJ_MAX_ASYNC_CFM)
+      {
+         RETVALUE(ROK);
+      }
+
+      PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, cfgIdx);
+      asyncCfm =  libInfo->asyncCfm[cfgIdx];
+
+      PJ_FILL_TIMEOUT_CFG_CFM_INFO(gCb,cfgCfm, asyncCfm);
+
+      PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+      PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm);
+   }
+   else if(asyncCfm->cfmType & PJ_CFG_UEDEL_ASYNC_CFM)
+   {
+      /* Delete ueCb entry from ueLstCp */
+      pjStopTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR);
+      ret = cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb);
+      if (ret != ROK)
+      {
+
+#ifdef DEBUGP
+         RLOG_ARG0(L_DEBUG,DBG_UEID,ueCb->key.ueId, 
+               "pjUtlHdlInitObdTmrExp: cmHashListDelete Failed for ueCb.");
+#endif
+      }
+
+      if ( asyncCfm->entity == ENTPJ )
+      {
+         PJ_ALLOC(gCb,cfgCfm, sizeof(CpjCfgCfmInfo));
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         if (cfgCfm == NULLP)
+         {
+            RLOG0(L_FATAL, "Memory Allocation failed.");
+            RETVALUE(RFAILED);
+         }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+
+         for ( idx = 0; idx < asyncCfm->numEnt; idx++)
+         {
+            cfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status;
+            cfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason;
+            cfgCfm->cfmEnt[idx].rbId   = asyncCfm->cfmEnt[idx].rbId;
+            cfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType;
+         }
+         cfgCfm->ueId    = asyncCfm->ueId;
+         cfgCfm->cellId  = asyncCfm->cellId;
+         cfgCfm->transId = asyncCfm->transId;
+         cfgCfm->numEnt  = asyncCfm->numEnt;
+
+         /* delete all confirms present there */
+         for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++)
+         {
+            if(libInfo->asyncCfm[idx] != NULLP)
+            {
+               PJ_FREE(gCb,ueCb->libInfo.asyncCfm[idx], sizeof(PjAsyncCfm)); 
+               ueCb->libInfo.asyncCfm[idx] = NULLP; 
+            }
+         }
+
+         PJ_FREE(gCb,ueCb, sizeof(PjUlUeCb));
+         PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm);
+      }
+      else if ( asyncCfm->entity == ENTPJ )
+      {
+         PJ_ALLOC(gCb,pjCfgCfm, sizeof(CpjCfgCfmInfo));
+#if (ERRCLASS & ERRCLS_ADD_RES)
+         if (pjCfgCfm == NULLP)
+         {
+            RLOG0(L_FATAL, "Memory Allocation failed.");
+            RETVALUE(RFAILED);
+         }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+         for ( idx = 0; idx < asyncCfm->numEnt; idx++)
+         {
+            pjCfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status;
+            pjCfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason;
+            pjCfgCfm->cfmEnt[idx].rbId          = asyncCfm->cfmEnt[idx].rbId;
+            pjCfgCfm->cfmEnt[idx].rbType        = asyncCfm->cfmEnt[idx].rbType;
+         }
+         pjCfgCfm->ueId    = asyncCfm->ueId;
+         pjCfgCfm->cellId  = asyncCfm->cellId;
+         pjCfgCfm->transId = asyncCfm->transId;
+         pjCfgCfm->numEnt  = asyncCfm->numEnt;
+
+         /* delete all confirms present there */
+         for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++)
+         {
+            if(libInfo->asyncCfm[idx] != NULLP)
+            {
+               PJ_FREE(gCb,ueCb->libInfo.asyncCfm[idx], sizeof(PjAsyncCfm)); 
+               ueCb->libInfo.asyncCfm[idx] = NULLP; 
+            }
+         }
+
+         PJ_FREE(gCb,ueCb, sizeof(PjUlUeCb));
+         PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, pjCfgCfm);
+      }
+   }
+
+   RETVALUE(ret);
+} /* pjHdlUeDelWaitTmrExp */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function to sent the REESTABLISHMENT COMPPLETE 
+ *        to the RRC.
+ *
+ * @b Description:
+ *
+ *        This function 
+ *        1. Sends a ReEstablishment Confirm for normal reestablishment.
+ *        2. Sends a SDU status confirm for handover reestablishment.
+ *
+ *  @param[in] ueCb   UE Control Block
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlUlSndSduStaCfm
+(
+PjCb         *gCb,
+PjUlUeCb     *ueCb           /* UE Control Block */ 
+)
+#else
+PUBLIC S16 pjUtlUlSndSduStaCfm(gCb, ueCb)  
+PjCb         *gCb;
+PjUlUeCb     *ueCb;           /* UE Control Block */ 
+#endif
+{
+   U8       rbCnt;
+   CpjSduStaCfmInfo  *cfmInfo;
+   UdxSduStaCfmInfo  *udxCfmInfo;
+   UdxSduStaInfo tempDlStaInfo[PJ_MAX_DRB_PER_UE] = {{0}};
+   U8 rbId;
+   U8 numRb = 0;
+   PjUlHoCfmInfo *hoCfmInfo;
+   CpjSduStaInfo  *staInfo;
+   Bool rbPres;
+   PjCpjSapCb     *cpjSap;
+   PjUdxUlSapCb   *udxSap;
+   
+
+   TRC2(pjUtlUlSndSduStaCfm); 
+
+   RLOG2(L_DEBUG, "pjUtlUlSndSduStaCfm(ueCb(%d,%d))",
+                ueCb->key.ueId, ueCb->key.cellId);
+
+   cpjSap = &(gCb->u.ulCb->cpjSap);
+   if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfmInfo,
+      sizeof (CpjSduStaCfmInfo)) != ROK)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+
+   cfmInfo->ueId = ueCb->key.ueId;
+   cfmInfo->cellId = ueCb->key.cellId;
+   cfmInfo->transId = ueCb->hoInfo->transId;
+   cfmInfo->reason = CPJ_CFG_REAS_NONE;
+   udxCfmInfo      = ueCb->hoInfo->staCfm;
+
+   for(rbCnt = 0; rbCnt < udxCfmInfo->numRb; rbCnt++)
+   {
+      /*
+      - Check for rbId and copy the info to index=(rbId)
+      */
+      rbId = udxCfmInfo->sduStaInfo[rbCnt].rbId;
+      if(udxCfmInfo->sduStaInfo[rbCnt].dlSduStaInfo.hoPres == TRUE)
+      {
+         tempDlStaInfo[rbId].rbId = udxCfmInfo->sduStaInfo[rbCnt].rbId;
+         tempDlStaInfo[rbId].dir = udxCfmInfo->sduStaInfo[rbCnt].dir;
+         tempDlStaInfo[rbId].dlSduStaInfo.count = udxCfmInfo->sduStaInfo[rbCnt].dlSduStaInfo.count;
+         tempDlStaInfo[rbId].dlSduStaInfo.hoPres = TRUE;
+      }
+   } 
+
+   for(rbCnt = 0;
+      ((rbCnt < PJ_MAX_DRB_PER_UE) && (numRb < CPJ_MAX_DRB)); rbCnt++)
+   {
+      rbPres     = FALSE;
+      hoCfmInfo   =  &ueCb->hoInfo->hoCfmInfo[rbCnt];
+      staInfo     =  &cfmInfo->sduStaInfo[numRb];
+      memset((void *)staInfo,0,sizeof(CpjSduStaInfo));
+      if(hoCfmInfo->pres == TRUE)
+      {                          
+         rbPres = TRUE;
+         staInfo->rbId  =  hoCfmInfo->rbId;
+         staInfo->dir   |= hoCfmInfo->dir;
+         staInfo->snLen = ueCb->drbCb[hoCfmInfo->rbId]->snLen;
+         staInfo->ulSduStaInfo.numBits   =  hoCfmInfo->numBits;
+         if (hoCfmInfo->numBits > 0) 
+         {
+            /* numBits is always filled as multiple's of 8 */
+            cpjSap = &(gCb->u.ulCb->cpjSap);
+            if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,
+                        (Data **)&staInfo->ulSduStaInfo.ulBitMap,
+                        sizeof (U8) * (hoCfmInfo->numBits / 8)) != ROK)
+            {
+               RLOG0(L_FATAL, "Memory Allocation failed.");
+               RETVALUE(RFAILED);
+            }
+            PJ_MEM_CPY(staInfo->ulSduStaInfo.ulBitMap, hoCfmInfo->ulBitMap, (hoCfmInfo->numBits / 8));
+            PJ_FREE(gCb, hoCfmInfo->ulBitMap, sizeof(U8) * (hoCfmInfo->numBits / 8));
+         }
+         staInfo->ulSduStaInfo.count     =  hoCfmInfo->count;
+      }
+      if(tempDlStaInfo[rbCnt].dlSduStaInfo.hoPres == TRUE)
+      { 
+         rbPres = TRUE;
+         staInfo->rbId  =  tempDlStaInfo[rbCnt].rbId;
+         staInfo->dir   |=  tempDlStaInfo[rbCnt].dir;
+         staInfo->snLen = ueCb->drbCb[staInfo->rbId]->snLen;
+         staInfo->dlSduStaInfo.count = tempDlStaInfo[rbCnt].dlSduStaInfo.count;
+      }
+      if(rbPres != TRUE)
+      {
+         continue;
+      }
+      else
+      {
+        numRb++;
+      }
+   }
+
+   cfmInfo->numRb = numRb; 
+   cfmInfo->status = ROK;
+   cfmInfo->reason = CPJ_CFG_REAS_NONE;
+   PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo,
+              (PJ_MAX_DRB_PER_UE * sizeof(PjUlHoCfmInfo)));
+   /* Memory leak fix ccpu00135359 */
+   udxSap = PJ_GET_UL_UDX_SAP(gCb);
+   PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool,ueCb->hoInfo->staCfm,
+                sizeof (UdxSduStaCfmInfo));
+   PJ_FREE(gCb,ueCb->hoInfo, sizeof(PjUlHoInfo));
+   
+   PjUiCpjSduStaCfm(&gCb->u.ulCb->cpjSap.pst, 
+                     gCb->u.ulCb->cpjSap.suId, cfmInfo);
+    
+   RETVALUE(ROK);
+} /* pjUtlSndSduStaCfm */
+
+/**
+ *
+ * @brief Handler to clean up all the PDCP Control Blocks.
+ *       
+ *
+ * @b Description
+ *        This function is invoked by LMM to shutdown the
+ *        layer. This cleans up recBuf and txBuf of all the
+ *        PDCP RBs in all the UEs.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED 
+ *
+*/
+
+#ifdef ANSI
+PUBLIC S16 pjUtlUlShutdown
+(
+PjCb  *gCb
+)
+#else
+PUBLIC S16 pjUtlUlShutdown()
+PjCb   *gCb;
+#endif
+{
+   S16         ret;              /* Return Value */
+   PjUlUeCb      *ueCb;            /* UE Control Block */
+   PjUlUeCb      *prevUeCb;        /* Previos UE Control Block */
+   PjUlRbCb        *rbCb;            /* RB Control Block */
+   PjUlRbCb        **rbCbLst;        /* RB Control Block List */
+   PjSec       *secInfo;          /* Security info of UE */
+   U8          idx;              /* Index for RBs */
+#ifdef LTE_L2_MEAS_COMMENT
+   PjL2MeasEvtCb  *measEvtCb = NULLP;
+#endif
+   TRC3(pjUtlShutdown)
+
+   RLOG0(L_DEBUG, "pjUtlShutdown()");
+
+   ret      = ROK;
+   ueCb     = NULLP;
+   prevUeCb = NULLP;
+   rbCb     = NULLP;
+   rbCbLst  = NULLP;
+   idx      = 0;
+
+   /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
+   while (cmHashListGetNext(&(gCb->u.ulCb->ueLstCp), (PTR) prevUeCb, (PTR *)&ueCb) == ROK)
+   {
+      if ( ueCb != NULLP )
+      {
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+         if (ueCb->libInfo.obdTmr.tmrEvnt == PJ_EVT_OBD_TMR)
+         {
+            pjStopTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_TMR);
+         }
+#endif
+         rbCbLst = ueCb->srbCb;
+         for (idx = 0; idx < PJ_MAX_SRB_PER_UE; idx++)
+         {
+             rbCb = rbCbLst[idx];
+             if (rbCb != NULLP)
+             {
+               /* Free the Buffers of RbCb */
+               pjUtlUlFreeRb(gCb,rbCb);
+             }
+         }
+         rbCbLst = ueCb->drbCb;
+         for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++)
+         {
+             rbCb = rbCbLst[idx];
+             if (rbCb != NULLP)
+             {
+                pjUtlUlFreeRb(gCb,rbCb);
+             }
+         }
+         /* Close all the context info for offboarding */
+         secInfo = &(ueCb->secInfo);
+#ifdef INTEL_QAT_DP
+                pjUtlUlIntClose(gCb,ueCb->secInfo.cpIntSessCxtId); 
+                pjUtlUlCipherClose(gCb,ueCb->secInfo.cpCiphSessCxtId);
+                pjUtlUlCipherClose(gCb,ueCb->secInfo.upCiphSessCxtId);
+#else
+         pjUtlUlCipherClose(gCb,secInfo->cpCxtId);
+         pjUtlUlCipherClose(gCb,secInfo->upCxtId);
+         pjUtlUlIntClose(gCb,secInfo->intCxtId);
+#endif
+         /* Delete hoInfo if present */
+         if (ueCb->hoInfo != NULLP)
+         {
+            for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++)
+            {
+               if (ueCb->hoInfo->hoCfmInfo[idx].pres == TRUE)
+               {
+                  PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo[idx].ulBitMap,
+                        (ueCb->hoInfo->hoCfmInfo[idx].numBits % 8)?
+                        ((ueCb->hoInfo->hoCfmInfo[idx].numBits / 8) + 1):
+                        (ueCb->hoInfo->hoCfmInfo[idx].numBits / 8 ));
+               }
+            }
+
+            PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo,                         \
+                           (PJ_MAX_DRB_PER_UE * sizeof(PjUlHoCfmInfo)));
+            PJ_FREE(gCb,ueCb->hoInfo, sizeof(PjUlHoInfo));                 
+         }
+      }
+      prevUeCb = ueCb;
+   }
+#ifdef LTE_L2_MEAS_COMMENT
+   for(idx = 0; idx < PJ_MAX_L2MEAS_EVT; idx++)
+   {
+      if(pjCb.pjL2Cb.pjMeasEvtCb[idx] != NULLP)
+      {
+         measEvtCb = pjCb.pjL2Cb.pjMeasEvtCb[idx];
+         pjStopTmr(gCb,(PTR)measEvtCb, PJ_EVT_L2_TMR);
+         gCb.pjL2Cb.pjNumMeas--;
+         PJ_FREE(gCb,measEvtCb, sizeof(PjL2MeasEvtCb));
+         pjCb.pjL2Cb.pjMeasEvtCb[idx] = NULLP;
+      }
+   }
+#endif
+   ret = pjDbmUlDeInit(gCb);
+#if (ERRCLASS & ERRCLS_DEBUG)
+   if (ret != ROK)
+   {
+      RLOG0(L_FATAL, "PDCP UL DeInitialization Failed.\n");
+   }
+#endif /* ERRCLASS & ERRCLS_DEBUG */
+   RETVALUE(ret);
+}
+
+/**
+ * 
+ * @brief 
+ *
+ *        Handler to free a PDCP Control Block.
+ *
+ * @b Description:
+ * 
+ *        This function frees the txBuf and rxBuf in a PDCP control block.
+ *        and closes the compression channel opened. It stops the timers 
+ *        of this control block if they are running.
+ *
+ *  @param[in]  pst        Post structure 
+ *  @param[in]  secCxt     Context for Integrity protection/verification 
+ *  @param[in]  ctxId      Integrity Context Id
+ *
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+
+#ifdef ANSI
+PUBLIC Void pjUtlUlFreeRb
+(
+PjCb     *gCb,
+PjUlRbCb *pjRbCb
+)
+#else
+PUBLIC Void pjUtlUlFreeRb(pjRbCb)
+PjCb     *gCb;
+PjUlRbCb *pjRbCb;
+#endif
+{
+   TRC3(pjUtlFreeUlRb)
+
+   RLOG0(L_DEBUG, "pjUtlFreeRb()");
+
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+   if (pjRbCb->ulCb.obdTmr.tmrEvnt == PJ_EVT_UL_OBD_TMR)
+   {
+       pjStopTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
+   }
+#endif
+   pjDbmRxDeInit(gCb,&(pjRbCb->ulCb.recBuf));
+   
+   pjUtlCmpClose(gCb,pjRbCb->cmpCxtId);
+   /*pj004.201 Adding of Missing Trace in LTE RLC PDCP*/
+   RETVOID;
+}
+
+/* pj005.201 added function to send data forward indication message */
+/**
+ * 
+ * @brief 
+ *
+ *        Handler to send Data Fwd Indication
+ *
+ * @b Description:
+ *      This function sends Data Fwd Indication message to PDCP user 
+ *
+ *  @param[in]  pjRbCb     PDCP RbCb
+ *  @param[in]  datFwdInd  Data forward indication
+ *
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUtlUlSndDatFwdInd
+(
+PjCb             *gCb,
+PjUlRbCb           *pjRbCb,
+PjuDatFwdIndInfo *datFwdInd
+)
+#else
+PUBLIC S16 pjUtlUlSndDatFwdInd(pjRbCb, datFwdInd)
+PjCb             *gCb;
+PjUlRbCb           *pjRbCb;
+PjuDatFwdIndInfo *datFwdInd;
+#endif
+{
+   CmLtePdcpId  *pdcpId;
+   PjPjuSapCb   *pjuSap;
+   CmLtePdcpId   pdcpIdTmp;
+
+   TRC3(pjUtlUlSndDatFwdInd)
+   
+   RLOG0(L_DEBUG, "pjUtlSndDatFwdInd()");
+
+   pjuSap   = &(gCb->u.ulCb->pjuSap[PJ_DRB_SAP]);
+   pdcpId = &pdcpIdTmp;
+
+   if(pdcpId != NULLP)
+   {
+      pdcpId->ueId   =  pjRbCb->ueCb->key.ueId;
+      pdcpId->cellId =  pjRbCb->ueCb->key.cellId;
+      pdcpId->rbId   =  pjRbCb->rbId;
+      pdcpId->rbType =  pjRbCb->rbType;
+      
+      gCb->pjGenSts.numPktsFrwd += datFwdInd->numSdus;
+      /* If trace flag is enabled send the trace indication */
+      if(gCb->init.trc == TRUE)
+      {                       
+         /* Populate the trace params */
+         pjLmmSendTrc(gCb,EVTPJUDATFWDIND, NULLP);
+      }
+      PjUiPjuDatFwdInd(&(pjuSap->pst), pjuSap->suId, pdcpId, datFwdInd);
+   }
+
+  RETVALUE(ROK);
+
+}/* end of pjUtlSndDatFwdInd */
+
+/**
+ * 
+ * @brief 
+ *
+ *        Handler to send Data Fwd Indication
+ *
+ * @b Description:
+ *      This function sends Data Fwd Indication message to PDCP user 
+ *
+ *  @param[in]  pjRbCb     PDCP RbCb
+ *  @param[in]  datFwdInd  Data forward indication
+ *
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUtlUlSndUlStaRep
+(
+PjCb             *gCb,
+PjUlRbCb         *pjRbCb,
+Buffer           *sta
+)
+#else
+PUBLIC S16 pjUtlUlSndUlStaRep(pjRbCb, sta)
+PjCb             *gCb;
+PjUlRbCb         *pjRbCb;
+Buffer           *sta;
+#endif
+{
+   PjUdxUlSapCb *udxSap;
+   UdxUlStaRepInfo   *staRep;
+   S16               ret = ROK;           /* Return Value */
+   
+   udxSap = PJ_GET_UL_UDX_SAP(gCb);
+
+   TRC3(pjUtlUlSndUlStaRep)
+   
+   RLOG0(L_DEBUG, "pjUtlUlSndUlStaRep()");
+
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, staRep,
+                     sizeof (UdxUlStaRepInfo), ret);
+                     
+   if(ret != ROK)
+   {
+     staRep = NULLP;
+   }
+
+   if(staRep != NULLP)
+   {
+      staRep->pdcpId.ueId   =  pjRbCb->ueCb->key.ueId;
+      staRep->pdcpId.cellId =  pjRbCb->ueCb->key.cellId;
+      staRep->pdcpId.rbId   =  pjRbCb->rbId;
+      staRep->pdcpId.rbType =  pjRbCb->rbType;
+      staRep->sta = sta;
+
+      PjUlUdxUlStaRep(&(udxSap->pst), udxSap->spId, staRep);
+   }
+   else
+   {
+      PJ_FREE_BUF(sta);
+   }
+
+   RETVALUE(ROK);
+}/* end of pjUtlSndDatFwdInd */
+
+
+/**
+ * 
+ * @brief 
+ *
+ *        Handler to send Feedback packet to DL-PDCP
+ *
+ * @b Description:
+ *      This function sends Feedback packet to DL-PDCP 
+ *
+ *  @param[in]  pjCb       PDCP global control block
+ *  @param[in]  pjRbCb     PDCP RbCb
+ *  @param[in]  fbPkt      Feedback packet
+ *
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUtlUlSndUlRohcFdbk
+(
+PjCb             *gCb,
+PjUlRbCb         *pjRbCb,
+Buffer           *fbPkt
+)
+#else
+PUBLIC S16 pjUtlUlSndUlRohcFdbk(gCb, pjRbCb, fbPkt)
+PjCb             *gCb;
+PjUlRbCb         *pjRbCb;
+Buffer           *fbPkt;
+#endif
+{
+   PjUdxUlSapCb      *udxSap;
+   UdxUlFdbkPktInfo  *fdbkPktInfo;
+   S16               ret = ROK;
+   
+   udxSap = PJ_GET_UL_UDX_SAP(gCb);
+
+   TRC3(pjUtlUlSndUlRohcFdbk)
+   
+   RLOG0(L_DEBUG, "pjUtlUlSndUlRohcFdbk()");
+
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, fdbkPktInfo,
+      sizeof (UdxUlFdbkPktInfo), ret);
+   if(ret != ROK)
+   {
+      fdbkPktInfo= NULLP;
+   }
+
+   if(fdbkPktInfo != NULLP)
+   {
+      fdbkPktInfo->pdcpId.ueId   =  pjRbCb->ueCb->key.ueId;
+      fdbkPktInfo->pdcpId.cellId =  pjRbCb->ueCb->key.cellId;
+      fdbkPktInfo->pdcpId.rbId   =  pjRbCb->rbId;
+      fdbkPktInfo->pdcpId.rbType =  pjRbCb->rbType;
+      fdbkPktInfo->fbPkt = fbPkt;
+
+      PjUlUdxUlFdbkPktInfo(&(udxSap->pst), udxSap->spId, fdbkPktInfo);
+   }
+   else
+   {
+      PJ_FREE_BUF(fbPkt);
+   }
+
+   RETVALUE(ROK);
+}/* end of pjUtlUlSndUlRohcFdbk */
+
+/* pj005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+/**
+ *
+ * @brief Function to initialise measurement
+ *
+ * @b Description
+ *
+ * @param[in]  gCb     PDCP Instance Control Block
+ *
+ *  @return  Void
+ *
+ */
+S16 pjUtlL2MeasUlInit(PjCb *gCb)
+{
+   U16   cntr;
+
+   gCb->u.ulCb->pjL2Cb.pjNumMeas=0;
+   for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++)
+   {
+      cmMemset((U8 *)&(gCb->u.ulCb->pjL2Cb.pjL2EvtCb[cntr]), 0, sizeof(PjL2MeasEvtCb));
+   }
+   gCb->u.ulCb->pjL2Cb.pjL2EvtCb[PJ_L2MEAS_UL_LOSS].measCb.measType = LPJ_L2MEAS_UL_LOSS;
+   gCb->u.ulCb->pjL2Cb.pjL2EvtCb[PJ_L2CPU_PERCORE_STATS].measCb.measType = LPJ_L2CPU_PERCORE_STATS;
+   gCb->u.ulCb->pjL2Cb.pjL2EvtCb[PJ_L2MEM_PERPOOL_STATS].measCb.measType = LPJ_L2MEM_PERPOOL_STATS;
+   /* initialize the timer value for memory and CPU utilization */
+   gCb->u.ulCb->pjL2Cb.measTmrCfg.enb = TRUE;
+   gCb->u.ulCb->pjL2Cb.measTmrCfg.val = CM_MEM_CPU_UITL_INFO_TMR_VAL;
+   cmInitTimers(&gCb->u.ulCb->pjL2Cb.measTmr,PJ_L2_MAX_TIMERS); 
+   
+   RETVALUE(ROK);
+}
+/**
+ *
+ * @brief Handler for resetting the DL measurement counters 
+ *
+ *
+ * @b Description
+ *
+ * @param[in] measCb    Measurement Control Block.
+ *
+ *
+ * @return  Void
+ */
+#ifdef ANSI
+
+PUBLIC Void pjUtlResetUlL2MeasCntr
+(
+PjCb         *tPjCb,
+PjL2MeasCb   *measCb,
+U8           measType
+)
+#else
+PUBLIC Void pjUtlResetUlL2MeasCntr(tPjCb, measCb, measType)
+PjCb         *tPjCb;
+PjL2MeasCb   *measCb;
+U8           measType;
+#endif
+{
+   if (measCb->measType & LPJ_L2MEAS_UL_LOSS)
+   {
+      U32 qciIdx;
+      for(qciIdx = 1; qciIdx < LPJ_MAX_QCI; qciIdx++)
+      {
+         U8 qci = measCb->qci[qciIdx];
+
+         measCb->measData[qci].ulLoss.val = 0;
+         measCb->measData[qci].ulLoss.numPkts = 0;
+         tPjCb->u.ulCb->pjL2Cb.measOn[qci] &= ~LPJ_L2MEAS_UL_LOSS;
+      }
+   }
+   if (measCb->measType & LPJ_L2MEM_PERPOOL_STATS)
+   {
+     tPjCb->u.ulCb->pjL2Cb.memUtilizationMask = 0;
+     /* Clear Memory Statistics */
+     cmClearMemUtilizationCounter(&(measCb->memInfo));
+   }
+   if(measCb->measType & LPJ_L2CPU_PERCORE_STATS )
+   {
+     tPjCb->u.ulCb->pjL2Cb.cpuUtilizationMask = 0;
+   }
+
+}
+
+\f
+/**
+ *
+ * @brief Handler for Sending Negative confirm .
+ *
+ *
+ * @b Description
+ *        This function is called when the l2 measurement cannot be started
+ *        This function sends  negative confirm for all the requests
+ *
+ *  @param[in] measReqEvt    Measurement Req Structure
+ *
+ *
+ *  @return  S16
+ *      -# ROK
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUtlSndUlL2MeasNCfm
+(
+PjCb            *gCb,
+PjL2MeasCfmEvt  *measCfmEvt
+)
+#else
+PUBLIC S16 pjUtlSndUlL2MeasNCfm(gCb, measCfmEvt)
+PjCb            *gCb;
+PjL2MeasCfmEvt  *measCfmEvt;
+#endif
+{
+
+   TRC3(pjUtlSndL2MeasNCfm)
+
+   PjMiLpjL2MeasCfm(&gCb->pjGenCfg.lmPst, measCfmEvt);
+
+   RETVALUE(ROK);
+} /* pjUtlSndL2MeasNCfm */
+
+/**
+ *
+ * @brief Handler for storing address of MeasData in rbCb at right index
+ *
+ *
+ * @b Description
+ *        Handler for storing address of MeasData in rbCb at right index.
+ *
+ *  @param[in] 
+ *  @param[out] 
+ *  @param[in] 
+ *
+ *
+ *  @return  S16
+ *      -# ROK
+ */
+#ifdef ANSI
+PUBLIC Void pjUtlPlcMeasDatInUlL2Sts
+(
+PjL2Cntr       *measData, 
+PjL2MeasRbCb   *rbL2Cb,
+U8             measType
+)
+#else
+PUBLIC Void pjUtlPlcMeasDatInUlL2Sts(measData, rbL2Cb, measType)
+PjL2Cntr       *measData; 
+PjL2MeasRbCb   *rbL2Cb;
+U8             measType;
+#endif
+{
+   TRC3(pjUtlPlcMeasDatInUlL2Sts)
+   
+   /* We should check the number of measType in the request. This can be done 
+    * by looking at each bit in the measType. Also store the measData in the 
+    * correct index of l2Sts in RbCb.
+    * */
+
+    if(measType & LPJ_L2MEAS_UL_LOSS)
+    {
+         rbL2Cb->l2Sts[PJ_L2MEAS_UL_LOSS] = measData;
+    }
+
+}/* End of pjUtlPlcMeasDatInUlL2Sts */
+#endif /* LTE_L2_MEAS */
+
+
+/**
+@brief 
+This function processes Data Resume request received from the Application.
+ *  @param[in] gCb      PDCP Instance Control block 
+ *  @param[in] ueCb     Uplink UeCb 
+ *  @return S16
+ *      -# Success : ROK
+ *      -# Failure : RFAILED
+*/
+#ifdef ANSI
+PUBLIC S16 pjUtlUlPrcsDatResume
+(
+PjCb                 *gCb,
+CpjDatResumeReqInfo  *datResReq
+)
+#else
+PUBLIC S16 pjUtlUlPrcsDatResume(gCb, datResReq)
+PjCb                 *gCb;
+CpjDatResumeReqInfo  *datResReq;
+#endif
+{
+   U8 rbCnt;
+   PjUlRbCb *pjRbCb = NULLP;
+   PjUlUeCb *ueCb= NULLP;
+   
+   pjDbmFetchUlUeCb(gCb, datResReq->ueId, datResReq->cellId, &ueCb);
+   if(!ueCb)
+   {
+      RLOG_ARG1(L_ERROR, DBG_CELLID, datResReq->cellId,"UeId[%u] not found",
+            datResReq->ueId);
+      RETVALUE(RFAILED);
+   }   
+
+   for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt ++)
+   {
+      /* Check of rbCb available */
+      if( (pjRbCb = ueCb->drbCb[rbCnt]) == NULLP)
+      {
+         continue;
+      }
+#ifdef LTE_L2_MEAS
+      pjRbCb->ulCb.nxtSubSn = (pjRbCb->ulCb.rxNext % (1 << pjRbCb->snLen));
+#endif
+
+      /* Process the packets in dlPktQ */
+      pjUlmProcessUlPktQ(gCb, pjRbCb);
+      pjRbCb->state = PJ_STATE_NORMAL;
+   }
+   ueCb->libInfo.state = PJ_STATE_NORMAL;
+   RETVALUE(ROK);
+}
+
+PUBLIC Void pjUtlEmptyUlPktList(PjCb *gCb, PjUlRbCb *pjRbCb)
+{
+   PjUlPkt *ulPkt;
+   CmLListCp *ulPktLst = &pjRbCb->ulCb.ulPktLst;
+   while(ulPktLst->first)
+   {
+      ulPkt = (PjUlPkt *)(ulPktLst->first->node);
+      cmLListDelFrm(ulPktLst, ulPktLst->first);
+      PJ_FREE_BUF(ulPkt->pdu);
+      PJ_FREE(gCb, ulPkt, sizeof(PjUlPkt));
+   }
+   RETVOID;
+}
+
+void dumpPDCPUlRbInformation(PjUlRbCb* ulRbCb, U16 ueId)
+{
+   PjUlCb* ulCb = &ulRbCb->ulCb;
+
+#ifndef ALIGN_64BIT
+   RTLIN_DUMP_DEBUG("UE [%u] PDCP UL RB numEntries = %lu\n",ueId, ulCb->recBuf.numEntries);
+#else
+   RTLIN_DUMP_DEBUG("UE [%u] PDCP UL RB numEntries = %u\n",ueId, ulCb->recBuf.numEntries);
+#endif
+}
+
+
+void DumpPDCPUlDebugInformation(void)
+{
+   PjCb* ulInst = pjCb[0]; /* TODO: check whether UL is 0 or 1 */
+
+   PjUlgCb* ulgCb = ulInst->u.ulCb;
+
+   PjUlUeCb *ueCb = NULLP; 
+   RTLIN_DUMP_DEBUG("PDCP UL Information\n");
+   RTLIN_DUMP_DEBUG("===================\n");
+   
+   /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
+   while (ROK == cmHashListGetNext(&ulgCb->ueLstCp, 
+                                   (PTR) ueCb, 
+                                   (PTR *)&ueCb))
+   {
+      U32 i;
+      for(i = 0; i < PJ_MAX_SRB_PER_UE; i++)
+      {
+         PjUlRbCb* rbCb = ueCb->srbCb[i];
+         if(rbCb != NULLP)
+         {
+            dumpPDCPUlRbInformation(rbCb, ueCb->key.ueId);
+         }
+      }
+      for(i = 0; i < PJ_MAX_DRB_PER_UE; i++)
+      {
+         PjUlRbCb* rbCb = ueCb->drbCb[i];
+         if(rbCb != NULLP)
+         {
+            dumpPDCPUlRbInformation(rbCb, ueCb->key.ueId);
+         }
+      }
+   }/* end while */   
+}
+
+#ifdef TENB_DPDK_BUF
+
+#ifdef ANSI
+PUBLIC S16 pjUpdRxEntBuf
+(
+PjRxEnt    *rxEnt
+)
+#else
+PUBLIC S16 pjUpdRxEntBuf(rxEnt)
+PjRxEnt    *rxEnt;
+#endif
+{
+   MsgLen    msgLen;
+   Data      *dpdkFBuf;
+
+#define PDCP_NW_OFFSET 8
+
+   TRC2(pjUpdRxEntBuf)
+
+
+   RETVALUE(ROK);
+}
+
+#endif  /* TENB_DPDK_BUF */
+#ifdef ANSI
+PRIVATE S16 pjUtlUlHdlSecInitCfm
+(
+PjCb        *gCb,              /* Pointer to PJ DL Control Block */
+PjUlUeCb      *ueCb,           /* Pointer to UeCb */ 
+U16         txIdx,             /* Transaction Index for UeCb */
+PjAsyncCfm       *asyncCfm,    /* Async Confirm */
+CpjSecCfgCfmInfo *secCfgCfm,   /* Security config confirm */
+CpjReEstCfmInfo  *reEstCfm     /* Reest config confirm */
+)
+#else
+PRIVATE S16 pjUtlUlHdlSecInitCfm(gCb,ueCb,txIdx, asyncCfm,secCfgCfm,reEstCfm)
+(                              
+PjCb        *gCb;              /* Pointer to PJ DL Control Block */
+PjUlUeCb      *ueCb;           /* Pointer to UeCb */ 
+U16         txIdx;             /* Transaction Index for UeCb */
+PjAsyncCfm       *asyncCfm;    /* Async Confirm */
+CpjSecCfgCfmInfo *secCfgCfm;   /* Security config confirm */
+CpjReEstCfmInfo  *reEstCfm;    /* Reest config confirm */
+)
+#endif   
+{
+   TRC3(pjUtlUlHdlSecInitCfm)
+
+   if(asyncCfm->libInitBitMask == 0)
+   {
+      PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx);
+      if(ueCb->libInfo.state == PJ_STATE_NORMAL)
+      {
+         /* Send security config confirm */
+         PJ_ALLOC(gCb,secCfgCfm, sizeof(CpjSecCfgCfmInfo));
+#if (ERRCLASS & ERRCLS_DEBUG)
+         if (secCfgCfm == NULLP)
+         {
+            RLOG0(L_FATAL, "Memory Allocation failed.");
+            RETVALUE(RFAILED);
+         }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+         PJ_FILL_SEC_CFM_INFO(secCfgCfm, asyncCfm);
+
+         PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+         PjUiCpjSecCfgCfm(&gCb->u.ulCb->cpjSap.pst, gCb->u.ulCb->cpjSap.suId, secCfgCfm);
+      }
+      else if(ueCb->libInfo.state == PJ_STATE_REEST)
+      {
+         /* Send ReEstCfm */
+         PJ_ALLOC(gCb,reEstCfm, sizeof(CpjReEstCfmInfo));
+#if (ERRCLASS & ERRCLS_DEBUG)
+         if (reEstCfm == NULLP)
+         {
+            RLOG0(L_FATAL, "Memory Allocation failed.");
+            RETVALUE(RFAILED);
+         }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+
+         PJ_FILL_REEST_CFM_INFO(reEstCfm, asyncCfm, LCM_PRIM_OK);
+
+         /* Some house keeping work */
+         PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+#ifdef PJ_SEC_ASYNC            
+         /*Change the state from REEST to NORMAL*/
+         ueCb->libInfo.reEstCfmSent = TRUE;
+#endif
+         PjUiCpjReEstCfm(&gCb->u.ulCb->cpjSap.pst, gCb->u.ulCb->cpjSap.suId, reEstCfm);
+      }
+   }
+
+ RETVALUE(ROK);
+}
+
+
+#ifdef ANSI
+PRIVATE S16 pjUtlUlHdlCmpInitCfm
+(
+PjCb           *gCb,            /* Pointer to PJ DL Control Block */
+PjUlUeCb       *ueCb,           /* Pointer to UeCb */ 
+U16            txIdx,           /* Transaction Index for UeCb */
+PjAsyncCfm     *asyncCfm,       /* Async Confirm */
+CpjCfgCfmInfo  *cfgCfm         /* UDX Config Confirm */
+)
+#else
+PRIVATE S16 pjUtlUlHdlCmpInitCfm(gCb,ueCb,txIdx,asyncCfm,cfgCfm)
+(                              
+PjCb           *gCb;            /* Pointer to PJ DL Control Block */
+PjUlUeCb       *ueCb;           /* Pointer to UeCb */ 
+U16            txIdx;           /* Transaction Index for UeCb */
+PjAsyncCfm     *asyncCfm;       /* Async Confirm */
+CpjCfgCfmInfo  *cfgCfm;         /* UDX Config Confirm */
+)
+#endif   
+{
+   U32               idx;
+
+   TRC3(pjUtlUlHdlCmpInitCfm)
+
+      if(asyncCfm->cmpInitBitMask == 0)
+      {
+         asyncCfm->libInitBitMask ^= (PJ_LIB_COMP_BIT_MASK);
+
+         if((asyncCfm->libInitBitMask == 0) &&
+               !(asyncCfm->cfmType & PJ_CFG_REEST_ASYNC_CFM))
+         {
+
+            /* Send config confirm */
+            PJ_ALLOC(gCb,cfgCfm, sizeof(CpjCfgCfmInfo));
+#if (ERRCLASS & ERRCLS_ADD_RES)
+            if (cfgCfm == NULLP)
+            {
+               RLOG0(L_FATAL, "Memory Allocation failed.");
+               RETVALUE(RFAILED);
+            }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+            cfgCfm->transId = asyncCfm->transId;
+            cfgCfm->ueId    = asyncCfm->ueId;
+            cfgCfm->cellId  = asyncCfm->cellId;
+            cfgCfm->numEnt  = asyncCfm->numEnt; 
+            for ( idx = 0; idx < asyncCfm->numEnt; idx++ )
+            {
+               cfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status;  
+               cfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason;  
+               cfgCfm->cfmEnt[idx].rbId   = asyncCfm->cfmEnt[idx].rbId;
+               cfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType;
+            }
+
+            /* Some house keeping work */
+            PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx);
+            PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
+
+            /* Send confirmtion to the User */
+            PjUiCpjCfgCfm(&(gCb->u.ulCb->cpjSap.pst), gCb->u.ulCb->cpjSap.suId, cfgCfm);
+         }
+      }
+   RETVALUE(ROK);
+}   
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_ulm.c b/src/5gnrpdcp/pj_ulm.c
new file mode 100755 (executable)
index 0000000..29d0a50
--- /dev/null
@@ -0,0 +1,3085 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/**********************************************************************
+
+     Name:     LTE-PDCP Layer 
+  
+     Type:     C file
+  
+     Desc:     Source code for PDCP Uplink module.
+               This file contains following functions
+                  -- pjUlmHdlSrbPkt
+                  -- pjUlmHdlDrbPkt
+                  -- pjUlmProcessRb
+                  -- pjUlmDeliverSrb
+                  -- pjUlmDeliverDrbUm
+                  -- pjUlmDeliverDrbAm
+                  -- pjUlmReEstSrb
+                  -- pjUlmReEstDrbAm
+                  -- pjUlmBldStaRep
+                  -- pjUlmHdlDatFwdReq
+                  -- pjUlmHdlObdTmrExpiry
+
+     File:     pj_ulm.c
+
+**********************************************************************/
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_FILE_ID=245;
+static int RLOG_MODULE_ID=1024;
+/** @file pj_ulm.c
+@brief PDCP Uplink module
+*/
+
+/* header (.h) include files */
+#include "envopt.h"             /* environment options */
+#include "envdep.h"             /* environment dependent */
+#include "envind.h"             /* environment independent */
+
+#include "gen.h"                /* general */
+#include "ssi.h"                /* system services interface */
+#include "cm5.h"                /* Timer Functions */
+#include "cm_lte.h"             /* common LTE header file */
+#include "cm_hash.h"            /* common hash module  file */
+#include "cm_llist.h"           /* common list header file */
+#include "cpj.h"                /* RRC layer */
+#include "pju.h"                /* PDCP service user */
+#include "lpj.h"                /* RRC layer */
+#include "pj_env.h"             /* RLC environment options */
+#include "pj.h"                 /* RLC layer */
+#include "pj_ul.h"
+#include "pj_err.h"
+#include "pj_ptsec.h"
+
+
+
+/* header/extern include files (.x) */
+
+#include "gen.x"                /* general */
+#include "ssi.x"                /* system services interface */
+#include "cm_lib.x"             /* common library */
+#include "cm5.x"                /* Timer Functions */
+#include "cm_hash.x"            /* common hash module */
+#include "cm_lte.x"             /* common LTE file */
+#include "cm_llist.x"           /* common list header file */
+#include "cpj.x"                /* RRC layer */
+#include "pju.x"                /* PDCP service user */
+#include "lpj.x"                /* LM Interface */
+#include "pj.h"                /* LM Interface */
+#include "pj.x"                 /* RLC layer */
+#include "pj_udx.h"
+#include "pj_udx.x"
+#include "pj_dl.x"
+#include "pj_ul.x"
+\f
+/* local defines */
+
+/* local externs */
+#ifdef TENB_AS_SECURITY
+EXTERN U8 isSecBatchMode;
+#endif
+
+/* forward references */
+PUBLIC S16 pjUtlChekTxEnqReq(PjCb *gCb, PjDlRbCb *pjRbCb, PjTxEnt *txEnt);
+PUBLIC S16 pjUtlChekRxEnqReq(PjCb *gCb, PjUlRbCb *pjRbCb, PjRxEnt *rxEnt);
+
+/* public variable declarations */
+
+/* This structure holds all the global structs we need. */
+
+/* private variable declarations */
+
+/* private function declarations */
+
+PRIVATE S16 pjUlmDrbFetchSn 
+(
+PjCb     *gCb,
+PjUlRbCb *pjRbCb,               /* !< PDCP Control Block */      
+Buffer   *pdu,                    /* !< PDU Buffer */ 
+U8        hdrByte,               /* !< one byte extracted from pdu */
+PjSn     *sn                     /* PDCP SN*/
+);
+PRIVATE S16 pjUlmProcessRb
+(
+PjCb     *gCb,
+PjUlRbCb   *pjRbCb,          /* !< PDCP Control Block */   
+PjSn       rcvdSn,               /* !< SN value of PDU */           
+Buffer   *pdu,              /* !< PDU message buffer */           
+Bool     isOutOfSeq         /* !< To indicate whether packet received is in-sequence or not */
+);
+/** @addtogroup uldata */
+/*@{*/
+
+/*****************************************************************************
+ *    HEADER PARSING FUNCTIONS
+ ****************************************************************************/
+
+PRIVATE Void pjUlmEnqueueUlPkt ARGS(( PjCb *gCb, PjUlRbCb   *pjRbCb,PjSn      sn, Buffer   *pdu));
+
+
+
+PUBLIC S16 pjUlmHndlDlFdbk ARGS ((
+PjCb     *gCb,
+PjUlRbCb   *pjRbCb,
+Buffer   *mBuf
+));
+/**
+ *
+ * @brief 
+ *
+ *        Function to extract the SRB header.
+ *
+ * @b Description: 
+ *
+ *        This function extracts the SN and the MAC-I from the pdu buffer and
+ *        places them in the SrbHdr structure.
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @param[in] pdu      PDU to be processed
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUlmHdlSrbPkt
+(
+PjCb   *gCb,
+PjUlRbCb *pjRbCb,               /* !< PDCP Control Block */  
+Buffer *pdu                   /* !< PDU Buffer */ 
+)
+#else
+PUBLIC S16 pjUlmHdlSrbPkt(gCb, pjRbCb, pdu)
+PjCb    *gCb;
+PjUlRbCb  *pjRbCb;               /* !< PDCP Control Block */      
+Buffer  *pdu;                  /* !< PDU Buffer */ 
+#endif
+{
+   S16    ret     = ROK;    /* Return Value */
+   PjSn   sn;               /* SN value */
+   U8     hdrByte;          /* First byte storing hdr values */
+   U8     res;              /* Reserved values */
+
+   TRC2(pjUlmHdlSrbPkt);
+
+
+   /* Initialistaions */
+
+   /* Get the first byte */
+   ret = SRemPreMsg(&hdrByte, pdu);
+#if (ERRCLASS & ERRCLS_DEBUG)
+   if (ret != ROK)
+   {
+      RLOG_ARG0(L_ERROR, DBG_UEID,pjRbCb->ueCb->key.ueId," SRemPreMsg Failed ");
+      PJ_FREE_BUF(pdu);
+      PJ_STS_INC_GEN_CNT(gCb,errorPdusRecv);
+      RETVALUE(RFAILED);
+   }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+
+   /* Verify that reserved values are zero */
+   res = (hdrByte >> 4);
+   if(res != 0)
+   {
+      RLOG_ARG0(L_ERROR,DBG_UEID,pjRbCb->ueCb->key.ueId,
+                     "Reserved Values Non-zero ");
+      PJ_FREE_BUF(pdu);
+      PJ_STS_INC_GEN_CNT(gCb,errorPdusRecv);
+      RETVALUE(RFAILED);
+   }
+
+   /* Directly assigning since the reserved values are zero */
+   sn = hdrByte;
+   sn = sn << PJ_BYTE_SIZE;
+   ret = SRemPreMsg(&hdrByte, pdu);
+#if (ERRCLASS & ERRCLS_DEBUG)
+   if (ret != ROK)
+   {
+      PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_ERROR),
+            (gCb->init.prntBuf," SRemPreMsg Failed \n"));
+      RETVALUE(RFAILED);
+   }
+#endif
+   sn |= hdrByte;
+
+   /* Start processing */
+   ret =  pjUlmProcessRb(gCb, pjRbCb, sn, pdu, FALSE);
+
+   RETVALUE(ret);
+}/* pjUlmHdlSrbPkt */
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to forward the status report to PDCP-DL.
+ *
+ * @b Description: 
+ *
+ *        1. This function is called when a status report is received from the
+ *        peer.    @n
+ *        2. This function forwards the status report to PDCP-DL.  @n
+ *            
+ *  @param[in] pjRbCb      PDCP control block. 
+ *  @param[in] staPdu      Status report.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUlmHndlDlStaRep
+(
+PjCb     *gCb,
+PjUlRbCb   *pjRbCb,
+PjSn     fmc,
+Buffer   *staPdu
+)
+#else
+PUBLIC S16 pjUlmHndlDlStaRep(gCb, pjRbCb, fmc, staPdu)
+PjCb     *gCb;
+PjUlRbCb   *pjRbCb;
+PjSn     fmc,
+Buffer   *staPdu;
+#endif
+{
+   UdxDlStaRepInfo      *staRep;
+   PjUdxUlSapCb         *udxSap;
+   S16                  ret = ROK;           /* Return Value */
+   
+   TRC3(pjUlmHndlDlStaRep)
+
+   udxSap = PJ_GET_UL_UDX_SAP(gCb);
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst ,staRep,
+                     sizeof (UdxUlStaRepInfo), ret);
+   if(ret != ROK)
+   {
+      staRep = NULLP;
+   }
+
+   if (NULLP != staRep)
+   {
+      staRep->pdcpId.cellId = pjRbCb->ueCb->key.cellId;
+      staRep->pdcpId.ueId = pjRbCb->ueCb->key.ueId;
+      staRep->pdcpId.rbId = pjRbCb->rbId;
+      staRep->pdcpId.rbType = pjRbCb->rbType;
+      staRep->fmc = fmc;
+      staRep->staPdu = staPdu;
+      
+      PjUlUdxDlStaRep(&(udxSap->pst), udxSap->spId, staRep);
+   }
+   else
+   {
+      RETVALUE(RFAILED);
+   }
+
+   RETVALUE(ROK);
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to forward the ROHC feedback packet received from UE to PDCP-DL.
+ *
+ * @b Description: 
+ *
+ *        1. This function is called when a ROHC feedback packet received from
+ *        peer.    @n
+ *        2. This function forwards the ROHC feedback packet to PDCP-DL.  @n
+ *            
+ *  @param[in] gCb           global control block.
+ *  @param[in] pjRbCb      PDCP control block. 
+ *  @param[in] mBuf         ROHC feedback packet.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUlmHndlDlFdbk
+(
+PjCb     *gCb,
+PjUlRbCb   *pjRbCb,
+Buffer   *mBuf
+)
+#else
+PUBLIC S16 pjUlmHndlDlFdbk(gCb, pjRbCb, mBuf)
+PjCb     *gCb;
+PjUlRbCb   *pjRbCb;
+Buffer   *mBuf;
+#endif
+{
+   UdxDlFdbkPktInfo *fbPkt;
+   PjUdxUlSapCb     *udxSap;
+   S16              ret = ROK;
+   
+   TRC3(pjUlmHndlDlFdbk)
+   
+   udxSap = PJ_GET_UL_UDX_SAP(gCb);
+
+   PJ_ALLOC_BUF_SHRABL(udxSap->pst, fbPkt,
+      sizeof (UdxDlFdbkPktInfo), ret);
+   if(ret != ROK)
+   {
+      fbPkt = NULLP;
+   }
+
+   if (NULLP != fbPkt)
+   {
+      fbPkt->pdcpId.cellId = pjRbCb->ueCb->key.cellId;
+      fbPkt->pdcpId.ueId = pjRbCb->ueCb->key.ueId;
+      fbPkt->pdcpId.rbId = pjRbCb->rbId;
+      fbPkt->pdcpId.rbType = pjRbCb->rbType;
+
+      fbPkt->fbPkt= mBuf;
+      
+      PjUlUdxDlFdbkPktInfo(&(udxSap->pst), udxSap->spId, fbPkt);
+   }
+   else
+   {
+      RETVALUE(RFAILED);
+   }
+
+   RETVALUE(ROK);
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Function to extract the DRB SN from hdr.
+ *
+ * @b Description: 
+ *
+ *        This function extracts the SN in case of a data packet 
+ *
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @param[in] pdu      PDU to be processed
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PRIVATE S16 pjUlmDrbFetchSn 
+(
+PjCb     *gCb,
+PjUlRbCb *pjRbCb,               /* !< PDCP Control Block */      
+Buffer   *pdu,                    /* !< PDU Buffer */ 
+U8        hdrByte,               /* !< one byte extracted from pdu */
+PjSn     *sn                     /* PDCP SN*/
+)
+#else
+PRIVATE S16 pjUlmDrbFetchSn(gCb, pjRbCb, pdu, hdrByte, sn)
+PjCb     *gCb;
+PjUlRbCb *pjRbCb;               /* !< PDCP Control Block */      
+Buffer   *pdu;                    /* !< PDU Buffer */ 
+U8        hdrByte;              /* !< one byte extracted from pdu */
+PjSn     *sn;                   /* PDCP SN*/
+#endif
+{
+   U8     res;              /* Reserved values */
+   S16    ret     = ROK;    /* Return Value */
+   /* Pack the SN */
+
+   if (pjRbCb->snLen == PJ_12_BIT_SN) /* Its 12 bit */ 
+   {
+      /* Verify that reserved values are zero */
+      res = (hdrByte >> 4);
+      if (res != 8)
+      {
+         PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_ERROR),
+               (gCb->init.prntBuf," Reserved Values Non-zero \n"));
+         RETVALUE(RFAILED);
+      }
+
+      *sn = (hdrByte & PJ_12_BIT_SN_MSB_MASK); /*KW_FIX*/
+      *sn = *sn << PJ_BYTE_SIZE;
+      ret = SRemPreMsg(&hdrByte, pdu);
+#if (ERRCLASS & ERRCLS_DEBUG)
+      if (ret != ROK)
+      {
+         PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_ERROR),
+               (gCb->init.prntBuf," SRemPreMsg Failed \n"));
+         RETVALUE(RFAILED);
+      }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+      *sn |= hdrByte;
+   }
+   else if (pjRbCb->snLen == PJ_18_BIT_SN)
+   {
+      *sn = ((hdrByte & PJ_18_BIT_SN_MSB_MASK)); /*KW_FIX*/
+      *sn = *sn << PJ_BYTE_SIZE;
+      ret = SRemPreMsg(&hdrByte, pdu);
+#if (ERRCLASS & ERRCLS_DEBUG)
+      if (ret != ROK)
+      {
+         PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_ERROR),
+               (gCb->init.prntBuf," SRemPreMsg Failed \n"));
+         RETVALUE(RFAILED);
+      }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+      *sn |= hdrByte;
+      *sn = *sn << PJ_BYTE_SIZE;
+      ret = SRemPreMsg(&hdrByte, pdu);
+#if (ERRCLASS & ERRCLS_DEBUG)
+      if (ret != ROK)
+      {
+         PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_ERROR),
+               (gCb->init.prntBuf," SRemPreMsg Failed \n"));
+         RETVALUE(RFAILED);
+      }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+      *sn |= hdrByte;
+   }
+
+   RETVALUE(ret);
+}
+
+/**
+ *
+ * @brief 
+ *
+ *        Function to extract the FMC.
+ *
+ * @b Description: 
+ *
+ *        This function extracts the FMC and Bitmap incase of a 
+ *        PDCP status packet places them in the DrbHdr structure.
+ *
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @param[in] pdu      PDU to be processed
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmGetFmc
+(
+U8       hdrByte,
+PjUlRbCb *pjRbCb,               /* !< PDCP Control Block */      
+Buffer *pdu,                    /* !< PDU Buffer */ 
+U32      *fmc              
+)
+#else
+PUBLIC S16 pjUlmGetFmc(hdrByte,pjRbCb, pdu, fmc)
+U8        hdrByte;
+PjUlRbCb *pjRbCb;               /* !< PDCP Control Block */      
+Buffer *pdu;                    /* !< PDU Buffer */ 
+U32     *fmc;             
+#endif
+{
+   
+   S16    ret     = ROK;
+   TRC2(pjUlmGetFmc)
+   ret = SRemPreMsg(&hdrByte, pdu);
+#if (ERRCLASS & ERRCLS_DEBUG)
+         if(ret != ROK)
+         {
+            RLOG_ARG0(L_DEBUG, DBG_UEID,pjRbCb->ueCb->key.ueId,"SRemPreMsg Failed");
+            PJ_FREE_BUF(pdu);
+            RETVALUE(RFAILED);
+         }
+#endif
+         *fmc = hdrByte;
+         *fmc = *fmc << PJ_BYTE_SIZE;
+         ret = SRemPreMsg(&hdrByte, pdu);
+#if (ERRCLASS & ERRCLS_DEBUG)
+         if(ret != ROK)
+         {
+            RLOG_ARG0(L_DEBUG, DBG_UEID,pjRbCb->ueCb->key.ueId,"SRemPreMsg Failed");
+
+            PJ_FREE_BUF(pdu);
+            RETVALUE(RFAILED);
+         }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+         *fmc   |=  hdrByte;
+         *fmc = *fmc << PJ_BYTE_SIZE;
+         ret = SRemPreMsg(&hdrByte, pdu);
+#if (ERRCLASS & ERRCLS_DEBUG)
+         if(ret != ROK)
+         {
+            RLOG_ARG0(L_DEBUG, DBG_UEID,pjRbCb->ueCb->key.ueId,"SRemPreMsg Failed");
+
+            PJ_FREE_BUF(pdu);
+            RETVALUE(RFAILED);
+         }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+         *fmc   |=  hdrByte;
+         *fmc = *fmc << PJ_BYTE_SIZE;
+         ret = SRemPreMsg(&hdrByte, pdu);
+#if (ERRCLASS & ERRCLS_DEBUG)
+         if(ret != ROK)
+         {
+            RLOG_ARG0(L_DEBUG, DBG_UEID,pjRbCb->ueCb->key.ueId,"SRemPreMsg Failed");
+
+            PJ_FREE_BUF(pdu);
+            RETVALUE(RFAILED);
+         }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+         *fmc   |=  hdrByte;
+         RETVALUE(ret);
+
+}
+
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function to extract the DRB header.
+ *
+ * @b Description: 
+ *
+ *        This function extracts the SN in case of a data packet 
+ *        or feedback packet and the FMS and Bitmap incase of a 
+ *        PDCP status packet places them in the DrbHdr structure.
+ *
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @param[in] pdu      PDU to be processed
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmHdlDrbPkt
+(
+PjCb   *gCb,
+PjUlRbCb *pjRbCb,               /* !< PDCP Control Block */      
+Buffer *pdu,                    /* !< PDU Buffer */ 
+Bool    isOutOfSeq              /*!< To indicate whether this packet is in-sequence or not */
+)
+#else
+PUBLIC S16 pjUlmHdlDrbPkt(gCb, pjRbCb, pdu, isOutOfSeq)
+PjCb   *gCb;
+PjUlRbCb *pjRbCb;               /* !< PDCP Control Block */      
+Buffer *pdu;                    /* !< PDU Buffer */ 
+Bool    isOutOfSeq;             /* !< To indicate whether this packet is in-sequence or not */
+#endif
+{
+   S16    ret     = ROK;    /* Return Value */
+   PjSn   sn = 0;               /* SN value */
+   U8     hdrByte;          /* First byte storing hdr values */
+   U8     pduType;          /* Type of PDU */
+   U8     res;              /* Reserved values */
+   U32    fmc;              /*First Missing Count 5G Nr*/
+
+   TRC2(pjUlmHdlDrbPkt)
+#ifndef RGL_SPECIFIC_CHANGES
+#ifndef TENB_ACC
+#ifndef LTE_PAL_ENB
+extern U32 ulrate_kwu;
+MsgLen len;
+SFndLenMsg(pdu, &len);
+ulrate_kwu += len;
+#endif
+#endif
+#endif
+   /* Get the first byte */
+   ret = SRemPreMsg(&hdrByte, pdu);
+#if (ERRCLASS & ERRCLS_DEBUG)
+   if (ret != ROK)
+   {
+      RLOG_ARG0(L_DEBUG, DBG_UEID,pjRbCb->ueCb->key.ueId," SRemPreMsg Failed ");
+      PJ_FREE_BUF(pdu);
+      PJ_STS_INC_GEN_CNT(gCb,errorPdusRecv);
+      RETVALUE(RFAILED);
+   }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+
+   /* check if its a data PDU */
+   if((hdrByte & PJ_TYPE_DRB_DATA) == PJ_TYPE_DRB_DATA)
+   {
+      ret = pjUlmDrbFetchSn (gCb, pjRbCb, pdu, hdrByte, &sn);
+#if (ERRCLASS & ERRCLS_DEBUG)
+      if (ret != ROK)
+      {
+         PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_ERROR),
+               (gCb->init.prntBuf," Failed to extract SN from PDU\n"));
+         PJ_FREE_BUF(pdu);
+         PJ_STS_INC_GEN_CNT(gCb,errorPdusRecv);
+         RETVALUE(RFAILED);
+      }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+
+      /* Call the processing function */
+      if(pjRbCb->mode == PJ_DRB_AM)
+      {
+         if (pjRbCb->state == PJ_STATE_HO)
+         {
+             pjUlmEnqueueUlPkt(gCb,pjRbCb,sn,pdu);
+         }
+         else
+         {
+           ret = pjUlmProcessRb(gCb, pjRbCb, sn, pdu, isOutOfSeq);
+         }
+      }
+      else /* (pjRbCb->type == PJ_DRB_UM) */
+      {
+         ret = pjUlmProcessRb(gCb, pjRbCb, sn, pdu, FALSE);
+      }
+   }
+   else  /* Its a control PDU */
+   {
+
+      pduType =  (U8)((hdrByte & PJ_PDU_BIT_MASK) >> 4);  /*KW_FIX*/
+
+      if(pduType == PJ_TYPE_STATUS_REPORT)
+      {
+         pjUlmGetFmc(hdrByte,pjRbCb,pdu,&fmc);
+         ret = pjUlmHndlDlStaRep(gCb, pjRbCb, fmc, pdu);
+         if (ret != ROK)
+         {
+            RLOG_ARG0(L_DEBUG,DBG_UEID,pjRbCb->ueCb->key.ueId,
+                          " pjUlmHndlDlStaRep() returned Failed ");
+            PJ_FREE_BUF(pdu);
+            RETVALUE(RFAILED);
+         }
+      }
+      else if(pduType == PJ_TYPE_ROHC_FEEDBACK)
+      {
+
+         /* validate that reserved values are 0*/
+         res  =  (U8)(hdrByte & PJ_CPDU_RES_VAL_MASK);  /*KW_FIX*/
+         if(res != 0)
+         {
+            RLOG_ARG0(L_DEBUG,DBG_UEID,pjRbCb->ueCb->key.ueId,
+                        " Reserved values non-null ");
+            PJ_FREE_BUF(pdu);
+            PJ_STS_INC_GEN_CNT(gCb,errorPdusRecv);
+            RETVALUE(RFAILED);
+         }
+
+         ret = pjUlmHndlDlFdbk(gCb, pjRbCb, pdu);
+         if (ret != ROK)
+         {
+            RLOG_ARG0(L_DEBUG,DBG_UEID,pjRbCb->ueCb->key.ueId,
+                  " pjUlmHndlDlStaRep() returned Failed ");
+            PJ_FREE_BUF(pdu);
+            RETVALUE(RFAILED);
+         }
+      }
+      else
+      {
+         /* Invalid PDU type */
+         RLOG_ARG0(L_DEBUG,DBG_UEID,pjRbCb->ueCb->key.ueId,
+                         " Invalid PDU Type ");
+         PJ_FREE_BUF(pdu);
+         PJ_STS_INC_GEN_CNT(gCb,errorPdusRecv);
+         RETVALUE(RFAILED);
+      }
+   }
+   RETVALUE(ret);
+}/* pjUlmHdlDrbPkt */
+
+/*****************************************************************************
+ *          PROCESSING FUNCTIONS
+ ****************************************************************************/
+/**
+ *
+ * @brief 
+ *
+ *        Function to process the PDCP RB Pdu and updates the state variables. 
+ *
+ * @b Description: 
+ *
+ *        This function performs the follwing steps:                       @n
+ *        1. Create and Insert the entry in the reception buffer.          @n
+ *        2. Check for firstSn in reestablish state.                       @n
+ *        3. Update nxtSubCnt and nxtSubDeCmp.                             @n
+ *        4. Call pjUtlDecipher to perform deciphering.                    @n
+ *        5. Call pjUtlDecomp to perform integrity verification.           @n
+ *        6. Call pjUlmDeliverDrbUm for performing state updations and 
+ *           submitting to upper layers.                                   @n
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @param[in] rcvdSn       SN value of the pdu
+ *  @param[in] pdu      PDU message buffer.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmProcessRb
+(
+PjCb     *gCb,
+PjUlRbCb   *pjRbCb,          /* !< PDCP Control Block */   
+PjSn       rcvdSn,               /* !< SN value of PDU */           
+Buffer   *pdu,              /* !< PDU message buffer */           
+Bool     isOutOfSeq         /* !< To indicate whether packet received is in-sequence or not */
+)
+#else
+PUBLIC S16 pjUlmProcessRb(gCb, pjRbCb, rcvdSn, pdu, isOutOfSeq)
+PjCb      *gCb;
+PjUlRbCb    *pjRbCb;         /* !< PDCP Control Block */     
+PjSn      rcvdSn;              /* !< SN value of PDU */           
+Buffer   *pdu;             /* !< PDU message buffer */           
+Bool     isOutOfSeq;         /* !< To indicate whether packet received is in-sequence or not */
+#endif
+{
+   PjUlCb       *ulCb;            /* PTR to UL Control Block     */
+   PjRxEnt      *rxEnt;           /* Ptr to Rx Entry             */
+   S16          ret      = ROK;   /* Return value                */
+   U32          rcvdCount;           /* Count value */
+   U32          rcvdHfn;
+   Bool         dupEntry;
+   U32          rxDelivHfn; 
+#ifdef PJ_SEC_ASYNC
+   U32          oldRxCnt;        /* Old Count value used for decomp */
+#endif
+    
+   TRC2(pjUlmProcessRb)
+
+   /* 1. Initialisations */
+   ulCb  = &pjRbCb->ulCb;
+
+   /*1.5G-NR Determine the Hfn and count value of the received PDCP data pdu*/
+   PJ_CALC_RCVD_HFN(rcvdSn,pjRbCb->snLen,ulCb->rxDeliv,rcvdHfn);
+
+   /*2.5G-NR Get the count value of the receiced PDCP data pdu from rcvdSn and rcvdHfn  */
+   PJ_GET_COUNT(rcvdCount, pjRbCb->snLen, rcvdSn, rcvdHfn);
+   
+
+   /* 3. Create the entry */
+   PJ_ALLOC(gCb,rxEnt, sizeof(PjRxEnt));
+#if (ERRCLASS & ERRCLS_DEBUG)
+   if(rxEnt == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+
+   /* 4. Fill values and Insert into hash list */
+   rxEnt->count   =  rcvdCount;
+   rxEnt->state   =  PJ_RDY_TO_DCIPHER;
+   rxEnt->mBuf    =  pdu;
+   rxEnt->lstEnt.next = NULLP;
+   rxEnt->lstEnt.prev = NULLP;
+   rxEnt->lstEnt.node = NULLP;
+   rxEnt->discFlag = rxEnt->dupEntry = 0;
+   rxEnt->isOutSeq = isOutOfSeq;
+   
+   PJ_GET_HFN(ulCb->rxDeliv,pjRbCb->snLen,rxDelivHfn)
+    
+   if((rcvdCount < ulCb->rxDeliv) &&(rxDelivHfn != PJ_MAX_HFN(pjRbCb->snLen)))
+   {
+      rxEnt->discFlag = TRUE;
+      PJ_FREE_BUF(rxEnt->mBuf);
+      PJ_FREE(gCb,rxEnt, sizeof(PjRxEnt));
+      RETVALUE(ROK);
+   }
+
+   ret = pjDbmInsRxEnt(gCb, &ulCb->recBuf, rxEnt, TRUE);
+   if(ret == ROKDUP)
+   {
+      /* Duplicates are not to be inserted */
+      /* marked to be freed up later */
+      rxEnt->dupEntry =  TRUE;
+   }
+   dupEntry = rxEnt->dupEntry;
+   
+   /* 7. Cleanup the duplicates */
+   if(dupEntry == TRUE)
+   {
+      /* duplicate entry, Need to add a counter to print it on console periodically */
+      PJ_FREE_BUF(rxEnt->mBuf);
+      PJ_FREE(gCb,rxEnt, sizeof(PjRxEnt));
+      RETVALUE(ROK);
+   }
+
+   /*3.Update the RX_NEXT */
+   PJ_ULM_UPDATE_RX_NEXT(pjRbCb,rxEnt);
+
+#ifdef PJ_SEC_ASYNC
+   oldRxCnt = ulCb->rxNext; 
+   PJ_ULM_UPD_NXT2DCOMP(ulCb, (pjRbCb->snLen), rcvdCount,oldRxCnt);
+   PJ_ULM_UPD_NXT2SUB(ulCb, rcvdCount); 
+#endif
+
+   /* 5. Update OBD count */
+   PJ_INC_OBD_COUNT(pjRbCb,rxEnt->count);
+
+   /* Check whether the received packet is in-sequence or not
+    * For every inSeq packet store the FMS Count value corresponding
+    * to the FMS + HFN now */
+   if((isOutOfSeq == FALSE) &&
+      (pjRbCb->rbType == PJ_DRB) &&  
+      (pjRbCb->mode == PJ_DRB_AM))
+   {
+      /*Need to be check again */
+      pjRbCb->ulCb.fmsCount = ulCb->rxNext ;  
+   }
+
+   /* 6. Send for deciphering */
+   ret = pjUlmHdlDecipher(gCb, pjRbCb, rxEnt);
+
+   RETVALUE(ret);
+}/* pjUlmProcessRb */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function is called when the offboard timer expires.
+ *
+ * @b Description: 
+ *
+ *    The function performs the following
+ *    1. If the SDU associated with the timer is not delivered, we 
+ *       delete the entry .                                              @n
+ *    2. A status indication is sent to the user with error cause.       @n
+ *    3. We associate the nextToSubmit value to the next SDU that has 
+ *       to be submitted.                                                @n
+ *    4. The timer is associated with the nextToSubmit SDU and restarted.@n
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @param[in] rxEnt    Rx Entry
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmHdlDecipher
+(
+PjCb       *gCb,
+PjUlRbCb     *pjRbCb,        /* !< PDCP Control Block */  
+PjRxEnt    *rxEnt          /* !< Rx Entry */
+)
+#else
+PUBLIC S16 pjUlmHdlDecipher(gCb, pjRbCb, rxEnt)
+PjCb       *gCb;
+PjUlRbCb     *pjRbCb;        /* !< PDCP Control Block */  
+PjRxEnt    *rxEnt;         /* !< Rx Entry */
+#endif
+{
+   PjUlCb   *ulCb;            /* ULM Control Block        */
+   S16       ret     = ROK;   /* Return values            */
+   Buffer   *mBuf    = NULLP; /* Output Buffer            */
+   PjSec     *secInfo;
+   U32        macI = 0;       /*5G_NR for DRB, its a 4 byte field */
+   TRC2(pjUlmHdlDecipher);
+
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ),
+         (gCb->init.prntBuf, "pjUlmHdlDecipher(pjRbCb(%d,%d),rxEnt(%ld)) \n", \
+          pjRbCb->rbId, pjRbCb->rbType, rxEnt->count));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ),
+         (gCb->init.prntBuf, "pjUlmHdlDecipher(pjRbCb(%d,%d),rxEnt(%d)) \n", \
+          pjRbCb->rbId, pjRbCb->rbType, rxEnt->count));
+#endif
+
+   /* 1. Initialistions */
+   ulCb  =  &pjRbCb->ulCb;
+
+   secInfo = &(pjRbCb->ueCb->secInfo); 
+   /* 2. Process for Deciphering */
+   if(secInfo->secAct == TRUE && secInfo->cipherInfo.algoType != 0)
+   {
+      /* 2.1 Check that it is not the first pkt, with selectively enabled */
+      if((pjRbCb->rbType == PJ_SRB) && 
+         (pjRbCb->ueCb->secInfo.firstMsg && pjRbCb->ueCb->secInfo.selSecAct))
+      {
+         /* first pkt */
+         pjRbCb->ueCb->secInfo.firstMsg   =  FALSE;
+      }
+      else
+      {
+#ifndef TENB_ACC 
+#ifndef LTE_PAL_ENB         
+         pjUtlChekRxEnqReq(gCb, pjRbCb, rxEnt);
+#endif         
+#endif         
+#ifdef SS_RBUF
+         if(rxEnt->rbCb)
+         {
+            RETVALUE(ROK);
+         }
+#endif
+         /* 2.3 call deciphering hook */
+         if( pjUtlDecipherReq(gCb, pjRbCb, rxEnt->count, rxEnt->mBuf, &mBuf) != ROK)
+         {
+            RLOG1(L_ERROR, "Deciphering Req failed Rx Count [%lu]", rxEnt->count);
+            PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt);
+            pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count);
+            PJ_STS_INC_GEN_CNT(gCb,numDeciphFails);
+            RETVALUE(RFAILED);
+         }
+
+         
+         /* 2.4 wait for output before processing further */
+    /* Batch Mode processing, Packets queued will be sent to spacc 
+       together upon trigger */
+#ifdef TENB_AS_SECURITY
+         if(isSecBatchMode)
+         {
+            rxEnt->state   =  PJ_SENT_TO_DCIPHER;
+            RETVALUE(ROK);       
+         }
+#endif
+
+#if defined (PJ_SEC_ASYNC) || defined (INTEL_QAT_DP)
+         /* 2.4 wait for output before processing further */
+         rxEnt->state   =  PJ_SENT_TO_DCIPHER;
+         RETVALUE(ROK);
+#else   /* PJ_SEC_ASYNC */
+         /* 2.3 Validate output of deciphering */
+         if(mBuf == NULLP)
+         {
+            RLOG1(L_ERROR, "Deciphering Req failed Rx Count [%lu]", rxEnt->count);
+            PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt);
+            pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count);
+            PJ_STS_INC_GEN_CNT(gCb,numDeciphFails);
+            RETVALUE(RFAILED);
+         }
+
+         /* 2.5 copy output buffer */
+#ifdef TENB_AS_SECURITY
+         /* If not batch mode, free PDU. If batch mode, free will be done upon
+         SPAcc return */
+         if(!(isSecBatchMode))
+         {
+            PJ_FREE_BUF(rxEnt->mBuf);
+         }
+#endif
+         rxEnt->mBuf     =  mBuf;
+#endif
+      }
+   }
+#ifdef TENB_DPDK_BUF
+   else if(pjRbCb->rbType == PJ_DRB)
+   {
+      pjUpdRxEntBuf(rxEnt);
+   }
+#endif
+   /* 3. Post ciphering updations */
+   if(pjRbCb->rbType == PJ_DRB)
+   {
+      rxEnt->state   =  PJ_RDY_TO_DCOMP;
+      /*Adding MACI for 5G NR for DRB in case of intergrity protection is enabled*/
+      if(pjRbCb->ueCb->secInfo.intProtEnbForDrb)
+      {
+         PJ_UNPK_MACI(rxEnt->mBuf, macI);
+      }
+      ret = pjUlmHdlDeCmp(gCb, pjRbCb, rxEnt);
+   }
+   else
+   {
+      rxEnt->state   =  PJ_RDY_TO_INTVER;
+      ret = pjUlmHdlIntVer(gCb, pjRbCb, rxEnt);
+   }
+
+   RETVALUE(ret);
+}/* end of pjUlmHdlDecipher */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function is called to perform integrity verification.
+ *
+ * @b Description: 
+ *
+ *    The function performs the following
+ *    1. Extract the mac-I.
+ *    2. Add sn to the buffer.
+ *    3. Call Integrity Verification hook.
+ *    4. Return in case of Async.
+ *    5. Validate output and submit for delivery.
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @param[in] rxEnt    Rx Entry
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmHdlIntVer
+(
+PjCb       *gCb,
+PjUlRbCb     *pjRbCb,        /* !< PDCP Control Block */  
+PjRxEnt    *rxEnt          /* !< Rx Entry */
+)
+#else
+PUBLIC S16 pjUlmHdlIntVer(gCb, pjRbCb, rxEnt)
+PjCb       *gCb;
+PjUlRbCb     *pjRbCb;        /* !< PDCP Control Block */  
+PjRxEnt    *rxEnt;         /* !< Rx Entry */
+#endif
+{
+   PjUlCb  *ulCb;          /* ULM Control Block */
+   PjSn     sn;            /* Sn Value */    /*KW_FIX*/
+   S16      ret = ROK;     /* Return value */
+   U32      macI = 0;      /* Mac-I value */
+   PjSecInp inParam;       /* Input Params */
+   Status   status = ROK;        /* Status of IntVer */
+
+   TRC2(pjUlmHdlIntVer);
+
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ),
+         (gCb->init.prntBuf, "pjUlmHdlIntVer(pjRbCb(%d,%d),rxEnt(%ld)) \n", \
+          pjRbCb->rbId, pjRbCb->rbType, rxEnt->count));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ),
+         (gCb->init.prntBuf, "pjUlmHdlIntVer(pjRbCb(%d,%d),rxEnt(%d)) \n", \
+          pjRbCb->rbId, pjRbCb->rbType, rxEnt->count));
+#endif
+
+   /* 1. Initialistions */
+   ulCb  =  &pjRbCb->ulCb;
+
+   /* 2. Xtract the last four bits irrescpective of whether you 
+    * are going to do integrity verification or not */
+
+   /* RANGELEY  Fix */
+#ifndef INTEL_QAT_DP
+   PJ_UNPK_MACI(rxEnt->mBuf, macI);
+#endif
+
+   /* 3. Process for Integrity Verification */
+   if(pjRbCb->ueCb->secInfo.secAct == TRUE && pjRbCb->ueCb->secInfo.intInfo.algoType != 0)
+   {
+
+      /* 3.1 Prepare the input Parameters */
+      inParam.dir    =  PJ_SEC_DIR_UL;
+      inParam.rbId   =  pjRbCb->rbId;
+      inParam.count  =  rxEnt->count;
+
+      /* 3.2. Add the SN to the buffer */
+      sn  =  (U32)(rxEnt->count % (1 << PJ_SRB_SN_LEN));  /*KW_FIX*/
+      ret = SAddPreMsg((Data)sn, rxEnt->mBuf);
+#if (ERRCLASS & ERRCLS_DEBUG)
+      if (ret != ROK)
+      {
+         RLOG_ARG0(L_ERROR, DBG_UEID,pjRbCb->ueCb->key.ueId,
+               " pjUlmProcessRb: SRemPreMsgMult Failed ");
+         pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count);
+         RETVALUE(RFAILED);
+      }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+
+      /* 3.3 call deciphering hook */
+      if( pjUtlIntVerReq(gCb, pjRbCb, inParam, rxEnt->mBuf, macI, &status) != ROK)
+      {
+         RLOG1(L_ERROR, "Integrity Verification Req failed Rx Count[%lu]", rxEnt->count);
+         ret = SRemPreMsg((Data *)&sn, rxEnt->mBuf);
+         if (ret != ROK)
+         {
+         }
+         PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt);
+         rxEnt->state = PJ_RX_INTVER_FAIL;
+         pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count);
+         PJ_STS_INC_GEN_CNT(gCb,numIntgVrfFails);
+         RETVALUE(RFAILED);
+      }
+#ifdef INTEL_QAT_DP   
+      /* 3.5 wait for output before processing further */
+      rxEnt->state   =  PJ_SENT_TO_INTVER;
+      RETVALUE(ROK);
+#else
+      /* 3.4. Remove the SN from the buffer */
+      ret = SRemPreMsg((Data *)&sn, rxEnt->mBuf);
+#if (ERRCLASS & ERRCLS_DEBUG)
+      if (ret != ROK)
+      {
+         RLOG1(L_ERROR, "SRemPreMsg failed  Rx Count [%lu]", rxEnt->count);
+         PJ_FREE_BUF(rxEnt->mBuf);
+         pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count);
+         RETVALUE(RFAILED);
+      }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+
+#ifdef PJ_SEC_ASYNC
+      /* 3.5 wait for output before processing further */
+      rxEnt->state   =  PJ_SENT_TO_INTVER;
+      RETVALUE(ROK);
+#else
+      /* 3.6 Post integrity verification updations */
+      if(status != ROK)
+      {
+         RLOG1(L_ERROR, "Integrity Verification Req failed Rx Count[%lu]", rxEnt->count);
+         PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt);
+         pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count);
+         PJ_STS_INC_GEN_CNT(gCb,numIntgVrfFails);
+         RETVALUE(RFAILED);
+      }
+
+#endif /* PJ_SEC_ASYNC */
+#endif /*INTEL_QAT_DP */
+   }
+#ifdef INTEL_QAT_DP
+   else 
+   {
+#endif
+      /* 4. Update state and send for delivery */
+      rxEnt->state   =  PJ_RDY_TO_SUBMIT;
+      ret = pjUlmDeliverSrb(gCb, pjRbCb, rxEnt);
+#ifdef INTEL_QAT_DP
+   }
+#endif
+
+   RETVALUE(ret);
+}/* end of pjUlmHdlIntVer */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function is called to handle decompression.
+ *
+ * @b Description: 
+ *
+ *    The function performs the following
+ *    1. Call decompression handler function.
+ *    2. For sync, validate output and submit for delivery.
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @param[in] rxEnt    Rx Entry
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmHdlDeCmp
+(
+PjCb       *gCb,
+PjUlRbCb     *pjRbCb,        /* !< PDCP Control Block */  
+PjRxEnt    *rxEnt          /* !< Rx Entry */
+)
+#else
+PUBLIC S16 pjUlmHdlDeCmp(gCb, pjRbCb, rxEnt)
+PjCb       *gCb;
+PjUlRbCb     *pjRbCb;        /* !< PDCP Control Block */  
+PjRxEnt    *rxEnt;         /* !< Rx Entry */
+#endif
+{
+   PjUlCb  *ulCb;          /* ULM Control Block */
+   Buffer  *mBuf = NULLP;  /* Output Buffer */
+
+   TRC2(pjUlmHdlDeCmp);
+
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ),
+          (gCb->init.prntBuf, "pjUlmHdlDeCmp(pjRbCb(%d,%d),rxEnt(%ld)) \n", \
+            pjRbCb->rbId, pjRbCb->rbType, rxEnt->count));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ),
+          (gCb->init.prntBuf, "pjUlmHdlDeCmp(pjRbCb(%d,%d),rxEnt(%d)) \n", \
+            pjRbCb->rbId, pjRbCb->rbType, rxEnt->count));
+#endif
+
+   /* 1. Initialistions */
+   ulCb  =  &pjRbCb->ulCb;
+
+   /* 2. process for decompression */
+   if(pjRbCb->rohc.hdrCmpUsed == TRUE)
+   {
+      /* 2.1 call decompression hook */
+      if(pjUtlDeCmpReq(gCb, pjRbCb,rxEnt->count, rxEnt->mBuf, &mBuf) != ROK)
+      {
+         RLOG1(L_ERROR, "DeCompression Req failed Rx Count[%lu]", rxEnt->count);
+         PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt);
+         pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count);
+         PJ_STS_INC_GEN_CNT(gCb,numDecmpFails);
+         RETVALUE(RFAILED);
+      }
+
+#ifdef PJ_CMP_ASYNC
+      /* 2.2 Wait for output before processing further */
+      rxEnt->state   =  PJ_SENT_TO_DCOMP;
+      RETVALUE(ROK);
+#else /* PJ_CMP_ASYNC */
+
+      /* 2.3 Validate output of decomp */
+      if(mBuf == NULLP)
+      {
+         RLOG1(L_ERROR, "DeCompression Req failed Rx Count[%lu]", rxEnt->count);
+         PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt);
+         pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count);
+         PJ_STS_INC_GEN_CNT(gCb,numDecmpFails);
+         RETVALUE(RFAILED);
+      }
+
+      /* 2.4 Copy output buffer */
+      PJ_FREE_BUF(rxEnt->mBuf);
+      rxEnt->mBuf     =  mBuf;
+#endif
+   }
+
+   /* 3. Return for discardable entries */
+   if((rxEnt->discFlag == TRUE) ||
+      (rxEnt->dupEntry == TRUE))
+   {
+      RLOG2(L_ERROR,"Dropping packets...discflag is [%d], dupEntry is [%d]", rxEnt->discFlag, rxEnt->dupEntry);
+      RETVALUE(ROK);
+   }
+
+   /* 4. Post decomp updations */
+   rxEnt->state   =  PJ_RDY_TO_SUBMIT;
+   PJ_DEC_OBD_COUNT(gCb, pjRbCb, rxEnt->count);
+   PJ_ULM_DELIVER_DRB(gCb,pjRbCb, rxEnt);
+
+   RETVALUE(ROK);
+}/* end of pjUlmHdlDeCmp */
+
+#ifdef ANSI
+PUBLIC S16 pjUlmDeliverPdu
+(
+PjCb   *gCb,
+PjUlRbCb *pjRbCb,           /* !< PDCP Control Block */                  
+PjRxEnt *rxEnt            /* !< Recption Buffer Entry   */             
+)
+#else
+PUBLIC S16 pjUlmDeliverPdu(gCb,pjRbCb, rxEnt)
+PjCb    *gCb;
+PjUlRbCb *pjRbCb;           /* !< PDCP Control Block */                  
+PjRxEnt *rxEnt;           /* !< Recption Buffer Entry   */             
+#endif
+{
+   PjUlCb   *ulCb;
+   PjRxEnt *tmpEnt;      /* Temp Entry - loop counter */
+   U32 rxReOrdHfn,rxNextHfn, rxDelivHfn;
+
+
+   TRC2(pjUlmDeliverPdu)
+
+   /* Initialisations */
+   ulCb           =  &pjRbCb->ulCb;
+   if(rxEnt->state != PJ_RDY_TO_SUBMIT)
+   {
+      /* PDU still under processing, return */
+      RETVALUE(ROK);
+   }
+   ulCb->outOfOrderDelivery = FALSE;
+
+   if(ulCb->outOfOrderDelivery == FALSE )
+   {
+
+      /* submit to upper layers and delete entry */
+      /* submit all the stored pdu's with consecutively associated COUNT value(s) starting from COUNT = RX_DELIV*/
+      if(rxEnt->count == ulCb->rxDeliv)
+      {
+         cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ);
+         if(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ))
+         {
+
+             tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ));
+            do
+            {
+                    PJ_SND_PJU_DAT_IND(gCb,pjRbCb, tmpEnt);
+                    pjDbmDelRxEnt(gCb, &ulCb->recBuf, tmpEnt->count);
+                    /*updating the stateVariable*/
+                    ulCb->rxDeliv      =   ulCb->rxDeliv + 1;
+                    cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ);
+                    if(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ) == NULLP)
+                    {
+                            break;
+                    }
+                    tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ));
+            }while(tmpEnt->count == ulCb->rxDeliv);
+        }
+      }
+   }
+   /*If out of order Delivery is configured*/
+   else
+   {
+      PJ_SND_PJU_DAT_IND(gCb,pjRbCb, rxEnt);
+      pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count);
+      /*updating the stateVariable*/
+      ulCb->rxDeliv      =   ulCb->rxDeliv + 1;
+
+   }
+   
+   /* Update the Reordering state variable reffer sec 5.2.2.2 of 38.323 */
+   Bool   tmrRunning;
+   PJ_GET_HFN(ulCb->rxDeliv,pjRbCb->snLen,rxDelivHfn);
+   tmrRunning = pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR);
+   if (tmrRunning)
+   {
+      PJ_GET_HFN(ulCb->rxDeliv,pjRbCb->snLen,rxReOrdHfn);
+     if ((ulCb->rxDeliv >= ulCb->rxReord) || 
+         ((PJ_MAX_HFN(pjRbCb->snLen) == rxReOrdHfn) &&
+          (0 == rxDelivHfn)))
+     {
+       pjStopTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR);
+       tmrRunning = FALSE;
+     }
+   }
+   
+  if (!tmrRunning)
+  {
+      PJ_GET_HFN(ulCb->rxNext, pjRbCb->snLen,rxNextHfn);
+     if ((ulCb->rxDeliv < ulCb->rxNext) || 
+         (((PJ_MAX_HFN(pjRbCb->snLen) == rxDelivHfn)) && 
+           (0 == rxNextHfn)))
+     {
+        ulCb->rxReord = ulCb->rxNext;
+        pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR);
+     }
+  }
+
+RETVALUE(ROK);
+}
+
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function to perform updations and deliver the SDU to the upper layer. 
+ *        It is called for SRBs .
+ *
+ * @b Description: 
+ *
+ *        This function performs the following functions,                    @n
+ *        1. Call PjUiPjuDatInd to deliver the SDU to the upper layer.       @n
+ *        2. In async mode, check if any subsequent SDUs can also be sent up.@n
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @param[in] rxEn     reception entry for the PDU
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmDeliverSrb
+(
+PjCb   *gCb,
+PjUlRbCb *pjRbCb,          /* !< PDCP Control Block */     
+PjRxEnt *rxEnt           /* !< Recption Buffer Entry   */            
+)
+#else
+PUBLIC S16 pjUlmDeliverSrb(gCb, pjRbCb, rxEnt)
+PjCb   *gCb;
+PjUlRbCb *pjRbCb;          /* !< PDCP Control Block */                  
+PjRxEnt *rxEnt;          /* !< Recption Buffer Entry   */             
+#endif
+{
+#ifdef PJ_SEC_ASYNC
+   PjUlCb     *ulCb;
+   U32      count;        /* Count for looping through the entries */
+   U32      nxtRxCnt;     /* Count for looping through the entries */
+   PjRxEnt  *tmpEnt;      /* Temp var for looping through the entries */
+#endif
+
+   TRC2(pjUlmDeliverSrb);
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ),
+          (gCb->init.prntBuf, "pjUlmDeliverSrb(pjRbCb(%d,%d),rxEnt(%ld)) \n", \
+            pjRbCb->rbId, pjRbCb->rbType, rxEnt->count));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ),
+          (gCb->init.prntBuf, "pjUlmDeliverSrb(pjRbCb(%d,%d),rxEnt(%d)) \n", \
+            pjRbCb->rbId, pjRbCb->rbType, rxEnt->count));
+#endif
+
+   /* Post integrity verification updations */
+#ifdef PJ_SEC_ASYNC
+   count          =  rxEnt->count;
+   ulCb           =  &pjRbCb->ulCb;
+#endif
+   pjUlmDeliverPdu(gCb,pjRbCb,rxEnt); 
+   
+#ifdef PJ_SEC_ASYNC
+   tmpEnt = NULLP;
+   /* Search and see if any of the successive SDUs can 
+    * also be sent to the upper layer */
+   count++;
+   nxtRxCnt  =  ulCb->rxNext;
+
+   /* Check till nxtRxCnt */
+   while(count < nxtRxCnt) 
+   {
+      /* Get the next node */
+      tmpEnt   =  (PjRxEnt *)pjDbmGetRxEnt(gCb, &ulCb->recBuf, count);
+      count ++;
+
+      if(tmpEnt == NULLP)
+      {
+         /* Such an entry does not exist, search for the next */
+         continue;
+      }
+      if(tmpEnt->state != PJ_RDY_TO_SUBMIT)
+      {
+         /* Integrity verification not yet done so we have to wait */
+         ulCb->nxtSubCnt =  tmpEnt->count;
+         /* Cant send anymore messages up, break*/
+         break;
+      }
+      else
+      {
+         /* call the PJU Primitive to deliver it to upper layers */
+         PJ_SND_PJU_DAT_IND(gCb,pjRbCb, tmpEnt);
+
+         /* cleanup the entry */
+         pjDbmDelRxEnt(gCb, &ulCb->recBuf, tmpEnt->count);
+      }
+   }
+
+   if( ((count == nxtRxCnt) &&(tmpEnt != NULLP) &&(tmpEnt->state == PJ_RDY_TO_SUBMIT)) ||
+       ((count == nxtRxCnt) &&(tmpEnt == NULLP)) )
+   {
+     if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == TRUE) 
+     {                                                            
+         pjStopTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);          
+     }
+   }
+#endif /* PJ_SEC_ASYNC */
+
+
+   RETVALUE(ROK);
+}/* pjUlmDeliverSrb */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function to deliver the SDU to the upper layer. 
+ *        It is called for DRB UM
+ *
+ * @b Description: 
+ *
+ *        This function performs the following functions.                  @n
+ *        1. Deliver the SDU to the upper layer                            @n
+ *        2. Clean up the hash list entry for this SDU.                    @n
+ *        3. For asynchronous mode, it checks if any subsequent 
+ *           messages can also be sent up.                                 @n
+ *        4. Mark the next SDU to be submitted to the upper layers.        @n
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @param[in] rxEnt    reception entry for the PDU
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmDeliverDrbUm 
+(
+PjCb   *gCb,
+PjUlRbCb *pjRbCb,        /* !< PDCP Control Block */                  
+PjRxEnt *rxEnt         /* !< Recption Buffer Entry   */             
+)
+#else
+PUBLIC S16 pjUlmDeliverDrbUm(gCb, pjRbCb, rxEnt)
+PjCb   *gCb;
+PjUlRbCb *pjRbCb;        /* !< PDCP Control Block */                  
+PjRxEnt *rxEnt;        /* !< Recption Buffer Entry   */             
+#endif
+{
+
+#ifdef PJ_CMP_ASYNC
+   PjUlCb   *ulCb;     /* Uplink Cb Ptr */
+   U32      nxtRxCnt;  /* Count for looping through the entries */
+   PjRxEnt  *tmpEnt;   /* Temp var for looping through the entries */
+   U32      count;     /* count varaible */ 
+   ulCb  =  &pjRbCb->ulCb;
+#endif
+
+   TRC2(pjUlmDeliverDrbUm)
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb, (PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ),
+         (gCb->init.prntBuf, "pjUlmDeliverDrbUm(pjRbCb(%d,%d),rxEnt(%ld)) \n", \
+          pjRbCb->rbId, pjRbCb->rbType, rxEnt->count));
+#else
+   PJDBGP(gCb, (PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ),
+         (gCb->init.prntBuf, "pjUlmDeliverDrbUm(pjRbCb(%d,%d),rxEnt(%d)) \n", \
+          pjRbCb->rbId, pjRbCb->rbType, rxEnt->count));
+#endif
+
+   /* Initialisations */
+
+   /* Update state */
+   rxEnt->state   =  PJ_RDY_TO_SUBMIT;
+
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+   if(rxEnt->count != ulCb->nxtSubCnt)
+   {
+      RETVALUE(ROK);
+   }
+#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
+#ifndef PJ_CMP_ASYNC
+#endif
+#ifndef RGL_SPECIFIC_CHANGES
+#ifndef TENB_ACC
+#ifndef LTE_PAL_ENB
+   EXTERN U32 ulrate_pju;
+      MsgLen len;
+      SFndLenMsg(rxEnt->mBuf, &len);
+      ulrate_pju += len;
+#endif      
+#endif      
+#endif
+     
+      pjUlmDeliverPdu(gCb,pjRbCb,rxEnt); 
+
+      
+#ifdef PJ_CMP_ASYNC
+
+   /* Search and see if any of the succeeding SNs can 
+    * also be sent to the upper layer */
+   nxtRxCnt  =  ulCb->rxNext;
+
+   /* Search till nextRxCnt */
+   for(count = ulCb->nxtSubCnt + 1; count < nxtRxCnt; count++) 
+   {
+      /* Get the next node */
+      tmpEnt   =  (PjRxEnt *)pjDbmGetRxEnt(gCb, &(ulCb->recBuf), count);
+
+      if(tmpEnt == NULLP)
+      {
+         /* pj005.201 added support for L2 Measurement */
+         /* Such an entry does not exist, search for the next */
+         continue;
+      }
+      if(tmpEnt->state != PJ_RDY_TO_SUBMIT)
+      {
+         /* Cant send anymore messages up, break*/
+         break;
+      }
+      else
+      {
+         /* pj005.201 added support for L2 Measurement */
+         /* call the PJU Primitive to deliver it to upper layers */
+         PJ_SND_PJU_DAT_IND(gCb,pjRbCb, tmpEnt);
+
+         /* cleanup the entry */
+         pjDbmDelRxEnt(gCb, &ulCb->recBuf, tmpEnt->count);
+      }
+   }/* end of while */
+
+   /* Update  nxtSubCnt */
+   ulCb->nxtSubCnt =  count;
+#endif /* PJ_CMP_ASYNC */
+
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+   if(pjRbCb->state != PJ_STATE_NORMAL)
+   {
+      /* start reestablishment procedures if last message has been processed */
+      if((ulCb->transCmp == TRUE) && 
+            (ulCb->obdCnt == 0))
+      {
+         /* It has received all messages from RLC and finished
+          * processing them. Possibility only when the last last message
+          * from deciphering fails. */
+         PJ_ULM_DRBUM_REEST(gCb, pjRbCb);
+      }
+   }
+#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
+
+   RETVALUE(ROK);
+}/* pjUlmDeliverDrbUm */
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function to deliver the SDU to the upper layer. It is called for DRB AM
+ *
+ * @b Description: 
+ *
+ *        This function performs the following functions.                                  @n
+ *        1. Delete duplicates and SDUs marked for discard.                                @n
+ *        2. Deliver the SDU to the upper layer                                            @n
+ *        3. Perform sequential delivery for SDUs received during reestablishment.         @n
+ *        4. Clean up the hash list entry for this SDU.                                    @n
+ *        5. For asynchronous mode, check if any subsequent messages can also be sent up.  @n
+ *        6. Mark the next SDU to be submitted to the upper layers.                        @n
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @param[in] rxEnt    Rx Entry
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmDeliverDrbAm
+(
+PjCb   *gCb,
+PjUlRbCb *pjRbCb,           /* !< PDCP Control Block */                  
+PjRxEnt *rxEnt            /* !< Recption Buffer Entry   */             
+)
+#else
+PUBLIC S16 pjUlmDeliverDrbAm(gCb, pjRbCb, rxEnt)
+PjCb   *gCb;
+PjUlRbCb *pjRbCb;           /* !< PDCP Control Block */                  
+PjRxEnt *rxEnt;           /* !< Recption Buffer Entry   */             
+#endif
+{
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+   PjUlCb  *ulCb;        /* RB uplink Control Block */
+#endif   
+   S16      ret;         /* Return value */
+
+   TRC2(pjUlmDeliverDrbAm)
+#ifndef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ),
+         (gCb->init.prntBuf, "pjUlmDeliverDrbAm(pjRbCb(%d,%d),rxEnt(%ld)) \n", \
+          pjRbCb->rbId, pjRbCb->rbType, rxEnt->count));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ),
+         (gCb->init.prntBuf, "pjUlmDeliverDrbAm(pjRbCb(%d,%d),rxEnt(%d)) \n", \
+          pjRbCb->rbId, pjRbCb->rbType, rxEnt->count));
+#endif
+
+   /* Initialisations */
+   ret         = ROK;
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+   ulCb        = &pjRbCb->ulCb;
+#endif   
+#ifndef RGL_SPECIFIC_CHANGES
+#ifndef TENB_ACC
+#ifndef LTE_PAL_ENB
+extern U32 ulrate_pju;
+MsgLen len;
+SFndLenMsg(rxEnt->mBuf, &len);
+ulrate_pju += len;
+#endif
+#endif
+#endif
+      pjUlmDeliverPdu(gCb,pjRbCb,rxEnt);
+      #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+   /* start reestablishment procedures if last message has been processed */
+   if(pjRbCb->state != PJ_STATE_NORMAL)
+   {
+      if((ulCb->transCmp == TRUE) && 
+         (ulCb->obdCnt == 0))
+      {
+         /* It has received all messages from RLC and finished
+          * processing them. Possibility only when the last last message
+          * from deciphering fails. */
+         pjUlmReEstDrbAm(gCb, pjRbCb);
+      }
+   }
+#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
+
+   RETVALUE(ret);
+}/* pjUlmDeliverDrbAm */
+
+/*****************************************************************************
+ *                      REESTABLISHMENT FUNCTIONS
+ ****************************************************************************/
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function to is called to reestablish the SRB. It is called as when the 
+ *        reestablishment request  is received.
+ *
+ * @b Description: 
+ *
+ *        This function performes the following.      @n
+ *        1. Reset NEXT_PDCP_RX_SN and RX_HFN         @n
+ *        2. Deinitialise the hashlist.               @n
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmReEstSrb
+(
+PjCb   *gCb,
+PjUlRbCb *pjRbCb       /*!< PDCP control block  */
+)
+#else
+PUBLIC S16 pjUlmReEstSrb(gCb,pjRbCb)
+PjCb   *gCb;
+PjUlRbCb *pjRbCb;      /*!< PDCP control block  */
+#endif
+{
+   TRC2(pjUlmReEstSrb);
+
+   /* Reset NEXT_PDCP_RX_SN and RX_HFN */
+   pjRbCb->ulCb.rxNext  =  0;
+   pjRbCb->ulCb.rxDeliv  =  0;
+
+   /* Deinitialise the hashlist */
+   pjDbmRxDelAll(gCb, &pjRbCb->ulCb.recBuf);
+
+   RETVALUE(ROK);
+}  /* pjUlmResetSrb */
+
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function to is called to reestablish the DRB .
+ *
+ * @b Description: 
+ *
+ *        This function is called after the last pdu is received from RLC
+ *        as part of reestablishment procedures. This function builds the staPdu
+ *        and store it
+ *                                               
+ *  @param[in] pjCb     PDCP Instance control block 
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmReEstDrbAm
+(
+PjCb       *gCb,
+PjUlRbCb   *pjRbCb   
+)
+#else
+PUBLIC S16 pjUlmReEstDrbAm(gCb, pjRbCb)
+PjCb       *gCb;
+PjUlRbCb   *pjRbCb;   
+#endif
+{
+       U16               fms;               /* First Missing SN                 */
+       PjUlCb           *ulCb;              /* RB uplink Control Block          */
+       PjSn              sn;                /* temp sn                          */
+       PjRxEnt          *tmpEnt    = NULLP; /* Temporary entity used in loop    */
+       U32               count;             /* Counter variable                 */
+       U32               idx;
+       U16               byteIdx = 0;
+       U8                bitIdx;
+       U8                numBits = 0;   /*KW_FIX */
+       Bool              nxtSnNotFnd;
+       PjUlHoCfmInfo     *hoInfo = NULLP;   /* To store the numBits and bitMap  */
+       U8                packByte[512] = {0};
+
+       TRC2(pjUlmReEstDrbAm);
+
+       RLOG2(L_DEBUG,"pjUlmReEstDrbAm(pjRbCb(%d,%d))",pjRbCb->rbId,pjRbCb->rbType);
+
+       /* Initialisations */
+       ulCb  =  &pjRbCb->ulCb;
+       PJ_MEM_SET(&(packByte), 0, (sizeof(packByte)));       /*KW_FIX : ccpu00136902*/
+       /* Its DRB AM from now on */
+       if(pjRbCb->state == PJ_STATE_REEST)
+       {
+               /* if status report generation not necessary, quit */
+               if(ulCb->staRepReqd == FALSE)
+               {
+                       RETVALUE(ROK);
+               }
+       }
+
+       /* If out-of-seq Pkts are stored in datPktQ then process the
+        * bitMap the following way */
+       fms = (U16)(pjRbCb->ulCb.fmsCount & (0x0fff));   /*KW_FIX*/
+       /* Setting the bitIdx to start from 8 */
+       bitIdx = PJ_BYTE_SIZE;
+       /* Initialize idx as 1 since Bitmap starts from FMS + 1 */
+       idx = 1;
+       cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ);
+       while(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ))
+       {
+               nxtSnNotFnd = TRUE;
+               tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ));
+               /* Retrieve the SN from Count of RxEnt */
+               sn = (U16)((tmpEnt->count) & (0x0fff)); /*KW_FIX*/
+               if(tmpEnt->isOutSeq == FALSE)
+               {
+                       /* This Packet is In-Seq so no need to compute this for Bitmap
+                        * As this Packet should have SN less than FMS. */
+                       cmLListNext(&pjRbCb->ulCb.recBuf.datPktQ);
+                       continue;
+               }
+               while((nxtSnNotFnd == TRUE) && (byteIdx < 512))
+               {
+                       /* BitMap start from FMS + 1 */
+                       count = fms + idx;
+                       if(count >= (1 << pjRbCb->snLen))
+                       {
+                               count = count % (1 << pjRbCb->snLen);
+                       }
+                       if(count != sn)
+                       {
+                               /* This SN is missing so set bitMap value to 0 */
+                               packByte[byteIdx] |= (0 << (--bitIdx));
+                               numBits++;
+                               idx++;
+                       }
+                       else
+                       {
+                               /* This SN is present so set bitMap value to 1 */
+                               packByte[byteIdx] |= (1 << (--bitIdx));
+                               numBits++;
+                               idx++;
+                               nxtSnNotFnd = FALSE;
+                               cmLListNext(&pjRbCb->ulCb.recBuf.datPktQ);               
+                       }
+                       if(numBits % PJ_BYTE_SIZE == 0)
+                       {
+                               byteIdx++;
+                               bitIdx = PJ_BYTE_SIZE;
+                       }
+               }
+               if(byteIdx >= 512)
+                       break;
+       }
+       /* if bitmap is not byte aligned, then append/pad 
+        * with 0s (to indicate from here Packets not received)
+        * to make it byte aligned and send to App */
+       while(numBits % 8 != 0)
+       {
+               packByte[byteIdx] |= (0 << (--bitIdx));
+               numBits++;
+       }
+
+       /* Store the numOfBits and bitMap in ueCb */
+       if(pjRbCb->state == PJ_STATE_REEST_HO)
+       {
+               hoInfo = &pjRbCb->ueCb->hoInfo->hoCfmInfo[pjRbCb->rbId];
+               hoInfo->pres = TRUE;
+               hoInfo->rbId = pjRbCb->rbId;
+               hoInfo->dir |= PJ_DIR_UL;
+               /* numBits sent from PDCP is always a multiple of 8 */
+               hoInfo->numBits = numBits;
+               if (numBits > 0) 
+               {
+                       RLOG_ARG1(L_DEBUG,DBG_UEID,pjRbCb->ueCb->key.ueId, 
+                                       "pjUlmReEstDrbAm : OutOfSeq UL Pkts are present for rbId = %d ",
+                                       pjRbCb->rbId);
+                       /* ByteAlign the computed Bits, numBits is always a multiple of 8 */ 
+#ifndef XEON_SPECIFIC_CHANGES
+      SGetStaticBuffer(gCb->init.region, gCb->init.pool, (Data **)&hoInfo->ulBitMap, sizeof(U8) * (numBits / 8), 0);
+#else
+                       PJ_ALLOC(gCb, hoInfo->ulBitMap, sizeof(U8) * (numBits / 8));
+#endif
+#if (ERRCLASS & ERRCLS_DEBUG)
+                       if(hoInfo->ulBitMap == NULLP)
+                       {
+                               RLOG0(L_FATAL, "Memory Allocation failed.");
+                               RETVALUE(RFAILED);
+                       }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+                       PJ_MEM_CPY(hoInfo->ulBitMap, packByte, (numBits / 8));
+               }
+               hoInfo->count = pjRbCb->ulCb.fmsCount;
+       }
+       else
+       {
+               /* Send the status report only in case of Re-Establishment 
+                * not during Handover as this part is hit when eNB is Source */
+               RLOG_ARG0(L_DEBUG,DBG_UEID,pjRbCb->ueCb->key.ueId, 
+                               "pjUlmReEstDrbAm : Sending PDCP Status Report ");
+               pjUlmBldStaRep(gCb, pjRbCb, pjRbCb->ulCb.fmsCount, packByte, numBits);
+       }
+       /*No error check required here*/
+
+       RETVALUE(ROK);
+}  /* pjUlmReEstDrbAm */
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function is called to build and send the SDU Status report.
+ *
+ * @b Description: 
+ *
+ *        This function is called to build the SDU status report and send it to the 
+ *        lower layer after reestablishment.
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @param[in] fms      First Missing sequence number
+ *  @param[in] staReq   Buffer containing status report bitmap
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmBldStaRep
+(
+PjCb       *gCb,
+PjUlRbCb   *pjRbCb,         
+PjSn       fmc,            
+U8         *bitMap,
+U16        bMapLen
+)
+#else
+PUBLIC S16 pjUlmBldStaRep(gCb, pjRbCb, fmc, bitMap, bMapLen)
+PjCb       *gCb;
+PjUlRbCb   *pjRbCb;      
+PjSn       fmc;         
+U8         *bitMap;
+U16        bMapLen;
+#endif
+{
+   Buffer          *staRep = NULLP;
+   U8              packByte = 0;         /* Temp Var for packing bytes */
+   S16             ret      =  ROK;  /* Return value */
+   U16             byteLen = 0;
+
+   TRC2(pjUlmBldStaRep);
+
+   RLOG2(L_DEBUG, "pjUlmBldStaRep(pjRbCb(%d,%d))",pjRbCb->rbId, pjRbCb->rbType);
+
+   PJ_ALLOC_BUF(gCb, staRep);
+#if (ERRCLASS & ERRCLS_DEBUG)
+   if(staRep == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+   SAddPstMsg(packByte, staRep);
+   packByte = (U8)((fmc & 0xff000000) >> 24);
+
+   SAddPstMsg(packByte, staRep);
+
+   packByte = (U8)((fmc & 0x00ff0000) >> 16);
+   SAddPstMsg(packByte, staRep);
+
+   packByte = (U8)((fmc & 0x0000ff00) >> 8);
+   SAddPstMsg(packByte, staRep);
+
+   packByte = (U8)((fmc & 0x000000ff));
+   SAddPstMsg(packByte, staRep);
+
+   /* Pack the bitmap */
+   if(bMapLen != 0)
+   {
+      /* bMapLen will always be a multiple of 8 */
+      byteLen = (U16)(bMapLen / 8);  /*KW_FIX*/
+      SAddPstMsgMult(bitMap, byteLen, staRep);
+   }
+
+   /*send the status report to DLPDCP */
+
+   pjUtlUlSndUlStaRep(gCb, pjRbCb, staRep);
+
+   RETVALUE(ret);
+
+}/*pjUlmBldStaRep*/
+
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function is called during handover to transfer the undeliverd SDUs
+ *        at the target side.
+ *
+ * @b Description: 
+ *
+ *        This function performs the following.                           @n
+ *        1. Calculate lastSubCnt.                                        @n
+ *        2. Compute count for each SDU.                                  @n
+ *        3. Create an rxEnt for each SDU and insert it into the hashlist.@n
+ *                                               
+ *  @param[in] pjRbCb      PDCP control block 
+ *  @param[in] datFwdReq   Data Forward Request info
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmHdlDatFwdReq  
+(
+PjCb           *gCb,
+PjUlRbCb         *pjRbCb,                       /* !< PDCP ID */        
+PjuDatFwdReqInfo   *datFwdReq                 /* !< DatFwdReq Info */
+)
+#else
+PUBLIC S16 pjUlmHdlDatFwdReq(gCb, pjRbCb, datFwdReq)
+PjCb           *gCb;
+PjUlRbCb         *pjRbCb;                       /* !< PDCP ID */        
+PjuDatFwdReqInfo   *datFwdReq;                /* !< DatFwdReq Info */ 
+#endif
+{
+   U32            datFwdCnt;         /* Temp value to store SDU count    */
+   PjRxEnt       *rxEnt     = NULLP; /* Rx Entry pointer                 */
+   PjuDatFwdInfo *info;              /* Loop var - pointer to DatFwdInfo */
+   PjUlCb        *ulCb      = NULLP; /* UL Control block                 */
+   U8             sduIndex;          /* loop index                       */
+   U32            rcvdHfn;
+
+   TRC2(pjUlmHdlDatFwdReq);
+
+   RLOG2(L_DEBUG, "pjUlmHdlDatFwdReq(pjRbCb(%d,%d), datFwdReq) ",
+         pjRbCb->rbId, pjRbCb->rbType);
+
+   /* Initialisations */
+   ulCb  =  &pjRbCb->ulCb;
+
+   /* Loop through all SDUs */
+   for( sduIndex = 0; sduIndex < datFwdReq->numSdus; sduIndex++)
+   {
+      info  =  &datFwdReq->datFwdInfo[sduIndex];
+      PJ_STS_INC_GEN_CNT(gCb,numPktsRcvd);
+
+      /*1.5G-NR Determine the Hfn and count value of the received PDCP data pdu*/
+      PJ_CALC_RCVD_HFN((info->sn),pjRbCb->snLen,ulCb->rxDeliv,rcvdHfn);
+      /*2.5G-NR Get the count value of the receiced PDCP data pdu from rcvdSn and rcvdHfn  */
+      PJ_GET_COUNT(datFwdCnt, pjRbCb->snLen, (info->sn), rcvdHfn);
+
+#ifdef PJ_SEC_ASYNC
+      PJ_ULM_UPD_NXT2DCOMP(pjRbCb->ulCb, (pjRbCb->snLen), rcvdCount, oldRxCnt);
+#endif
+
+      /* PJ_ULM_UPD_RX_VAR(info->sn, pjRbCb); */
+
+      /* Create and insert the entry in the buffer */
+      PJ_ALLOC(gCb,rxEnt, sizeof(PjRxEnt));
+
+#if (ERRCLASS & ERRCLS_DEBUG)
+      if(rxEnt == NULLP)
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         RETVALUE(RFAILED);
+      }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+
+      rxEnt->count     = datFwdCnt;
+      rxEnt->state     = PJ_RDY_TO_SUBMIT;
+      rxEnt->mBuf      = info->sdu;
+
+      if(pjRbCb->state == PJ_STATE_HO) 
+      {
+         /* If RbCb State = PJ_STATE_HO, then this is Target and Forwarded Packets
+          * are received before Status Transfer so buffer this Packet */
+         rxEnt->isOutSeq = TRUE;
+      }
+      /* Insert the entry in the buffer */
+      pjDbmInsRxEnt(gCb, &ulCb->recBuf, rxEnt, FALSE); 
+   }
+
+   RETVALUE(ROK);
+}/*pjUlmHdlDatFwdReq*/
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Function is called when 
+ *        1. The offboard timer expires.
+ *        2. Deciphering returns. 
+ *
+ * @b Description: 
+ *
+ *    The function is called when the pdu is next in line for decompression
+ *    It performs the following.                                           @n
+ *    1. Submit the pdu for decompression.                                 @n
+ *    2. Check if any successive messages can be sent to for decompression @n
+ *    3. Update the nxtSubDeCmp value appropriately .                      @n
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block 
+ *  @param[in] rxEnt    Reception Entry
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmSubmitForDecmp
+(
+PjCb       *gCb,
+PjUlRbCb     *pjRbCb,        /* !< PDCP Control Block */  
+PjRxEnt    *rxEnt          /* Ptr To Rx Entry */
+)
+#else
+PUBLIC S16 pjUlmSubmitForDecmp(gCb, pjRbCb, rxEnt)
+PjCb       *gCb;
+PjUlRbCb     *pjRbCb;        /* !< PDCP Control Block */  
+PjRxEnt    *rxEnt;         /* Ptr To Rx Entry */
+#endif
+{
+   PjUlCb  *ulCb;          /* ULM Control Block */
+#ifdef PJ_SEC_ASYNC
+   U32     count;          /* count to go through the list and check */
+   U32     nxtRxCnt;       /* count of Sdu to receive next */
+   PjRxEnt *tmpEnt;        /* Temporary variable for looping */
+#endif /* PJ_SEC_ASYNC */
+   U32     macI=0;
+
+   TRC2(pjUlmSubmitForDecmp);
+
+#ifndef ALIGN_64BIT
+   RLOG3(L_DEBUG, "pjUlmSubmitForDecmp(pjRbCb(%d,%d),rxEnt(%ld)) ",
+         pjRbCb->rbId, pjRbCb->rbType, rxEnt->count);
+#else
+   RLOG3(L_DEBUG, "pjUlmSubmitForDecmp(pjRbCb(%d,%d),rxEnt(%d)) ",
+         pjRbCb->rbId, pjRbCb->rbType, rxEnt->count);
+#endif
+
+   /* 1. Initialisations */
+   ulCb  =  &pjRbCb->ulCb;
+   rxEnt->state = PJ_RDY_TO_DCOMP;
+   /*Adding MACI for 5G NR for DRB in case of intergrity protection is enabled*/
+   if(pjRbCb->ueCb->secInfo.intProtEnbForDrb)
+   {
+      PJ_UNPK_MACI(rxEnt->mBuf, macI);
+   }
+
+   /* 2. If decomp is disabled, start delivery procedures */
+   if(pjRbCb->rohc.hdrCmpUsed != TRUE)
+   {
+      rxEnt->state   =  PJ_RDY_TO_SUBMIT;
+      PJ_DEC_OBD_COUNT(gCb, pjRbCb, rxEnt->count);
+      PJ_ULM_DELIVER_DRB(gCb,pjRbCb, rxEnt);
+      RETVALUE(ROK);
+   }
+
+   /* 3. If not the next in line for decompression, wait.. */
+   if(ulCb->nxtSubDeCmp != rxEnt->count)
+   {
+      RETVALUE(ROK);
+   }
+
+   /* 4. Calling decompression hook */
+   if(pjUlmHdlDeCmp(gCb, pjRbCb, rxEnt) != ROK)
+   {
+      RETVALUE(RFAILED);
+   }
+
+#ifdef PJ_SEC_ASYNC
+   /* 5. cycle through the subsequent entries to see if any of them are also 
+    * available for decompression */
+    nxtRxCnt = ulCb->rxNext;
+
+   for(count =  ulCb->nxtSubDeCmp + 1; count < nxtRxCnt; count ++)
+   {
+      /* 5.1 Get the next node */
+      tmpEnt   =  pjDbmGetRxEnt(gCb, &ulCb->recBuf, count);
+
+      /* 5.2 If such an entry does not exist, search for the next */
+      if(tmpEnt == NULLP)
+      {
+         continue;
+      }
+
+      /* 5.3 During post reestablishment phase, there might me some PDUs in 
+       * the Rx Buffer that were received prior to reestablishment and 
+       * have been fully processed but are not sent up because they are 
+       * waiting for the arrival of a previous PDU. We can  safely skip 
+       * such an entry */
+      if(tmpEnt->state == PJ_RDY_TO_SUBMIT)
+      {
+         continue;
+      }
+
+      /* 5.4 Deciphering not yet done so we have to wait */
+      if(tmpEnt->state != PJ_RDY_TO_DCOMP)
+      {
+         break;
+      }
+      
+      /*Adding MACI for 5G NR for DRB in case of intergrity protection is enabled*/
+      if(pjRbCb->ueCb->secInfo.intProtEnbForDrb)
+      {
+         PJ_UNPK_MACI(rxEnt->mBuf, macI);
+      }
+      /* 5.5 Send it to decompression */
+      if(pjUlmHdlDeCmp(gCb, pjRbCb, tmpEnt) != ROK)
+      {
+         RETVALUE(RFAILED);
+      }
+
+   } /* while(!((sn == ulCb->nxtRxSn)... */
+
+   /* 6. Update nxtSubDeCmp */
+   ulCb->nxtSubDeCmp = count;
+
+#endif /* PJ_SEC_ASYNC */
+
+   RETVALUE(ROK);
+
+}/* end of pjUlmSubmitForDecmp */
+/**
+ *
+ * @brief 
+ *
+ *        Function is called when the offboard timer expires.
+ *
+ * @b Description: 
+ *
+ *    The function performs the following
+ *    1. If the SDU associated with the timer is not delivered, we 
+ *       delete the entry .                                              @n
+ *    2. A status indication is sent to the user with error cause.       @n
+ *    3. In case of failure call pjUlmHdlErrUpdates to recalculate
+ *       nxtSubCnt and if necessary nxtSubDeCmp.                         @n
+ *    4. The timer is associated with the nextToSubmit SDU and restarted.@n
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC Void pjUlmHdlReordTmrExpiry 
+(
+PjCb       *gCb,
+PjUlRbCb     *pjRbCb         /* !< PDCP Control Block */  
+)
+#else
+PUBLIC Void pjUlmHdlReordTmrExpiry(gCb,pjRbCb)
+PjCb       *gCb;
+PjUlRbCb     *pjRbCb;        /* !< PDCP Control Block */  
+#endif
+{
+   PjRxEnt *tmpEnt = NULLP;
+   PjUlCb   *ulCb;
+   U32 tmpNxtDelvrCnt;
+   U32 rxReOrdHfn, tmpNxtDlvrHfn;
+
+   ulCb        = &pjRbCb->ulCb;
+
+   gPdcpStats.numPdcpCellReorderTmrExp++;
+   cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ);
+   if(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ))
+   {
+      tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ));
+
+      /* all stored PDCP SDU(s) with associated COUNT value(s) < RX_REORD; */
+      while(tmpEnt && (tmpEnt->count < ulCb->rxReord))
+      {
+         PJ_SND_PJU_DAT_IND(gCb,pjRbCb, tmpEnt);
+         pjDbmDelRxEnt(gCb, &ulCb->recBuf, tmpEnt->count);
+         cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ);
+         if(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ) == NULLP)
+         {
+            break;
+         }
+         tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ));
+      }
+   }
+   
+   tmpNxtDelvrCnt = ulCb->rxReord;
+   cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ);
+   if(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ))
+   {
+      tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ));
+      /* all stored PDCP SDU(s) with consecutively associated COUNT value(s) starting from RX_REORD */
+      while(tmpEnt && ( tmpEnt->count == tmpNxtDelvrCnt )) 
+      {
+         PJ_SND_PJU_DAT_IND(gCb,pjRbCb, tmpEnt);
+         tmpNxtDelvrCnt++;
+         pjDbmDelRxEnt(gCb, &ulCb->recBuf, tmpEnt->count);
+         cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ);
+         if(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ) == NULLP)
+         {
+            break;
+         }
+         tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ));
+      }
+   }
+   
+   /* update RX_DELIV to the COUNT value of the first PDCP SDU 
+      which has not been delivered to upper layers, 
+      with COUNT value >= RX_REORD;*/
+      PJ_GET_HFN(ulCb->rxDeliv,pjRbCb->snLen,rxReOrdHfn);
+      PJ_GET_HFN(tmpNxtDelvrCnt,pjRbCb->snLen,tmpNxtDlvrHfn);
+   if ((tmpNxtDelvrCnt > ulCb->rxReord) || 
+       ((PJ_MAX_HFN(pjRbCb->snLen) == rxReOrdHfn ) && (0 == tmpNxtDlvrHfn)))
+   {
+      ulCb->rxDeliv      =   tmpNxtDelvrCnt;
+   }
+   
+   if (ulCb->rxDeliv < ulCb->rxNext)
+   {
+      ulCb->rxReord = ulCb->rxNext;
+      pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR);
+   }
+}
+
+\f
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+/**
+ *
+ * @brief 
+ *
+ *        Function is called when the offboard timer expires.
+ *
+ * @b Description: 
+ *
+ *    The function performs the following
+ *    1. If the SDU associated with the timer is not delivered, we 
+ *       delete the entry .                                              @n
+ *    2. A status indication is sent to the user with error cause.       @n
+ *    3. In case of failure call pjUlmHdlErrUpdates to recalculate
+ *       nxtSubCnt and if necessary nxtSubDeCmp.                         @n
+ *    4. The timer is associated with the nextToSubmit SDU and restarted.@n
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ */
+#ifdef ANSI
+PUBLIC Void pjUlmHdlObdTmrExpiry
+(
+PjCb       *gCb,
+PjUlRbCb     *pjRbCb         /* !< PDCP Control Block */  
+)
+#else
+PUBLIC Void pjUlmHdlObdTmrExpiry(gCb,pjRbCb)
+PjCb       *gCb;
+PjUlRbCb     *pjRbCb;        /* !< PDCP Control Block */  
+#endif
+{
+   PjUlCb  *ulCb;          /* ULM Control Block */
+   PjRxEnt *rxEnt;         /* Ptr To Rx Entry */
+   U32      subCnt;        /* Count that was/will be submitted */
+
+   TRC2(pjUlmHdlObdTmrExpiry);
+
+   RLOG2(L_DEBUG, "pjUlmHdlObdTmrExpiry(pjRbCb(%d,%d)) ",
+         pjRbCb->rbId, pjRbCb->rbType);
+
+   /* 1. Initialistions */
+   ulCb  =  &pjRbCb->ulCb;
+   PJ_STS_INC_GEN_CNT(gCb,numPdusDiscObdTmrExp);
+
+
+   /* 2. For SDUs that have not yet been delivered */
+   PJ_ULM_GET_SUBCNT(pjRbCb, subCnt, gCb);
+   if(ulCb->obdPdu == subCnt)
+   {
+      /* 2.1 Send failure indication  and delete the entry */
+      rxEnt =  (PjRxEnt *)pjDbmGetRxEnt(gCb, &(ulCb->recBuf), ulCb->obdPdu);
+      if(rxEnt == NULLP)
+      {
+         if( ulCb->recBuf.numEntries == 0)
+         {
+            RETVOID;
+         }
+#if (ERRCLASS & ERRCLS_DEBUG)
+         RLOG1(L_ERROR, "rxEnt not found for subCnt [%lu]", subCnt);
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+         RETVOID;
+      }
+      else
+      {
+         RLOG1(L_ERROR, "Obd Timer expires without reply for subCnt [%lu]", subCnt);
+         PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt);
+         pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count);
+      }
+
+      /* 2.2 Update nxtSubCnt */
+      pjUlmHdlErrUpdates(gCb, pjRbCb, ulCb->obdPdu);
+
+      /* 2.3 Restart timer if it has not been restarted already */
+      if( ulCb->recBuf.numEntries != 0)
+      {
+         if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE)
+         {
+            PJ_ULM_GET_SUBCNT(pjRbCb, (ulCb->obdPdu), gCb);
+            if(!PJ_DRBAM_ALL_PDU_RECVD(pjRbCb))
+            {
+               pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
+            }
+         }
+      }
+   }
+   /* 3. For SDUs that have been delivered */
+   else
+   {
+      if( ulCb->recBuf.numEntries != 0)
+      {
+         /* 3.1 Associate the nxtToSub with the timer */
+         PJ_ULM_GET_SUBCNT(pjRbCb, (ulCb->obdPdu), gCb);
+         if(!PJ_DRBAM_ALL_PDU_RECVD(pjRbCb))
+         {
+            pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
+         }
+      }
+   }
+
+   RETVOID;
+}/* end of pjUlmHdlObdTmrExpiry */
+#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Function is called when 
+ *        1. The offboard timer expires 
+ *        2. The library functions fail.
+ *
+ * @b Description: 
+ *
+ *    The function performs the following
+ *    1. Update nxtSubCnt if necessary.
+ *    2. Update nxtSubDeCmp if necessary.
+ *    3. Check if reestablishment has to be triggered.
+ *                                               
+ *  @param[in] pjRbCb   PDCP control block.
+ *  @param[in] errCnt   Count of the error PDU.
+ *
+ *  @return  Void
+ */
+#ifdef ANSI
+PUBLIC Void pjUlmHdlErrUpdates
+(
+PjCb       *gCb,
+PjUlRbCb     *pjRbCb,        /* !< PDCP Control Block */  
+U32         errCnt         /* !< Count of PDU that raises the error */
+)
+#else
+PUBLIC Void pjUlmHdlErrUpdates(gCb, pjRbCb, errCnt)
+PjCb       *gCb;
+PjUlRbCb     *pjRbCb;        /* !< PDCP Control Block */  
+U32         errCnt;        /* !< Count of PDU that raises the error */
+#endif
+{
+#ifdef PJ_SEC_ASYNC
+   U32      nxtToDeCmp;
+#endif /* PJ_SEC_ASYNC */
+
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+   PjUlCb  *ulCb;          /* ULM Control Block */
+   U32      nxtRxCnt;
+   U32      nxtToSub;
+   PjRxEnt *rxEnt = NULLP;   /* Ptr To Rx Entry */
+#endif /* (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) */
+
+   TRC2(pjUlmHdlErrUpdates);
+
+#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
+   /* 1. Initialistions */
+   ulCb       =  &pjRbCb->ulCb;
+   nxtRxCnt  =  ulCb->rxNext;
+
+   /* 2. Decrement obd counter */
+   PJ_DEC_OBD_COUNT(gCb, pjRbCb, errCnt);
+
+   /* 3. For DRB AM , check if we can deliver anything  */
+   if((pjRbCb->rbType == PJ_DRB) &&  (pjRbCb->mode == PJ_DRB_AM))
+   {
+      /* if any successive entries can be sent up , send it */
+      for(nxtToSub  =  ulCb->rxDeliv; nxtToSub < nxtRxCnt; nxtToSub++)
+      {
+         if( (rxEnt = pjDbmGetRxEnt(gCb, &ulCb->recBuf, nxtToSub)) != NULLP)
+         {
+            /* As soon as we get an entry, we break */
+            if(rxEnt->state == PJ_RDY_TO_SUBMIT)
+            {
+               pjUlmDeliverDrbAm(gCb, pjRbCb, rxEnt);
+            }
+            break;
+         }
+
+      }
+      if(nxtToSub == nxtRxCnt)
+      {
+         /* This situation occurs, if this is the only pdu in the hashlist 
+          * and obd fails for it. In this case, we have to trigger reestablishment
+          * procedures */
+         if(pjRbCb->state != PJ_STATE_NORMAL)
+         {
+            if((ulCb->transCmp == TRUE) && 
+                  (ulCb->obdCnt == 0))
+            {
+               PJ_ULM_DRBUM_REEST(gCb, pjRbCb);
+            }
+         }
+      }
+   }
+   /* 4. For SRB/DRB UM Update nxtSubCnt */
+   else
+   {
+      if(errCnt ==  ulCb->nxtSubCnt)
+      {
+         for(nxtToSub  =  ulCb->nxtSubCnt + 1; nxtToSub < nxtRxCnt; nxtToSub++)
+         {
+            if( (rxEnt = pjDbmGetRxEnt(gCb, &ulCb->recBuf, nxtToSub)) != NULLP)
+            {
+               ulCb->nxtSubCnt = nxtToSub;
+               break;
+            }
+         }
+         if(nxtToSub == ulCb->nxtSubCnt )
+         {
+            if(rxEnt->state == PJ_RDY_TO_SUBMIT)
+            {
+               PJ_ULM_DELIVER_PDU(gCb, pjRbCb, rxEnt);
+            }
+         }
+         else
+         {
+            /* Update nxtSubCnt to point to nxtRxCnt so that 
+             * updations at pjUlmProcessRb can happen properly */
+            ulCb->nxtSubCnt   =  nxtRxCnt;
+
+            /* Check if its necessary to reestablish */
+            if(pjRbCb->state != PJ_STATE_NORMAL)
+            {
+               if((ulCb->transCmp == TRUE) && 
+                     (ulCb->obdCnt == 0))
+               {
+                  PJ_ULM_DRBUM_REEST(gCb, pjRbCb);
+               }
+            }
+         }
+      }
+   }
+
+#endif /* (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) */
+
+   /* Notes : Update nxSubCnt first and then nxtSubDeCmp because we dont want a case
+    * where nxtSubDeCmp becomes greater that nxtSubCnt */
+#ifdef PJ_SEC_ASYNC
+   /* 5. Update nxtSubDeCmp */
+   if((pjRbCb->rbType == PJ_DRB) && (errCnt == ulCb->nxtSubDeCmp))
+   {
+      nxtToDeCmp  =  ulCb->nxtSubDeCmp + 1;
+
+      for(; nxtToDeCmp < nxtRxCnt; nxtToDeCmp++)
+      {
+         rxEnt = pjDbmGetRxEnt(gCb, &ulCb->recBuf, nxtToDeCmp);
+
+         if(rxEnt == NULLP)
+         {
+            continue;
+         }
+
+         /* A pdu existing after reestablishment */
+         if(rxEnt->state == PJ_RDY_TO_SUBMIT)
+         {
+            continue;
+         }
+
+         ulCb->nxtSubDeCmp = nxtToDeCmp;
+         break;
+      }
+
+      if(nxtToDeCmp == ulCb->nxtSubDeCmp)
+      {
+         if(rxEnt && (rxEnt->state == PJ_RDY_TO_DCOMP))
+         {
+            pjUlmSubmitForDecmp(gCb, pjRbCb, rxEnt);
+         }
+      }
+      else
+      {
+         /* Update nxtSubDeCmp to point to nxtRxCnt so that 
+          * updations at pjUlmProcessRb can happen properly */
+         ulCb->nxtSubDeCmp =  nxtRxCnt;
+
+      }
+   }
+#endif /* PJ_SEC_ASYNC */
+
+   RETVOID;
+}/* end of pjUlmHdlErrUpdates */
+
+/**
+ *
+ * @brief 
+ *
+ *        Function is called when 
+ *        1.  PjLiKwuReEstCmpInd received from RLC in case of Re-establishment and HO
+ *
+ * @b Description: 
+ *
+ *    The function performs the following
+ *    1. Checks the RB state, if it is not equal to PJ_STATE_NORMAL calls
+ *        PJ_ULM_DRBUM_REEST or pjUlmReEstDrbAm
+ *                                               
+ *  @param[in] tPjCb   PDCP control block.
+ *  @param[in] tRbCb  RB control block.
+ *
+ *  @return  Void
+ */
+#ifdef ANSI
+PUBLIC Void pjUlmReEstCmpInd
+(
+PjCb   *gCb,
+PjUlRbCb *tRbCb        /* !< RB control block */  
+)
+#else
+PUBLIC Void pjUlmReEstCmpInd(tPjCb, tRbCb)
+PjCb       *gCb;
+PjUlRbCb     *tRbCb;        /* !< PDCP Control Block */  
+#endif
+{
+
+   TRC3(pjUlmReEstCmpInd)
+
+   /* No need to update state for SRB */
+   if(tRbCb->ueCb->libInfo.state == PJ_STATE_NORMAL)
+   {
+      RETVOID;
+   }
+
+   if(tRbCb->rbType == PJ_SRB)
+   {
+      RETVOID;
+   }
+
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+   /* If Async mode, set variable to true and return */
+   tRbCb->ulCb.transCmp = TRUE;
+   if(tRbCb->ulCb.obdCnt == 0)
+   {
+#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
+      /* In synchronous mode, we can proceed with reestablishment */
+      if (tRbCb->mode  ==  PJ_DRB_UM)
+      {
+         tRbCb->ulCb.rxNext  =  0; 
+         tRbCb->ulCb.rxDeliv   =  0;
+#ifdef LTE_L2_MEAS
+         tRbCb->ulCb.nxtSubSn =  0; 
+#endif
+      }
+      else
+      {
+         (Void)pjUlmReEstDrbAm(gCb, tRbCb);
+      }
+
+      pjUtlUlHdlRbReEstComplete(gCb,tRbCb);
+
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+   }
+#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
+
+   RETVOID;
+}
+
+
+/**
+ *
+ * @brief
+ *
+ *        Handler to forward the uplink data to the upper layer.
+ *
+ * @b Description:
+ *
+ *        1. This function is used to forward the uplink data to the upper layer
+ *        during handover.  @n
+ *        2. The out-of-sequene data SDUs are sent to the upper
+ *        layer.    @n
+ *
+ *  @param[in] pjRbCb      PDCP control block.
+ *
+ *  @return  S16
+ *      -# ROK
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmStartDataFrwdPerRb
+(
+PjCb       *gCb,
+PjUlRbCb    *pjRbCb 
+)
+#else
+PUBLIC S16 pjUlmStartDataFrwdPerRb(gCb, pjRbCb)
+PjCb       *gCb;
+PjUlRbCb    *pjRbCb;
+#endif
+{
+
+   U32              numSdu =0;
+   U16              count;
+   U32              numSduCnt =0,numSduTx = 0;
+   PjRxEnt  *tmpRxEnt = NULLP;              /* temporary Rx Entity */
+   PjuDatFwdIndInfo *datFwdInd = NULLP;
+   U32      numEntries = 0;
+   U16      sn = 0;
+   PjPjuSapCb   *pjuSap;
+
+   TRC3(pjUlmStartDataFrwdPerRb)
+
+   RLOG1(L_DEBUG, "pjUlmStartDataFrwdPerRb (%d )) ", pjRbCb->rbId);
+
+   pjuSap   = &(gCb->u.ulCb->pjuSap[PJ_DRB_SAP]);
+   if((pjRbCb->ulCb.rxNext == 0))
+   {
+      if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd,
+      sizeof (PjuDatFwdIndInfo)) != ROK)
+      {
+          datFwdInd = NULLP;
+      }
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      if (datFwdInd == NULLP)
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         RETVALUE(RFAILED);
+      }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+      datFwdInd->dir = PJ_DIR_UL;
+      datFwdInd->numSdus = 0;
+      datFwdInd->isLastDatFwdInd = TRUE;
+
+      /* sending DatFwdInd even if numSdu is zero */
+      pjUtlUlSndDatFwdInd(gCb,pjRbCb, datFwdInd);
+
+      RETVALUE(ROK);
+   }
+
+   /* Find the total number of RxEnts present */
+   numEntries = pjRbCb->ulCb.recBuf.numEntries;
+   /* Find the total count of the txEnts present */
+   numSduCnt = numSdu = numEntries;
+
+   /* Traverse the datPktQ and send the UL Packets to DAM */
+   cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ);
+
+while(numSduCnt >0)
+{
+   count = 0;
+   if(numSduCnt > PJ_FWD_MAX_SDU_CNT)
+   {
+      numSduTx  = PJ_FWD_MAX_SDU_CNT;
+      numSduCnt = numSduCnt - PJ_FWD_MAX_SDU_CNT;
+   }
+   else
+   {
+      numSduTx = numSduCnt;
+      numSduCnt = 0;
+   }
+
+      if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd,
+      sizeof (PjuDatFwdIndInfo)) != ROK)
+      {
+          datFwdInd = NULLP;
+      }
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      if (datFwdInd == NULLP)
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         RETVALUE(RFAILED);
+      }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+
+      if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,
+         (Data **)&datFwdInd->datFwdInfo, (sizeof (PjuDatFwdInfo)* numSduTx)) != ROK)
+      {
+          datFwdInd->datFwdInfo = NULLP;
+      }
+#if (ERRCLASS & ERRCLS_ADD_RES)
+      if (datFwdInd->datFwdInfo == NULLP)
+      {
+         RLOG0(L_FATAL, "Memory Allocation failed.");
+         RETVALUE(RFAILED);
+      }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+
+   while (numSduTx>0)
+   {
+      /* Retrieve the Packet Info by typecasting to RxEnt */
+      tmpRxEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ)); 
+      sn = (U16)((tmpRxEnt->count) & (0x0fff)); /*KW_FIX*/
+
+      datFwdInd->datFwdInfo[count].sn = sn;
+      /* Copy the SDU Buffer as it is into datFwdInfo */
+#ifdef SS_RBUF
+     datFwdInd->datFwdInfo[count].sdu = tmpRxEnt->mBuf;
+#else
+      SCpyMsgMsg(tmpRxEnt->mBuf, 0, 0,
+            &datFwdInd->datFwdInfo[count].sdu);
+#endif
+      cmLListNext(&pjRbCb->ulCb.recBuf.datPktQ);
+      numSduTx--;
+      count++;
+   }
+      /* Fill the datFwdInd struct and send it to DAM */
+      datFwdInd->dir = PJ_DIR_UL;
+      datFwdInd->numSdus = count;
+      datFwdInd->isLastDatFwdInd = FALSE;
+      /* Send the datFwdInd to DAM */
+      pjUtlUlSndDatFwdInd(gCb,pjRbCb, datFwdInd);
+
+}
+
+   if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd,
+      sizeof (PjuDatFwdIndInfo)) != ROK)
+   {
+       datFwdInd = NULLP;
+   }
+#if (ERRCLASS & ERRCLS_ADD_RES)
+   if (datFwdInd == NULLP)
+   {
+      RLOG0(L_FATAL, "Memory Allocation failed.");
+      RETVALUE(RFAILED);
+   }
+#endif /* ERRCLASS & ERRCLS_ADD_RES */
+   datFwdInd->dir = PJ_DIR_UL;
+   datFwdInd->numSdus = 0;
+   datFwdInd->isLastDatFwdInd = TRUE;
+
+   /* sending DatFwdInd even if numSdu is zero */
+   pjUtlUlSndDatFwdInd(gCb,pjRbCb, datFwdInd);
+
+   RETVALUE(ROK);
+}
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler to process the forwarded data received from upper layer.
+ *
+ * @b Description: 
+ *
+ *        1. This function is used to process the SDUs received from the upper
+ *        layer as part of handover.   @n
+ *        2. This function calls pjDlmProcessSdus function with the correct 
+ *        SN and HFN values.     @n
+ *            
+ *  @param[in] gCb         PDCP Instance control block. 
+ *  @param[in] pjUlRbCb    Uplink Rb control block. 
+ *  @param[in] datFwdReq   Data Forward Info.
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUlmHndlDatFwdReq
+(
+PjCb               *gCb,
+PjUlRbCb           *pjRbCb,
+PjuDatFwdReqInfo   *datFwdReq
+)
+#else
+PUBLIC S16 pjUlmHndlDatFwdReq(gCb,pjRbCb,datFwdReq)
+PjCb               *gCb;
+PjUlRbCb           *pjRbCb;
+PjuDatFwdReqInfo   *datFwdReq;
+#endif
+{
+
+   PjRxEnt  *rxEnt;              /* Transmission Entity */ 
+   PjSn     sn;
+   int      ret;
+   U32      numSdus=0;
+   U32      macI=0;
+   U32     rcvdHfn;             /*Hfn for received PDU */
+   U32     rcvdCount;           /*Count for received Pdu */
+   PjUlCb       *ulCb;            /* PTR to UL Control Block     */
+   U32          rxDelivHfn;     /*Hfn of the rxDeliv */
+
+   TRC3(pjUlmHndlDatFwdReq)
+     
+    /* 1. Initialisations */
+    ulCb   = &pjRbCb->ulCb;
+
+  
+   RLOG2(L_DEBUG, "pjDlmHndlDatFwdReq(pjRbCb (%d),datFwdReq(%d)) ", 
+      pjRbCb->rbId, datFwdReq->numSdus);
+
+   ret      = ROK;
+   sn       =datFwdReq->datFwdInfo[numSdus].sn;
+   gCb->pjGenSts.numPktsRcvd += datFwdReq->numSdus;
+   /* Process each of the SDUs with received SN and sduId */ 
+   for ( numSdus = 0; numSdus < datFwdReq->numSdus; numSdus++ )
+   {
+      /* 
+         The variables nxtTxSn and COUNT are assumed to be 
+         already updated in dlCb to continue with the 
+         transmission ( in the target eNodeB ).
+      */
+
+      PJ_CALC_RCVD_HFN(sn,pjRbCb->snLen,ulCb->rxDeliv,rcvdHfn);
+
+      /* 2.5G-NR Get the count value of the receiced PDCP data pdu from rcvdSn and rcvdHfn  */
+      PJ_GET_COUNT(rcvdCount, pjRbCb->snLen, sn, rcvdHfn);
+
+      /* 2. Allocate memory for the rxEnt */
+      PJ_ALLOC(gCb,rxEnt, sizeof(PjRxEnt));
+#if (ERRCLASS & ERRCLS_DEBUG)
+      if(rxEnt == NULLP)
+      {
+         RLOG0(L_FATAL, "Memory allocation failure");
+         RETVALUE(RFAILED);
+      }
+#endif /* (ERRCLASS & ERRCLS_DEBUG) */
+
+      
+      /* 4. Fill up the structures and insert into hashlist */
+      rxEnt->count   =  rcvdCount;
+      rxEnt->state   =  PJ_RDY_TO_DCIPHER;
+      rxEnt->mBuf    =  datFwdReq->datFwdInfo[numSdus].sdu;
+       
+
+      PJ_ULM_UPD_NXT2SUB(pjRbCb->ulCb, rxEnt->count); 
+      ret = pjDbmInsRxEnt(gCb, &pjRbCb->ulCb.recBuf, rxEnt, TRUE); 
+      if(ret == ROKDUP)
+      {
+         /* Duplicates are not to be inserted */
+         /* marked to be freed up later */
+         rxEnt->dupEntry =  TRUE;
+      }
+
+      PJ_GET_HFN(pjRbCb->ulCb.rxDeliv,pjRbCb->snLen,rxDelivHfn)
+      if((rcvdCount < ulCb->rxDeliv) && (rxDelivHfn != PJ_MAX_HFN(pjRbCb->snLen)))
+      {
+         rxEnt->discFlag = TRUE;
+
+      }
+      if(rxEnt->dupEntry == TRUE)
+      {
+         /* duplicate entry */
+         PJ_FREE_BUF(rxEnt->mBuf);
+         PJ_FREE(gCb,rxEnt, sizeof(PjRxEnt));
+      }
+      else if(rxEnt->discFlag == TRUE)
+      {
+         /* duplicate entry */
+         pjDbmDelRxEnt(gCb, &pjRbCb->ulCb.recBuf, rxEnt->count);
+      }   
+
+      
+      /*3.Update the RX_NEXT */
+       PJ_ULM_UPDATE_RX_NEXT(pjRbCb,rxEnt);
+
+      if(pjRbCb->rbType == PJ_DRB)
+      {
+         rxEnt->state   =  PJ_RDY_TO_DCOMP;
+         /*Adding MACI for 5G NR for DRB in case of intergrity protection is enabled*/
+         if(pjRbCb->ueCb->secInfo.intProtEnbForDrb)
+         {
+            PJ_UNPK_MACI(rxEnt->mBuf, macI);
+         }
+         ret = pjUlmHdlDeCmp(gCb, pjRbCb, rxEnt);
+      }
+      else
+      {
+         rxEnt->state   =  PJ_RDY_TO_INTVER;
+         ret = pjUlmHdlIntVer(gCb, pjRbCb, rxEnt);
+      }
+
+   }
+   RETVALUE(ROK);
+}
+/**
+ *
+ * @brief It processes the packets queued up in ULPktQ
+ *
+ * @Description
+ *      This ulPktQ queues the forwarded message at targe enodeb 
+ *      during handover. 
+ *
+ *  @param[in] pjCb     PDCP Instance control block.
+ *  @param[in] pjUlRbCb  Uplink Rb Control block 
+ *
+ *  @return  Void
+ */
+#ifdef ANSI
+PUBLIC Void pjUlmProcessUlPktQ
+(
+PjCb       *gCb,
+PjUlRbCb   *pjRbCb           /* !< PDCP Control Block */
+)
+#else
+PUBLIC Void pjUlmProcessUlPktQ(gCb, pjRbCb)
+PjCb       *gCb;
+PjUlRbCb   *pjRbCb;          /* !< PDCP Control Block */
+#endif
+{
+   PjUlPkt *pkt;
+   CmLList *node;
+
+   TRC2(pjUlmProcessUlPktQ);
+
+   CM_LLIST_FIRST_NODE(&(pjRbCb->ulCb.ulPktLst), node);
+   while (node != NULLP)
+   {
+      pkt = (PjUlPkt *) node->node;
+
+      cmLListDelFrm(&(pjRbCb->ulCb.ulPktLst), node);
+      pkt->lnk.node = NULLP;
+      pjUlmProcessRb(gCb,pjRbCb, pkt->sn, pkt->pdu, TRUE);
+      PJ_FREE(gCb,pkt, sizeof (PjUlPkt));
+      
+      CM_LLIST_FIRST_NODE(&(pjRbCb->ulCb.ulPktLst), node);
+   }
+
+   RETVOID;
+}/* end of pjDlmProcessDlPktQ */
+
+/**
+ *
+ * @brief
+ *
+ *  @param[in] pjRbCb   PDCP control block.
+    @param[in] PjRxEnt  *rxEnt
+ *
+ *  @return  Void
+ */
+#ifdef ANSI
+PRIVATE Void pjUlmEnqueueUlPkt
+(
+PjCb     *gCb,
+PjUlRbCb   *pjRbCb,           /* !< PDCP Control Block */
+PjSn      sn,               /* !< SN value of PDU */
+Buffer   *pdu              /* !< PDU message buffer */
+)
+#else
+PRIVATE Void pjUlmEnqueueUlPkt(gCb,pjRbCb, sn, pdu)
+PjCb     *gCb;
+PjUlRbCb   *pjRbCb;          /* !< PDCP Control Block */
+PjSn      sn;              /* !< SN value of PDU */
+Buffer   *pdu;             /* !< PDU message buffer */
+#endif
+{
+   PjUlPkt    *pkt;
+
+   TRC2(pjUlmEnqueueUlPkt)
+
+   PJ_ALLOC(gCb,pkt, sizeof(PjUlPkt));
+   if (pkt != NULLP)
+   {
+      pkt->sn = sn;
+      pkt->pdu = pdu;
+      pkt->type = PJ_DATA_NRM_PKT;
+      pkt->lnk.node = (PTR)pkt;
+      cmLListAdd2Tail (&pjRbCb->ulCb.ulPktLst, &pkt->lnk);
+   }
+   else
+   {
+      RLOG0(L_FATAL, "Memory allocation failure");
+      PJ_FREE_BUF(pdu);
+   }
+
+   RETVOID;
+}
+                                                        
+/*@}*/
+
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/5gnrpdcp/pj_utl.c b/src/5gnrpdcp/pj_utl.c
new file mode 100755 (executable)
index 0000000..127ad4c
--- /dev/null
@@ -0,0 +1,1977 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/**********************************************************************
+
+     Name:     LTE-PDCP Layer 
+  
+     Type:     C file
+  
+     Desc:     Source code for PDCP Utility Module
+
+               This file contains following functions:
+
+                  --PjLibObdCmpCfm
+                  --PjLibObdIntProtCfm
+                  --PjLibObdCipherCfm
+                  --PjLibObdDecipherCfm
+                  --PjLibObdIntVerCfm
+                  --PjLibObdDecmpCfm
+                  -- pjUtlCmpReq
+                  -- pjUtlIntProtReq
+  
+     File:     pj_utl.c
+
+**********************************************************************/
+static const char* RLOG_MODULE_NAME="PDCP";
+static int RLOG_MODULE_ID=1024;
+static int RLOG_FILE_ID=231;
+/** @file pj_utl.c
+@brief PDCP Utility Module 
+*/
+
+/* header (.h) include files */
+#include "envopt.h"        /* environment options */
+#include "envdep.h"        /* environment dependent */
+#include "envind.h"        /* environment independent */
+
+#include "gen.h"           /* general */
+#include "ssi.h"           /* system services */
+#include "cm5.h"           /* common timer defines */
+#include "cm_tkns.h"       /* common tokens defines */
+#include "cm_mblk.h"       /* common memory allocation library defines */
+#include "cm_llist.h"      /* common link list  defines  */
+#include "cm_hash.h"       /* common hash list  defines */
+#include "cm_lte.h"        /* common LTE defines */
+#include "cpj.h"                /* CPJ defines */
+#include "pju.h"                /* PJU defines */
+#include "lpj.h"                /* LPJ defines */
+
+#include "pj_env.h"        /* RLC environment options */
+#include "pj.h"            /* RLC defines */
+#include "pj_ul.h"
+#include "pj_dl.h"
+#include "pj_err.h"        /* Error defines */
+
+/* extern (.x) include files */
+#include "gen.x"           /* general */
+#include "ssi.x"           /* system services */
+
+#include "cm5.x"           /* common timer library */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_mblk.x"       /* common memory allocation */
+#include "cm_llist.x"      /* common link list */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lte.x"        /* common LTE includes */
+#include "cm_lib.x"        /* common memory allocation library */
+#include "cpj.x"                /* CPJ */
+#include "pju.x"                /* PJU */
+#include "lpj.x"                /* LPJ */
+#include "pj.x"
+#include "pj_udx.h"          /* LIB */
+#include "pj_udx.x"          /* LIB */
+#include "pj_ul.x"
+#include "pj_dl.x"
+
+#include "pj_lib.x"          /* LIB */
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif /* __cplusplus */
+
+/** @addtogroup dldata */
+/*@{*/
+\f
+#ifdef PJ_CMP_ASYNC
+/********************************************************************
+ *    Input Handler from Offboarding unit                           *
+ *******************************************************************/
+/**
+ *
+ * @brief 
+ *
+ *        Asynchronous handler to received that Init Confirm for 
+ *        compression for the  offboarding unit.
+ *
+ * @b Description:
+ *
+ *        This function gets the context Id passed as the parameter and stores it
+ *        in the RbCb.
+ *
+ *  @param[in]  pst      Post structure 
+ *  @param[in]  cmpCxt   Context for ROHC
+ *  @param[in]  ctxId    Context Id
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLibObdCmpInitCfm
+(
+Pst      *pst,                    /* post structure */
+PjCmpCxt cmpCxt,                  /* Context for ROHC */
+PTR      ctxId                    /* Compression Context ID */
+)
+#else
+PUBLIC S16 PjLibObdCmpInitCfm(pst, cmpCxt, ctxId)
+Pst      *pst;                    /* post structure */
+PjCmpCxt cmpCxt;                  /* Context for ROHC */
+PTR      ctxId;                   /* Compression Context ID */
+#endif
+{                                 
+   PjCb     *tPjCb;
+
+   TRC3(PjLibObdCmpInitCfm);
+   
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   RLOG4(L_DEBUG, "PjLibObdCmpInitCfm(pst, cmpCxt(%d,%d,%d,%d)"
+           cmpCxt.ueId, cmpCxt.rbId, cmpCxt.rbType, cmpCxt.cfgTxId);
+   RLOG1(L_DEBUG ," ctxId(%ld))",ctxId);
+
+   if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
+   {
+      RETVALUE(RFAILED);
+   }
+
+   if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      PjUlUeCb   *ueCb = NULLP;         /* UeCb control block */
+      PjUlRbCb   *pjRbCb = NULLP;       /* PDCP RB control block */
+
+      pjDbmFetchUlUeCb(tPjCb,cmpCxt.ueId, cmpCxt.cellId, &ueCb);
+      if(ueCb  == NULLP)
+      {
+         RLOG_ARG1(L_ERROR, DBG_CELLID, cmpCxt.cellId,"UL UeId[%u] not found",
+            cmpCxt.ueId);
+         RETVALUE(RFAILED);
+      }
+      
+      pjDbmFetchPjUlRbCb(ueCb, cmpCxt.rbId, cmpCxt.rbType,&pjRbCb); 
+      if(pjRbCb  == NULLP)
+      {
+         RLOG_ARG2(L_ERROR, DBG_UEID,cmpCxt.ueId,"CellId[%u]: UL RbId[%d] not found",
+            cmpCxt.cellId, cmpCxt.rbId);
+         RETVALUE(RFAILED);
+      }
+
+      pjRbCb->cmpCxtId  =  ctxId;
+
+      /* Check if all confirms have been received */
+      pjUtlUlHdlObdInitCfm(tPjCb,ueCb, cmpCxt.cfgTxId, PJ_CMP_INIT_CFM,  cmpCxt.rbId);
+   }
+   else
+   {
+      PjDlUeCb   *ueCb = NULLP;         /* UeCb control block */
+      PjDlRbCb   *pjRbCb = NULLP;       /* PDCP RB control block */
+
+      pjDbmFetchDlUeCb(tPjCb,cmpCxt.ueId, cmpCxt.cellId, &ueCb);
+      if(ueCb  == NULLP)
+      {
+         RLOG_ARG1(L_ERROR, DBG_CELLID, cmpCxt.cellId,"DL UeId[%u] not found",
+                cmpCxt.ueId);
+         RETVALUE(RFAILED);
+      }
+
+      pjDbmFetchPjDlRbCb(ueCb, cmpCxt.rbId, cmpCxt.rbType,&pjRbCb);
+      if(pjRbCb  == NULLP)
+      {
+         RLOG_ARG2(L_ERROR, DBG_UEID,cmpCxt.ueId, "CellId[%u]: DL RbId[%d] not found",
+                cmpCxt.cellId, cmpCxt.rbId);
+         RETVALUE(RFAILED);
+      }
+
+      pjRbCb->cmpCxtId  =  ctxId;
+
+      /* Check if all confirms have been received */
+      pjUtlDlHdlObdInitCfm(tPjCb,ueCb, cmpCxt.cfgTxId, PJ_CMP_INIT_CFM,  cmpCxt.rbId);
+   }
+
+
+   RETVALUE(ROK);
+
+} /* end of PjLibObdCmpInitCfm */
+#endif /* PJ_SEC_ASYNC */
+
+#ifdef PJ_SEC_ASYNC
+/**
+ *
+ * @brief 
+ *
+ *        Asynchronous handler to received that Init Confirm for 
+ *        Integrity for the  offboarding unit.
+ *
+ * @b Description:
+ *
+ *        This function gets the context Id passed as the parameter and stores it
+ *        in the UeCb.
+ *
+ *  @param[in]  pst        Post structure 
+ *  @param[in]  secCxt     Context for Integrity protection/verification 
+ *  @param[in]  ctxId      Integrity Context Id
+ *
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLibObdIntInitCfm
+(
+Pst      *pst,                    /* post structure */
+PjSecCxt secCxt,                  /* Secutiry Context */
+PTR      ctxId                    /* Integrity Context ID */
+)
+#else
+PUBLIC S16 PjLibObdIntInitCfm(pst, secCxt, ctxId)
+Pst      *pst;                    /* post structure */
+PjSecCxt secCxt;                  /* Secutriy Context */
+PTR      ctxId;                   /* Integrity Context ID */
+#endif
+{                                 
+   PjCb     *tPjCb;
+
+   TRC3(PjLibObdIntInitCfm)
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+
+   RLOG4(L_DEBUG, "PjLibObdCmpInitCfm(pst, secCxt(%d,%d,%d), ctxId(%ld))",
+           secCxt.cellId, secCxt.ueId, secCxt.cfgTxId, ctxId);
+
+   if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
+   {
+      RETVALUE(RFAILED);
+   }
+
+   if (tPjCb->pjGenCfg.mode  == LPJ_MODE_PDCP_UL)
+   {
+      PjUlUeCb   *ueCb = NULLP;         /* UeCb control block */
+      /* Fetch UeCb */
+      pjDbmFetchUlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb);
+      if(ueCb  == NULLP)
+      {
+         RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"UL UeId[%u] not found",
+            secCxt.ueId);
+         RETVALUE(RFAILED);
+      }
+
+      /* Update context Id */
+      ueCb->secInfo.intCxtId = ctxId;
+
+      pjUtlUlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM,  
+                                             PJ_LIB_INT_BIT_MASK);
+   }
+   else
+   {
+      PjDlUeCb   *ueCb = NULLP;         /* UeCb control block */
+      /* Fetch UeCb */
+      pjDbmFetchDlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb);
+      if(ueCb  == NULLP)
+      {
+         RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"DL UeId[%u] not found",
+            secCxt.ueId);
+         RETVALUE(RFAILED);
+      }
+
+      /* Update context Id */
+      ueCb->secInfo.intCxtId = ctxId;
+
+      pjUtlDlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM,  
+                                             PJ_LIB_INT_BIT_MASK);
+   }
+
+   RETVALUE(ROK);
+
+} /* end of PjLibObdIntInitCfm */
+\f
+/**
+ *
+ * @brief 
+ *
+ *        Asynchronous handler to received that Init Confirm for 
+ *        Ciphering Cp Key  for the  offboarding unit.
+ *
+ * @b Description:
+ *
+ *        This function gets the context Id passed as the parameter and stores it
+ *        in the UeCb.
+ *
+ *  @param[in]  pst        Post structure 
+ *  @param[in]  secCxt     Context for Ciphering 
+ *  @param[in]  ctxId      Ciphering CP Context Id
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLibObdCpInitCfm
+(
+Pst      *pst,                    /* post structure */
+PjSecCxt secCxt,                  /* Secutiry Context */
+PTR      ctxId                    /* Ciphering Context ID */
+)
+#else
+PUBLIC S16 PjLibObdCpInitCfm(pst, secCxt, ctxId)
+Pst      *pst;                    /* post structure */
+PjSecCxt secCxt;                  /* Secutriy Context */
+PTR      ctxId;                   /* Ciphering Context ID */
+#endif
+{
+   PjCb     *tPjCb;
+
+   TRC3(PjLibObdCpInitCfm);
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+
+   RLOG4(L_DEBUG, "PjLibObdCpInitCfm(pst, secCxt(%d,%d,%d), ctxId(%ld))",
+           secCxt.cellId, secCxt.ueId, secCxt.cfgTxId, ctxId);
+
+   if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
+   {
+      RETVALUE(RFAILED);
+   }
+
+   if (tPjCb->pjGenCfg.mode  == LPJ_MODE_PDCP_UL)
+   {
+      PjUlUeCb   *ueCb = NULLP;         /* UeCb control block */
+      pjDbmFetchUlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb);
+      if(ueCb  == NULLP)
+      {
+         RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"UL UeId[%u] not found",
+            secCxt.ueId);
+         RETVALUE(RFAILED);
+      }
+
+      ueCb->secInfo.cpCxtId =  ctxId;
+
+      /* Update bit mask and check if all confirms have been received */
+      pjUtlUlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM,  
+                           (U8)PJ_LIB_CP_CIP_BIT_MASK);
+   }
+   else
+   {
+      PjDlUeCb   *ueCb = NULLP;         /* UeCb control block */
+      pjDbmFetchDlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb);
+      if(ueCb  == NULLP)
+      {
+         RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"DL UeId[%u] not found",
+            secCxt.ueId);
+         RETVALUE(RFAILED);
+      }
+
+      ueCb->secInfo.cpCxtId =  ctxId;
+
+      /* Update bit mask and check if all confirms have been received */
+      pjUtlDlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM,  
+                           (U8)PJ_LIB_CP_CIP_BIT_MASK);
+   }
+
+   RETVALUE(ROK);
+} /* end of PjLibObdCpInitCfm */
+
+/**
+ *
+ * @brief 
+ *
+ *        Asynchronous handler to received that Init Confirm for 
+ *        Ciphering Up Key  for the  offboarding unit.
+ *
+ * @b Description:
+ *
+ *        This function gets the context Id passed as the parameter and stores it
+ *        in the UeCb.
+ *
+ *  @param[in]  pst        Post structure 
+ *  @param[in]  secCxt     Context for Ciphering 
+ *  @param[in]  ctxId      Ciphering UP Context Id
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLibObdUpInitCfm
+(
+Pst      *pst,                    /* post structure */
+PjSecCxt secCxt,                  /* Secutiry Context */
+PTR      ctxId                    /* Ciphering Context ID */
+)
+#else
+PUBLIC S16 PjLibObdUpInitCfm(pst, secCxt, ctxId)
+Pst      *pst;                    /* post structure */
+PjSecCxt secCxt;                  /* Secutriy Context */
+PTR      ctxId;                   /* Ciphering Context ID */
+#endif
+{
+   PjCb     *tPjCb;
+
+   TRC3(PjLibObdUpInitCfm);
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+   RLOG4(L_DEBUG, "PjLibObdUpInitCfm(pst, secCxt(%d,%d,%d), ctxId(%ld))",
+           secCxt.cellId, secCxt.ueId, secCxt.cfgTxId, ctxId);
+
+   if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
+   {
+      RETVALUE(RFAILED);
+   }
+
+   if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
+   {
+      PjUlUeCb   *ueCb = NULLP;         /* UeCb control block */
+
+      pjDbmFetchUlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb);
+      if(ueCb  == NULLP)
+      {
+         RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"UL UeId[%u] not found",
+            secCxt.ueId);
+         RETVALUE(RFAILED);
+      }
+
+      ueCb->secInfo.upCxtId =  ctxId;
+
+      /* Update bit mask and check if all confirms have been received */
+      pjUtlUlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM,  
+                        (U8)PJ_LIB_UP_CIP_BIT_MASK);
+   }
+   else
+   {
+      PjDlUeCb   *ueCb = NULLP;         /* UeCb control block */
+
+      pjDbmFetchDlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb);
+      if(ueCb  == NULLP)
+      {
+         RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"DL UeId[%u] not found",
+            secCxt.ueId);
+         RETVALUE(RFAILED);
+      }
+
+      ueCb->secInfo.upCxtId =  ctxId;
+
+      /* Update bit mask and check if all confirms have been received */
+      pjUtlDlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM,  
+                        (U8)PJ_LIB_UP_CIP_BIT_MASK);
+   }
+
+   RETVALUE(ROK);
+
+} /* end of PjLibObdUpInitCfm */
+
+#endif /* PJ_SEC_ASYNC */
+
+#ifdef PJ_CMP_ASYNC
+/**
+ *
+ * @brief 
+ *
+ *        Asynchronous handler to receive the compressed SDU from off-board
+ *        entity.
+ *
+ * @b Description:
+ *
+ *        This function receives an output from compression unit and 
+ *        sends the same for ciphering with relevant input paramenters.
+ *
+ *  @param[in]   pst          Post structure 
+ *  @param[in]   cmpCxtId     Context Id for compression 
+ *  @param[in]   libTrans     Transaction Id 
+ *  @param[in]   opSdu        compressed SDU 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLibObdCmpCfm
+(
+Pst        *pst,        /* post structure             */
+PTR         cmpCxtId,   /* Context Id for compression */
+PjLibTrans  libTrans,   /* Transaction Id             */
+Buffer     *opSdu       /* compressed SDU             */
+)
+#else
+PUBLIC S16 PjLibObdCmpCfm(pst, cmpCxtId, libTrans, opSdu)
+Pst        *pst;        /* post structure             */
+PTR         cmpCxtId;   /* Context Id for compression */
+PjLibTrans  libTrans;   /* Transaction Id             */
+Buffer     *opSdu;      /* compressed SDU             */
+#endif
+{
+   PjCb        *tPjCb;
+   PjDlRbCb    *pjRbCb;
+   PjTxEnt     *txEnt;
+   S16         ret;
+   U32         macI;          /* MAC-I value to be padded to the PDU */
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   CmLteRbId rbId;
+
+   TRC3(PjLibObdCmpCfm)
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef ALIGN_64BIT
+   RLOG4(L_DEBUG, "PjLibObdCmpCfm(pst, cmpCxtId(%ld), libTrans(%d,%d,%d))",
+           cmpCxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
+#else
+   RLOG4(L_DEBUG, "PjLibObdCmpCfm(pst, cmpCxtId(%ld), libTrans(%d,%d,%ld))",
+           cmpCxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
+#endif
+
+   /* If PDCP Layer is not configured and recieved message from Off-board, then
+    * clean the resources recieved and return RFAILED.
+    * Else proceed with processing.*/
+   if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
+   {
+      PJ_FREE_BUF(opSdu);
+      RETVALUE(RFAILED);
+   }
+
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   rbId =  libTrans.rbId + 1;
+   pjDbmFetchPjDlRbCb((PjDlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb);
+   if ( pjRbCb == NULLP )
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: DL RbId[%d] not found",
+            libTrans.cellId, rbId);
+      PJ_FREE_BUF(opSdu);
+      RETVALUE(RFAILED);
+   }
+   
+   if ( pjRbCb->state == PJ_STATE_REEST || pjRbCb->state == PJ_STATE_REEST_HO)
+   {
+      PJ_FREE_BUF(opSdu);
+      RETVALUE(ret);
+   }
+
+   txEnt = pjDbmGetTxEnt(tPjCb,&(pjRbCb->dlCb.txBuf), libTrans.count);
+   if ( txEnt == NULLP )
+   {
+      RLOG1(L_ERROR, "txEnt not found for Cnt [%lu]", libTrans.count);
+      PJ_FREE_BUF(opSdu);
+      RETVALUE(RFAILED);
+   }
+   if ( opSdu == NULLP )
+   {
+      RLOG_ARG0(L_ERROR, DBG_RBID, rbId ,"Compression Failed , Count [%lu]",  libTrans.count);
+      PJ_UPD_DL_VAR(tPjCb, pjRbCb, txEnt->count);
+      txEnt->sdu = NULLP;
+      if ( pjRbCb->dlCb.cfmReqd)
+      {
+         PJ_SND_CFM(tPjCb,pjRbCb, txEnt, PJU_COMP_FAILED);
+      }
+      else
+      {
+          pjDbmDelTxEnt( tPjCb,&(pjRbCb->dlCb.txBuf), txEnt->count);
+      }
+      tPjCb->pjGenSts.numCmpFails++;
+      RETVALUE(RFAILED);
+   }
+
+   txEnt->pdu    = opSdu;
+   if(pjRbCb->ueCb->secInfo.intProtEnbForDrb)
+   {
+      macI   = 0;
+      PJ_PACK_MACI(txEnt->sdu, macI);
+   }
+   if ( pjRbCb->ueCb->secInfo.secAct )
+   {
+      ret = pjDlmHdlCiph(tPjCb,pjRbCb, txEnt);
+      if ( ret != ROK )
+      {
+         RLOG_ARG0(L_ERROR, DBG_RBID, rbId ,"CipherReq Failed , Count [%lu]",  libTrans.count);
+         RETVALUE(RFAILED);
+      }
+#ifdef PJ_SEC_ASYNC
+      RETVALUE(ret);
+#endif
+   }
+   ret = pjDlmDeliverPdu(tPjCb,pjRbCb, txEnt);
+   
+   RETVALUE(ret);
+} /* end of PjLibObdCmpCfm */
+
+/**
+ *
+ * @brief 
+ *
+ *        Asynchronous handler to receive the decompressed SDU from off-board
+ *        entity.
+ *
+ * @b Description:
+ *
+ *        This function receives an output from decompression unit and 
+ *        sends the SDU to upper layer in sequence. 
+ *
+ *  @param[in] pst         post structure
+ *  @param[in] cmpCxtId    Context Id for decompression
+ *  @param[in] libTrans    Transaction Id
+ *  @param[in] opSdu       decompressed SDU
+ *  @param[in] fbPkt       Feedback Pkt
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLibObdDecmpCfm
+(
+Pst         *pst,                 /* post structure */
+PTR         cmpCxtId,             /* Context Id for decompression */
+PjLibTrans  libTrans,             /* Transaction Id */
+Buffer      *opSdu,               /* decompressed SDU */
+Buffer      *fbPkt                /* Feedback pkt */
+)
+#else
+PUBLIC S16 PjLibObdDecmpCfm(pst, cmpCxtId, libTrans, opSdu, fbPkt)
+Pst         *pst;                 /* post structure */
+PTR         cmpCxtId;             /* Context Id for decompression */
+PjLibTrans  libTrans;             /* Transaction Id */
+Buffer      *opSdu;               /* decompressed SDU */
+Buffer      *fbPkt;               /* feedback Pkt */
+#endif
+{
+   PjCb       *tPjCb;
+   PjUlRbCb   *pjRbCb;
+   PjUlCb     *ulCb;
+   PjRxEnt    *rxEnt;
+
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   CmLteRbId rbId;
+
+   TRC2(PjLibObdDecmpCfm);
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef ALIGN_64BIT
+   RLOG4(L_DEBUG, "PjLibObdDecmpCfm(pst, cmpCxtId(%ld), libTrans(%d,%d,%d))",
+        cmpCxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
+#else
+   RLOG4(L_DEBUG, "PjLibObdDecmpCfm(pst, cmpCxtId(%ld), libTrans(%d,%d,%ld))",
+       cmpCxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
+#endif
+
+   /* If PDCP Layer is not configured and recieved message from Off-board, then
+    * clean the resources recieved and return RFAILED.
+    * Else proceed with processing.*/
+   if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
+   {
+      PJ_FREE_BUF(opSdu);
+      PJ_FREE_BUF(fbPkt);
+      RETVALUE(RFAILED);
+   }
+
+   /* 1. Initialisations */
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   rbId =  libTrans.rbId + 1;
+   pjDbmFetchPjUlRbCb((PjUlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb);
+   if(pjRbCb == NULLP)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: UL RbId[%d] not found",
+            libTrans.cellId, rbId);
+      RETVALUE(RFAILED);
+   }
+   ulCb  =  &pjRbCb->ulCb;
+
+   /* 2. Send the feedback packet */
+   if(fbPkt != NULLP)
+   {
+      pjUtlUlSndUlRohcFdbk(tPjCb,pjRbCb,fbPkt);
+   }
+
+   
+   /* 3. Get the rxEnt */
+   rxEnt =  pjDbmGetRxEnt(tPjCb,&ulCb->recBuf, libTrans.count );
+   if((rxEnt == NULLP) || (rxEnt->state != PJ_SENT_TO_DCOMP))
+   {
+      /* We  have got a duplicate . 
+       * It is NULLP if the original has been sent up,
+       * Or, the original is in another state 
+       * (if both are in the same state, we accept the 
+       * first output) */
+      PJ_FREE_BUF(opSdu);
+      RETVALUE(ROK);
+   }
+
+   /* 4. check decompression status */
+   if(opSdu == NULLP)
+   {
+      RLOG_ARG0(L_ERROR,DBG_RBID,rbId,"opSdu is NULLP");
+      PJ_FREE_BUF(opSdu);
+      PJ_SND_PJU_STA_IND(tPjCb,pjRbCb, rxEnt);
+      PJ_STS_INC_GEN_CNT(tPjCb,numDecmpFails);
+      pjUlmHdlErrUpdates(tPjCb,pjRbCb, rxEnt->count);
+      pjDbmDelRxEnt(tPjCb,&ulCb->recBuf, rxEnt->count);
+      RETVALUE(RFAILED);
+   }
+
+   /* 5. check for discardable entries */
+   if(rxEnt->discFlag == TRUE)
+   {
+      pjDbmDelRxEnt(tPjCb,&ulCb->recBuf, rxEnt->count);
+      PJ_FREE_BUF(opSdu);
+      RETVALUE(ROK);
+   }
+
+   /* 6. Post decomp updations */
+   rxEnt->state   =  PJ_RDY_TO_SUBMIT;
+   PJ_FREE_BUF(rxEnt->mBuf);
+   rxEnt->mBuf  =  opSdu;
+
+   /* 7. Call the function to deliver the pdu*/
+   PJ_DEC_OBD_COUNT(tPjCb,pjRbCb, rxEnt->count);
+   PJ_ULM_DELIVER_DRB(tPjCb,pjRbCb, rxEnt);
+
+   RETVALUE(ROK);
+} /* end of PjLibObdDecmpCfm */
+
+#endif /* PJ_CMP_ASYNC */
+\f
+#ifdef PJ_SEC_ASYNC 
+/**
+ *
+ * @brief 
+ *
+ *        Asynchronous handler to receive the MAC-I from off-board
+ *        entity.
+ *
+ * @b Description:
+ *
+ *        This function receives an output, MAC-I from Integration unit and 
+ *        sends the data for ciphering with relevant input paramenters.
+ *
+ *  @param[in]   pst         Post structure 
+ *  @param[in]   cxtId       Context Id for Integrity protection
+ *  @param[in]   libTrans    Transaction Id 
+ *  @param[in]   macI        Message authentication code 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLibObdIntProtCfm
+(
+Pst      *pst,                    /* post structure */
+PTR      cxtId,                   /* Context Id for Integrity protection*/
+PjLibTrans libTrans,              /* Transaction Id */
+U32      macI                     /* Message authentication code */
+)
+#else
+PUBLIC S16 PjLibObdIntProtCfm(pst, cxtId, libTrans, macI)
+Pst      *pst;                    /* post structure */
+PTR      cxtId;                   /* Context Id for Integrity protection */
+PjLibTrans libTrans;              /* Transaction Id */
+U32      macI;                    /* Message authentication code */
+#endif
+{
+   PjCb    *tPjCb;
+   U8         hdr;
+   PjDlRbCb   *pjRbCb;
+   Buffer   *ciphSdu;
+   S16      ret;
+   U32      count;
+   PjTxEnt  *txEnt;
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   CmLteRbId rbId;
+  
+   TRC3(PjLibObdIntProtCfm)
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef ALIGN_64BIT
+   RLOG4(L_DEBUG, "PjLibObdIntProtCfm(pst, cxtId(%ld), libTrans(%d,%d,%d))",
+           cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
+#else
+   RLOG4(L_DEBUG, "PjLibObdIntProtCfm(pst, cxtId(%ld), libTrans(%d,%d,%ld))",
+           cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
+#endif
+
+
+   /* If PDCP Layer is not configured and recieved message from Off-board, then
+    * clean the resources recieved and return RFAILED.
+    * Else proceed with processing.*/
+   if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
+   {
+      RETVALUE(RFAILED);
+   }
+   
+   count    = libTrans.count;
+   ret      = ROK;
+   txEnt    = NULLP;
+   ciphSdu  = NULLP;
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   rbId =  libTrans.rbId + 1;
+   pjDbmFetchPjDlRbCb((PjDlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb);
+   if ( pjRbCb == NULLP )
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: DL RbId[%d] not found",
+            libTrans.cellId, rbId);
+      RETVALUE(RFAILED);
+   }
+   if ( pjRbCb->state == PJ_STATE_REEST || pjRbCb->state == PJ_STATE_REEST_HO)
+   {
+      RETVALUE(ret);
+   }
+
+   txEnt = pjDbmGetTxEnt(tPjCb,&(pjRbCb->dlCb.txBuf), count);
+   if ( txEnt == NULLP)
+   {
+      RLOG_ARG1(L_ERROR,DBG_RBID,rbId,"txEnt is NULLP, Count[%lu]",
+            count);
+      RETVALUE(RFAILED);
+   }
+
+
+   PJ_PACK_MACI(txEnt->sdu, macI);
+   
+   ret = SRemPreMsg(&hdr, txEnt->sdu);
+   if ( ret != ROK )
+   {
+      RLOG_ARG1(L_ERROR,DBG_RBID,rbId,"SRemPreMsg failed , Count [%lu]",
+            count);
+      PJ_UPD_DL_VAR(tPjCb,pjRbCb, txEnt->count);
+      PJ_SND_CFM(tPjCb,pjRbCb, txEnt, PJ_REM_MSG_FAILED);
+      pjDbmDelTxEnt(tPjCb,&(pjRbCb->dlCb.txBuf), txEnt->count);
+      RETVALUE(RFAILED);
+   }
+    
+   txEnt->pdu = txEnt->sdu;
+
+   if (pjRbCb->firstDlMsg == TRUE && pjRbCb->firstSn == txEnt->sn)
+   {
+      pjRbCb->firstDlMsg = FALSE; 
+      txEnt->sdu = NULLP;
+      ret = pjDlmDeliverPdu(tPjCb,pjRbCb, txEnt);
+   }
+   else
+   {
+      ret = pjDlmHdlCiph(tPjCb,pjRbCb, txEnt);
+      if ( ret != ROK )
+      {    
+         RLOG_ARG1(L_ERROR,DBG_RBID,rbId,"CipherReq failed, Count[%lu]",
+                libTrans.count);
+      } 
+   }
+   
+   RETVALUE(ret);
+
+} /* end of PjLibObdIntProtCfm */
+
+/**
+ *
+ * @brief 
+ *
+ *        Asynchronous handler to receive the ciphered SDU from off-board
+ *        entity.
+ *
+ * @b Description:
+ *
+ *        This function receives an output from ciphering unit and 
+ *        sends the PDU to lower layer in sequence.
+ *
+ *  @param[in]   pst              Post structure
+ *  @param[in]   cxtId            Context Id for Ciphering 
+ *  @param[in]   libTrans         Transaction Id 
+ *  @param[in]   opSdu            ciphered SDU 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLibObdCipherCfm
+(
+Pst      *pst,                    /* post structure */
+PTR      cxtId,                   /* Context Id for Ciphering */
+PjLibTrans libTrans,              /* Transaction Id */
+Buffer   *opSdu                   /* ciphered SDU */
+)
+#else
+PUBLIC S16 PjLibObdCipherCfm(pst, cxtId, libTrans, opSdu)
+Pst      *pst;                    /* post structure */
+PTR      cxtId;                   /* Context Id for Integrity protection */
+PjLibTrans libTrans;              /* Transaction Id */
+Buffer   *opSdu;                  /* ciphered SDU */
+#endif
+{
+   PjCb     *tPjCb;
+   PjDlRbCb   *pjRbCb;
+   S16      ret;
+   PjTxEnt  *txEnt;
+   U32      count;
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   CmLteRbId rbId;
+
+   TRC3(PjLibObdCipherCfm)
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef ALIGN_64BIT
+   RLOG4(L_DEBUG, "PjLibObdCipherCfm(pst, cxtId(%ld), libTrans(%d,%d,%d))",
+           cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
+#else
+   RLOG4(L_DEBUG, "PjLibObdCipherCfm(pst, cxtId(%ld), libTrans(%d,%d,%ld))",
+           cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
+#endif
+
+   count  = libTrans.count;
+   ret    = ROK;
+
+   /* If PDCP Layer is not configured and recieved message from Off-board, then
+    * clean the resources recieved and return RFAILED.
+    * Else proceed with processing.*/
+   if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
+   {
+      PJ_FREE_BUF(opSdu);
+      RETVALUE(RFAILED);
+   }
+
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   rbId =  libTrans.rbId + 1;
+   pjDbmFetchPjDlRbCb((PjDlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb);
+   if ( pjRbCb == NULLP )
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: DL RbId[%d] not found",
+            libTrans.cellId, rbId);
+      PJ_FREE_BUF(opSdu);
+      RETVALUE(RFAILED);
+   }
+   if ( pjRbCb->state == PJ_STATE_REEST || pjRbCb->state == PJ_STATE_REEST_HO)
+   {
+      PJ_FREE_BUF(opSdu);
+      RETVALUE(ret);
+   }
+   txEnt = pjDbmGetTxEnt(tPjCb,&(pjRbCb->dlCb.txBuf), count);
+   if ( txEnt == NULLP )
+   {
+      /* Log an error and return */
+      RLOG_ARG1(L_ERROR,DBG_RBID,rbId,"txEnt is NULLP, Count[%lu]",
+            count);
+      PJ_FREE_BUF(opSdu);
+      RETVALUE(RFAILED);
+   }
+   if ( opSdu == NULLP )
+   {
+      RLOG_ARG0(L_ERROR,DBG_RBID,rbId,"opSdu is NULLP");
+      PJ_UPD_DL_VAR(tPjCb,pjRbCb, txEnt->count);
+      if (!pjRbCb->rohc.hdrCmpUsed)
+      {
+         txEnt->sdu = NULLP;
+      }
+      if ( pjRbCb->dlCb.cfmReqd)
+      {
+         PJ_SND_CFM(tPjCb,pjRbCb, txEnt, PJU_CIPHER_FAILED);
+      }
+      else
+      {
+         pjDbmDelTxEnt(tPjCb, &(pjRbCb->dlCb.txBuf), txEnt->count);
+      }
+      tPjCb->pjGenSts.numCiphFails++;
+      RETVALUE(RFAILED);
+   }
+
+   if ( pjRbCb->rohc.hdrCmpUsed )
+   {
+      PJ_FREE_BUF(txEnt->pdu);
+   }
+   txEnt->pdu = opSdu;
+   ret = pjDlmDeliverPdu(tPjCb,pjRbCb, txEnt);
+
+   RETVALUE(ret);
+
+} /* end of PjLibObdCipherCfm */
+/*@}*/
+
+/**
+ *
+ * @brief 
+ *
+ *        Asynchronous handler to receive the deciphered SDU from off-board
+ *        entity.
+ *
+ * @b Description:
+ *
+ *        This function receives an output from deciphering unit and 
+ *        sends the same for Integrity verification or decompression
+ *        based on the rbType.
+ * 
+ *  @param[in]  pst            Post structure 
+ *  @param[in]  cxtId          Context Id for Integrity protection
+ *  @param[in]  libTrans       Transaction Id 
+ *  @param[in]  opPdu          Deciphered SDU 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLibObdDecipherCfm
+(
+Pst         *pst,                 /* post structure */
+PTR         cxtId,                /* Context Id for Integrity protection*/
+PjLibTrans  libTrans,             /* Transaction Id */
+Buffer      *opPdu                /* deciphered SDU */
+)
+#else
+PUBLIC S16 PjLibObdDecipherCfm(pst, cxtId, libTrans, opPdu)
+Pst         *pst;                 /* post structure */
+PTR         cxtId;                /* Context Id for Integrity protection*/
+PjLibTrans  libTrans;             /* Transaction Id */
+Buffer      *opPdu;               /* deciphered SDU */
+#endif
+{
+   PjCb       *tPjCb;
+   PjUlCb     *ulCb;
+   PjRxEnt    *rxEnt;
+   PjUlRbCb     *pjRbCb;
+   Buffer     *outPdu = NULLP;
+   S16         ret   =  ROK;
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   CmLteRbId rbId;
+
+   TRC2(PjLibObdDecipherCfm);
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef ALIGN_64BIT
+   RLOG4(L_DEBUG, "PjLibObdDecipherCfm(pst, cxtId(%ld), libTrans(%d,%d,%d))",
+       cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
+#else
+   RLOG4(L_DEBUG, "PjLibObdDecipherCfm(pst, cxtId(%ld), libTrans(%d,%d,%ld))",
+       cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
+#endif
+
+   /* If PDCP Layer is not configured and recieved message from Off-board, then
+    * clean the resources recieved and return RFAILED.
+    * Else proceed with processing.*/
+   if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
+   {
+      PJ_FREE_BUF(opPdu);
+      RETVALUE(RFAILED);
+   }
+
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   rbId =  libTrans.rbId + 1;
+   /* 1. Initialisations */
+    pjDbmFetchPjUlRbCb((PjUlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb); 
+   if(pjRbCb == NULLP)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: UL RbId[%d] not found",
+            libTrans.cellId, rbId);
+      PJ_FREE_BUF(opPdu);
+      PJ_STS_INC_GEN_CNT(tPjCb,numDeciphFails);
+      RETVALUE(RFAILED);
+   }
+
+   ulCb  =  &pjRbCb->ulCb;
+
+   /* Validating rxEnt will be done later in code */
+   rxEnt =  pjDbmGetRxEnt(tPjCb,&ulCb->recBuf, libTrans.count);
+
+    /* 2. check decipher status */
+   if( opPdu == NULLP)
+   {
+      RLOG_ARG0(L_ERROR, DBG_RBID, rbId,"opPdu is NULL");
+      PJ_FREE_BUF(opPdu);
+      PJ_STS_INC_GEN_CNT(tPjCb,numDecmpFails);
+      if ( rxEnt != NULLP )
+      {
+         PJ_SND_PJU_STA_IND(tPjCb,pjRbCb, rxEnt);
+         pjUlmHdlErrUpdates(tPjCb,pjRbCb, rxEnt->count);
+         pjDbmDelRxEnt(tPjCb,&ulCb->recBuf, rxEnt->count);
+      }
+      RETVALUE(RFAILED);
+   }
+
+
+   /* 3. Check if it is SRB */
+   if(pjRbCb->rbType == PJ_SRB)
+   {
+      /* 3.1 For reestablishment scenarios, discard */
+      if(pjRbCb->state != PJ_STATE_NORMAL )
+      {
+         /* Discard the mBuf */
+         PJ_FREE_BUF(opPdu);
+         RETVALUE(ROK);
+      }
+      
+      /* 3.2 Validate the rxEnt */
+      if(rxEnt == NULLP)
+      {
+         RLOG_ARG0(L_ERROR, DBG_RBID,rbId,"rxEnt not found");
+         PJ_FREE_BUF(opPdu);
+         PJ_STS_INC_GEN_CNT(tPjCb,numDeciphFails);
+         RETVALUE(RFAILED);
+      }
+         
+      /* 3.3 Post deciphering updations */
+      rxEnt->state   =  PJ_RDY_TO_INTVER;
+      PJ_FREE_BUF(rxEnt->mBuf);
+      rxEnt->mBuf  =  opPdu;
+
+      /* 3.4 Send for IntVer. This will be ASYNC  */
+      ret = pjUlmHdlIntVer(tPjCb,pjRbCb, rxEnt);
+
+      RETVALUE(ret);
+   }
+   else  /*  DRB */
+   {
+
+      /* 4. Special case, 
+       * Duplicate entries, can be sent out of order */
+      if((rxEnt  == NULLP)||
+         (rxEnt->discFlag == TRUE) ||
+         (rxEnt->state != PJ_SENT_TO_DCIPHER))
+      {
+         /* 4.1 is decompression applicable */
+         if(pjRbCb->rohc.hdrCmpUsed == TRUE)
+         {
+
+            /* 4.1.1 Calling decompression hook */
+            if(pjUtlDeCmpReq(tPjCb,pjRbCb, libTrans.count, opPdu, &outPdu) != ROK)
+            {
+               RETVALUE(RFAILED);
+            }
+
+#ifdef PJ_CMP_ASYNC
+            PJ_FREE_BUF(opPdu);
+            RETVALUE(ROK);
+#endif /* PJ_CMP_ASYNC */
+         }
+
+         /* 4.1.2 discard output and exit */
+         PJ_FREE_BUF(opPdu);
+         PJ_FREE_BUF(outPdu);
+         if((rxEnt != NULLP) &&
+            (rxEnt->discFlag == TRUE))
+         {
+            pjDbmDelRxEnt(tPjCb,&ulCb->recBuf, rxEnt->count);
+         }
+
+         RETVALUE(ROK);
+      }
+      
+
+      /* 5. Post deciphering updations */
+      rxEnt->state   =  PJ_RDY_TO_SUBMIT;
+      PJ_FREE_BUF(rxEnt->mBuf);
+      rxEnt->mBuf  =  opPdu;
+
+      /* 6. Submit it for decompression */
+      pjUlmSubmitForDecmp(tPjCb,pjRbCb, rxEnt);
+
+   }/* if(pjRbCb->rbType == PJ_DRB) */
+
+   RETVALUE(ROK);
+
+} /* end of PjLibObdDecipherCfm */
+
+/**
+ *
+ * @brief 
+ *
+ *        Asynchronous handler to receive the status for Integrity verification 
+ *        from off-board entity.
+ *
+ * @b Description:
+ *
+ *        This function receives status, success or failure for Integrity
+ *        verification and sends the data for deciphering with relevant input paramenters.
+ *
+ *  @param[in] pst        post structure 
+ *  @param[in] cxtId      Context Id for Integrity protection
+ *  @param[in] libTrans   Transaction Id 
+ *  @param[in] status     Integrity verification status 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 PjLibObdIntVerCfm
+(
+Pst      *pst,                    /* post structure */
+PTR      cxtId,                   /* Context Id for Integrity protection*/
+PjLibTrans libTrans,              /* Transaction Id */
+Status   status                   /* Integrity verification status */
+)
+#else
+PUBLIC S16 PjLibObdIntVerCfm(pst, cxtId, libTrans, status)
+Pst      *pst;                    /* post structure */
+PTR      cxtId;                   /* Context Id for Integrity protection */
+PjLibTrans libTrans;              /* Transaction Id */
+Status   status;                  /* Integrity verification status */
+#endif
+{
+   PjCb     *tPjCb;
+   PjUlRbCb   *pjRbCb;
+   PjUlCb   *ulCb;
+   PjRxEnt  *rxEnt;
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   CmLteRbId rbId;
+
+   TRC2(PjLibObdIntVerCfm)
+
+   if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
+   {
+      RETVALUE (RFAILED);
+   }
+
+   tPjCb = PJ_GET_PJCB(pst->dstInst);
+
+#ifdef ALIGN_64BIT
+   RLOG4(L_DEBUG, "PjLibObdIntVerCfm(cxtId(%ld), libTrans(%d,%d,%d))",
+          cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
+#else
+   RLOG4(L_DEBUG, "PjLibObdIntVerCfm(cxtId(%ld), libTrans(%d,%d,%ld))",
+          cxtId, libTrans.rbId, libTrans.rbType, libTrans.count, status);
+#endif
+   RLOG1(L_DEBUG," status(%d)",status);
+
+   /* If PDCP Layer is not configured and recieved message from Off-board, then
+    * clean the resources recieved and return RFAILED.
+    * Else proceed with processing.*/
+   if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
+   {
+      RETVALUE(RFAILED);
+   }
+
+   /* Initialisations */
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   rbId =  libTrans.rbId + 1;
+   pjDbmFetchPjUlRbCb((PjUlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb); 
+   if(pjRbCb == NULLP)
+   {
+      RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: UL RbId[%d] not found",
+            libTrans.cellId, rbId);
+      PJ_STS_INC_GEN_CNT(tPjCb, numIntgVrfFails);
+      RETVALUE(RFAILED);
+   }
+   ulCb  =  &pjRbCb->ulCb;
+
+   /* For reestablishment cases, exit */
+   if(pjRbCb->state != PJ_STATE_NORMAL)
+   {
+      RETVALUE(ROK);
+   }
+
+   /* Get the rxEnt */
+   rxEnt =  pjDbmGetRxEnt(tPjCb,&ulCb->recBuf, libTrans.count);
+   if(rxEnt == NULLP)
+   {
+      RLOG_ARG1(L_ERROR, DBG_RBID, rbId, "rxEnt not found for Count [%lu]", libTrans.count);
+      PJ_STS_INC_GEN_CNT(tPjCb, numIntgVrfFails);
+      PJ_PERFORM_ERR_UPDATES(tPjCb, pjRbCb, libTrans.count);
+      RETVALUE(RFAILED);
+   }
+
+   /* Validate status */
+   if(status != ROK)
+   {
+      RLOG_ARG1(L_ERROR, DBG_RBID, rbId, "Integrity Verification Failed , Count [%lu]"
+            , rxEnt->count);
+      PJ_SND_PJU_STA_IND(tPjCb,pjRbCb, rxEnt);
+      PJ_STS_INC_GEN_CNT(tPjCb,numIntgVrfFails);
+      PJ_PERFORM_ERR_UPDATES(tPjCb,pjRbCb, rxEnt->count);
+/*      pjDbmDelRxEnt(&ulCb->recBuf, rxEnt->count); */
+      RETVALUE(RFAILED);
+   }
+
+   /* Check if next in line for delivery */
+   rxEnt->state   =  PJ_RDY_TO_SUBMIT;
+   if(rxEnt->count != ulCb->nxtSubCnt)
+   {
+      RETVALUE(ROK);
+   }
+
+   /* Send for delivery */
+   pjUlmDeliverSrb(tPjCb,pjRbCb, rxEnt);
+
+   RETVALUE(ROK);
+
+} /* end of PjLibObdIntVerCfm */
+#endif /* PJ_SEC_ASYNC */
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for redirecing compression request to either synchronous
+ *        or asynchronous module.
+ *
+ * @b Description:
+ *
+ *        This function sends compression request as either synchronous or
+ *        asynchronous function calls with relevant input parameters.
+ *
+ *  @param[in]   pjRbCb         PDCP RbCb 
+ *  @param[in]   mBuf           SDU to be compressed 
+ *  @param[in]   opSdu          Compressed SDU 
+ *  @param[in]   count          COUNT - transaction Id 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlCmpReq
+(
+PjCb       *gCb,
+PjDlRbCb   *pjRbCb,                 /* PDCP RbCb */
+Buffer   *mBuf,                   /* SDU to be compressed */
+Buffer   **opSdu,                 /* Compressed SDU */
+U32      count                    /* COUNT - transaction Id */
+)
+#else
+PUBLIC S16 pjUtlCmpReq(gCb,pjRbCb, mBuf, opSdu, count)
+PjCb       *gCb;
+PjDlRbCb   *pjRbCb;                 /* PDCP RbCb */
+Buffer   *mBuf;                   /* SDU to be compressed */
+Buffer   **opSdu;                 /* Compressed SDU */
+U32      count;                   /* COUNT - transaction Id */
+#endif
+{
+#ifdef PJ_CMP_ASYNC
+   PjLibTrans libTrans; /* Transaction Id for compression */
+#endif
+   S16        ret;
+
+   ret = ROK;
+
+   TRC3(pjUtlCmpReq)
+
+#ifdef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), 
+          (gCb->init.prntBuf, "pjUtlCmpReq(pjRbCb(%d,%d), count(%d))\n",\
+                    pjRbCb->rbId, pjRbCb->rbType, count));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), 
+          (gCb->init.prntBuf, "pjUtlCmpReq(pjRbCb(%d,%d), count(%ld))\n",\
+                    pjRbCb->rbId, pjRbCb->rbType, count));
+#endif
+
+
+#ifdef PJ_CMP_ASYNC
+   /* Assign transId and cxtId */
+   libTrans.count  = count;
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   libTrans.rbId   = pjRbCb->rbId - 1;
+   libTrans.rbType = pjRbCb->rbType;
+   libTrans.ueCb   = (PTR)pjRbCb->ueCb;
+
+   /* Start the timer if it is not started already */
+   if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR)) == FALSE)
+   {
+      pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR);
+   }
+
+   /* Send to the library */
+   ret = PjLibObdCmpReq(&(gCb->pjGenCfg.obdPst.cmpPst), pjRbCb->cmpCxtId, 
+                                                      libTrans, mBuf);  
+#else
+   ret = pjLibCmpReq(pjRbCb->cmpCxtId, mBuf, opSdu);
+#endif
+
+   RETVALUE(ret);
+
+} /* end of pjUtlCmpReq */
+
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for redirecing decompression request to either synchronous
+ *        or asynchronous module.
+ *
+ * @b Description:
+ *
+ *        This function sends decompression protection request as either synchronous or
+ *        asynchronous function calls with relevant input parameters.
+ *
+ *  @param[in]   pjRbCb         PDCP RbCb 
+ *  @param[in]   mBuf           SDU to be compressed 
+ *  @param[in]   opSdu          Compressed SDU 
+ *  @param[in]   count          COUNT - transaction Id 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlDeCmpReq
+(
+PjCb       *gCb,
+PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
+U32      count,                   /* COUNT - transaction Id */
+Buffer   *mBuf,                   /* SDU to be compressed */
+Buffer   **opSdu                  /* Compressed SDU */
+)
+#else
+PUBLIC S16 pjUtlDeCmpReq(pjRbCb, count, mBuf, opSdu)
+PjCb    *gCb;
+PjUlRbCb   *pjRbCb;                 /* PDCP RbCb */
+U32      count;                   /* COUNT - transaction Id */
+Buffer   *mBuf;                   /* SDU to be compressed */
+Buffer   **opSdu;                 /* Compressed SDU */
+#endif
+{
+   S16 ret = ROK;
+#ifdef PJ_CMP_ASYNC
+   PjLibTrans libTrans; /* Transaction Id for compression */
+#else
+   Buffer *feedback  = NULLP;
+#endif /* PJ_CMP_ASYNC */
+
+   TRC3(pjUtlDeCmpReq)
+
+#ifdef ALIGN_64BIT
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), 
+          (gCb->init.prntBuf, "pjUtlDeCmpReq(pjRbCb(%d,%d), count(%d))\n",\
+                    pjRbCb->rbId, pjRbCb->rbType, count));
+#else
+   PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), 
+          (gCb->init.prntBuf, "pjUtlDeCmpReq(pjRbCb(%d,%d), count(%ld))\n",\
+                    pjRbCb->rbId, pjRbCb->rbType, count));
+#endif
+#ifdef PJ_CMP_ASYNC
+   /* Assign transId and cxtId */
+   libTrans.count  = count;
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   libTrans.rbId   = pjRbCb->rbId - 1;
+   libTrans.rbType = pjRbCb->rbType;
+   libTrans.ueCb   = (PTR)pjRbCb->ueCb;
+
+   /* Start the timer if it is not started already */
+   if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE)
+   {
+      pjRbCb->ulCb.obdPdu   =  count;
+      pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
+   }
+
+   ret = PjLibObdDecmpReq(&(gCb->pjGenCfg.obdPst.cmpPst), 
+                                      pjRbCb->cmpCxtId, libTrans, mBuf);  
+#else
+   ret = pjLibDecmpReq(pjRbCb->cmpCxtId, mBuf, &feedback, opSdu);
+
+   if(feedback != NULLP)
+   {
+      pjUtlUlSndUlRohcFdbk(gCb,pjRbCb,feedback);
+   }
+#endif
+
+   RETVALUE(ret);
+
+} /* end of pjUtlDeCmpReq */
+
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for redirecing compression request to either synchronous
+ *        or asynchronous module.
+ *
+ * @b Description:
+ *
+ *        This function sends compression request as either synchronous or
+ *        asynchronous function calls with relevant input parameters.
+ *
+ *  @param[in]   pjRbCb           PDCP RbCb
+ *  @param[in]   feedback         ROHC Feedback
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlSndFeedback
+(
+PjCb     *gCb,
+PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
+Buffer   *feedback                /* ROHC Feedback */
+)
+#else
+PUBLIC S16 pjUtlSndFeedback(pjRbCb, feedback)
+PjCb     *gCb;
+PjUlRbCb   *pjRbCb;                 /* PDCP RbCb */
+Buffer   *feedback;               /* Feedback */
+#endif
+{
+#ifdef PJ_CMP_ASYNC
+   PjLibTrans libTrans; /* Transaction Id for compression */
+#endif /* PJ_SEC_ASYNC */
+
+   TRC3(pjUtlSndFeedback)
+
+   RLOG2(L_DEBUG, "pjUtlCmpReq(pjRbCb(%d,%d))",
+                    pjRbCb->rbId, pjRbCb->rbType);
+
+#ifdef PJ_CMP_ASYNC
+   /* Assign transId and cxtId */
+   libTrans.count  = pjRbCb->ulCb.rxDeliv - 1;
+   /* pj005.201 ccpu00114955 corrected the RB ID calculation */
+   libTrans.rbId   = pjRbCb->rbId - 1;
+   libTrans.rbType = pjRbCb->rbType;
+   libTrans.ueCb   = (PTR)pjRbCb->ueCb;
+
+   PjLibObdCmpFbReq(&(gCb->pjGenCfg.obdPst.cmpPst), pjRbCb->cmpCxtId, libTrans,
+         feedback);
+#else
+   pjLibCmpFbReq(pjRbCb->cmpCxtId, feedback);
+#endif
+
+   RETVALUE(ROK);
+
+} /* end of pjUtlSndFeedback */
+
+/**
+ *
+ * @brief 
+ *
+ *        Handler for closing the context with the compression unit (either 
+ *        synchronous or asynchronous) for RB within an UE.
+ *
+ * @b Description:
+ *
+ *        This function closes an existing context with the compression unit per RB per
+ *        UE, either using synchronous / asynchronous function calls with relevant input parameters.
+ *
+ *
+ *  @param[in] cmpCxtId         ROHC Context to be closed
+ *
+ *  @return  S16
+ *      -# ROK 
+ *
+ */
+#ifdef ANSI
+PUBLIC S16 pjUtlCmpClose
+(
+PjCb     *gCb,
+PTR      cmpCxtId                 /* ROHC Context to be closed */
+)
+#else
+PUBLIC S16 pjUtlCmpClose(cmpCxtId)
+PjCb     *gCb;
+PTR      cmpCxtId;                /* ROHC Context to be closed */
+#endif
+{
+   TRC3(pjUtlCmpClose)
+
+   RLOG1(L_DEBUG, "pjUtlCmpClose(cmpCxtId(%ld))", cmpCxtId);
+
+#ifndef PJ_CMP_ASYNC
+   pjLibCmpCloseReq(cmpCxtId);
+#else
+   PjLibObdCmpCloseReq(&gCb->pjGenCfg.obdPst.cmpPst, cmpCxtId);
+#endif
+
+   RETVALUE(ROK);
+
+} /* end of pjUtlCmpClose */
+
+
+
+/* pj005.201 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS_COMMENT
+\f
+/**
+ *
+ * @brief Handler for L2 Measurement timer expiry.
+ *
+ *
+ * @b Description
+ *        This function is called when the l2 measurement timer expires. 
+ *        This function sends a consolidates the mesaurements taken during
+ *        this time and sends the confirm .
+ *
+ *  @param[in] measEvtCb    Measurement Event Control Block.
+ *
+ *
+ *  @return  S16
+ *      -# ROK
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUtlHdlL2TmrExp
+(
+PjL2MeasEvtCb *measEvtCb
+)
+#else
+PUBLIC S16 pjUtlHdlL2TmrExp(measEvtCb)
+PjL2MeasEvtCb *measEvtCb;
+#endif
+{
+   CmLList        *node;
+   U32            idx;
+   PjL2MeasCb     *measCb;
+   PjL2MeasCfmEvt measCfmEvt;
+   PjRbCb         *pjRbCb;
+   PjTxEnt        *txEnt      = NULLP;
+   U8             qciIdx;
+
+   TRC3(pjUtlHdlL2TmrExp)
+
+   RLOG1,"pjUtlHdlL2TmrExp(transId(%ld))", measEvtCb->transId);
+
+   measCb = &measEvtCb->measCb;
+   while((node = cmLListFirst(&measCb->rbList)))
+   {
+      node = cmLListDelFrm(&measCb->rbList, node);
+      pjRbCb = (PjRbCb *) node->node;
+
+      /* Cleanup any pending buffers which were not acked */
+      if(measCb->measType & LPJ_L2MEAS_DL_DELAY)
+      {
+         for(idx = pjRbCb->rbL2Cb.startCount; idx < pjRbCb->dlCb.count; idx++)
+         {
+            if((txEnt = pjDbmGetTxEnt( &(pjRbCb->dlCb.txBuf), idx)) == NULLP)
+            {
+               continue;
+            }
+            if(txEnt->state != PJ_PDU_SUBMITTED)
+            {
+               break;
+            }
+            pjDbmDelTxEnt( &(pjRbCb->dlCb.txBuf), idx);
+         }
+         pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DELAY]   =  NULLP;
+      }
+      if(measCb->measType & PJ_L2MEAS_ACT_UE)
+      {
+         pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_ACT_UE]   =  NULLP;
+      }
+      if(measCb->measType & PJ_L2MEAS_DL_DISC )
+      {
+         pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DISC]   =  NULLP;
+      }
+      if(measCb->measType & PJ_L2MEAS_UL_LOSS)
+      {
+         pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]   =  NULLP;
+      }
+    }/* End of while loop */
+   /* Initialize measCfmEvt */
+   cmMemset((U8 *) &measCfmEvt, 0, sizeof(PjL2MeasCfmEvt));
+
+   measCfmEvt.transId = measEvtCb->transId;
+   measCfmEvt.numQciCfm = 0;
+   /* Fill the measCfmEvt structure */
+   for(qciIdx = 0; qciIdx < measCb->numQci; qciIdx++)
+   {
+      pjCb.pjL2Cb.measOn[measCb->qci[qciIdx]] &= ~measCb->measType;
+      measCfmEvt.measType = measCb->measType;
+      measCfmEvt.measCfm[measCfmEvt.numQciCfm].qci = measCb->qci[qciIdx];
+      measCfmEvt.status.status = LCM_PRIM_OK;
+      measCfmEvt.status.reason = LCM_REASON_NOT_APPL;
+      if((measCb->measType &  LPJ_L2MEAS_DL_DELAY) &&
+         (measCb->measData[measCb->qci[qciIdx]].dlDelay.numPkts > 0))
+      {
+         /* Packed delay is in ms */
+         measCfmEvt.measCfm[measCfmEvt.numQciCfm].dlDelay = 
+         (measCb->measData[measCb->qci[qciIdx]].dlDelay.val / 
+         measCb->measData[measCb->qci[qciIdx]].dlDelay.numPkts);
+      }
+      if((measCb->measType & LPJ_L2MEAS_DL_DISC) &&
+         (measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts > 0))
+      {
+         /* dlDisc = num of Pkts Discarded * 10^6 / total no of pkts. */
+         measCfmEvt.measCfm[measCfmEvt.numQciCfm].dlDisc = 
+         measCb->measData[measCb->qci[qciIdx]].dlDisc.val  * (1000000) /
+         measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts;
+      }
+      if((measCb->measType &  LPJ_L2MEAS_UL_LOSS) &&
+         (measCb->measData[measCb->qci[qciIdx]].ulLoss.numPkts > 0))
+      {
+         /* ul Loss  = num of Pkts lost * 10^6 / total no of pkts. */
+         measCfmEvt.measCfm[measCfmEvt.numQciCfm].ulLoss  =
+         measCb->measData[measCb->qci[qciIdx]].ulLoss.val  * (1000000) /
+         measCb->measData[measCb->qci[qciIdx]].ulLoss.numPkts;
+      }
+      measCfmEvt.numQciCfm++;
+   }
+
+   pjCb.pjL2Cb.pjMeasEvtCb[measEvtCb->cbIdx] = NULLP;
+   PJ_FREE(measEvtCb, sizeof(PjL2MeasEvtCb));
+   pjCb.pjL2Cb.pjNumMeas--;
+
+   /* Send Measurement confirmation to layer manager */
+   PjMiLpjL2MeasCfm(&pjCb.pjGenCfg.lmPst,&measCfmEvt);
+
+   RETVALUE(ROK);
+} /* pjUtlHdlL2TmrExp */
+\f
+/**
+ *
+ * @brief Handler for Sending Negative confirm .
+ *
+ *
+ * @b Description
+ *        This function is called when the l2 measurement cannot be started
+ *        This function sends  negative confirm for all the requests
+ *
+ *  @param[in] measReqEvt    Measurement Req Structure
+ *
+ *
+ *  @return  S16
+ *      -# ROK
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUtlSndL2MeasNCfm
+(
+PjL2MeasReqEvt  *measReqEvt,
+PjL2MeasCfmEvt  *measCfmEvt
+)
+#else
+PUBLIC S16 pjUtlSndL2MeasNCfm(measReqEvt, measCfmEvt)
+PjL2MeasReqEvt  *measReqEvt;
+PjL2MeasCfmEvt  *measCfmEvt;
+#endif
+{
+
+   TRC3(pjUtlSndL2MeasNCfm)
+
+   RLOG1,"pjUtlSndL2MeasNCfm(transId(%ld))", measReqEvt->transId);
+
+   PjMiLpjL2MeasCfm(&pjCb.pjGenCfg.lmPst, measCfmEvt);
+
+   RETVALUE(ROK);
+} /* pjUtlSndL2MeasNCfm */
+#endif
+
+#ifdef FLAT_BUFFER_OPT
+/**
+ *
+ * @brief 
+ *
+ *       Handler to move the 'FlatBuffer' into 'Buffer' 
+ *
+ * @b Description: 
+ *
+ *            
+ *  @param[in] gCb         Global PDCP control block. 
+ *  @param[in] FlatBuffer  'FlatBuffer' ptr to be converted. 
+ *  @param[in_out] Buffer  Output mBuf. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUtlConvFbToBuf
+(
+PjCb       *gCb,
+FlatBuffer *fb,
+Buffer     **mBuf
+)
+#else
+PUBLIC S16 pjUtlConvFbToBuf(gCb, fb, mBuf)
+PjCb       *gCb;
+FlatBuffer *fb;
+Buffer     **mBuf;
+#endif
+{
+   S16 ret;
+
+   TRC3(pjUtlConvFbToBuf);
+#ifdef T2K_MEM_LEAK_DBG
+   ret = SAttachPtrToBufNew(gCb->init.region,
+         gCb->init.pool,
+         fb->ptr,
+         fb->len,
+         mBuf,
+         __FILE__,
+         __LINE__);
+#else
+   ret = SAttachPtrToBuf(gCb->init.region,
+         gCb->init.pool,
+         fb->ptr,
+         fb->len,
+         mBuf);
+
+#endif
+   if(ret != ROK)
+   {
+      RLOG0(L_ERROR,"SAttachPtrToBuf failed !!!!!");
+   }
+
+   RETVALUE(ret);
+}
+
+
+/**
+ *
+ * @brief 
+ *
+ *       Handler to copy a 'FlatBuffer' to 'Buffer' 
+ *
+ * @b Description: 
+ *
+ *            
+ *  @param[in] gCb         Global PDCP control block. 
+ *  @param[in] FlatBuffer  'FlatBuffer' to be converted. 
+ *  @param[in_out] Buffer  Output mBuf. 
+ *
+ *  @return  S16
+ *      -# ROK 
+ *      -# RFAILED
+ *
+ */
+
+#ifdef ANSI
+PUBLIC S16 pjUtlCopyFbToBuf
+(
+PjCb       *gCb,
+FlatBuffer *fb,
+Buffer     **mBuf
+)
+#else
+PUBLIC S16 pjUtlCopyFbToBuf(gCb, fb, mBuf)
+PjCb       *gCb;
+FlatBuffer *fb;
+Buffer     **mBuf;
+#endif
+{
+   U8 *opPdu;
+   S16 ret;
+
+   TRC3(pjUtlCopyFbToBuf);
+#ifdef INTEL_WLS
+      SGetSBufWls(gCb->init.region, gCb->init.pool,
+                  (Data **)&(opPdu), fb->len + 128);
+   
+      //cmMemcpy(opPdu + 2, fb->ptr, fb->len);
+      cmMemcpy(opPdu + 128, fb->ptr, fb->len);
+
+      ret = SAttachWlsPtrToMBuf(gCb->init.region,
+                                gCb->init.pool,
+                                opPdu,
+                                opPdu + 128,
+                                fb->len,
+                                fb->len + 128,
+                                mBuf);
+#else
+
+   if((SGetStaticBuffer(gCb->init.region,
+               gCb->init.pool,
+               (Data
+                **)&(opPdu),
+               fb->len,
+               SS_SHARABLE_MEMORY)
+            != ROK))
+   {
+      RLOG0(L_ERROR,"SGetStaticBuffer failed !!!!!");
+      RETVALUE(RFAILED);
+   }
+
+   cmMemcpy(opPdu, fb->ptr, fb->len);
+   /*RLOG1(L_ERROR,"Data forwarding: PDCP SN %d is converted to mBuf",
+    * txEnt->sn); */
+#ifdef T2K_MEM_LEAK_DBG
+   ret = SAttachPtrToBufNew(gCb->init.region,
+         gCb->init.pool,
+         opPdu,
+         fb->len,
+         mBuf,
+         __FILE__,
+         __LINE__);
+#else
+   ret = SAttachPtrToBuf(gCb->init.region,
+         gCb->init.pool,
+         opPdu,
+         fb->len,
+         mBuf);
+#endif 
+
+#endif
+   if(ret != ROK)
+   {
+      RLOG0(L_ERROR,"SAttachPtrToBuf failed !!!!!");
+   }
+
+   RETVALUE(ret);
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/cm/cpj.h b/src/cm/cpj.h
new file mode 100755 (executable)
index 0000000..0d078f8
--- /dev/null
@@ -0,0 +1,307 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE PDCP Interface  
+    
+        Type:    C include file
+  
+        Desc:    This file contains the defines required by PDCP user
+        File:    cpj.h
+  
+*********************************************************************21*/
+#ifndef __CPJ_H__
+#define __CPJ_H__
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif  /*for extern "C"*/
+
+/**
+ * @file 
+ * @brief Macro for CPJ Interface 
+ */
+
+#define CPJ_SEL_LC           0   /* CPJ loose couple selector */
+
+#define CPJ_7BIT_SN_SIZE     7               /*!< Sequence length is 7-bit */
+#define CPJ_12BIT_SN_SIZE    12              /*!< Sequence length is 12-bit */
+#define CPJ_MAX_CFG    10                    /*!< Maximum PDCP entity to be configured */ 
+#define CPJ_MAX_DRB    12                    /*!< Maximum DRBs per UE */
+
+/* CPJ Configuration Failure Reasons */
+#define CPJ_CFG_REAS_NONE                  0  /*!< No Failure */
+#define CPJ_CFG_REAS_ENT_CREAT_FAIL        1  /*!< PDCP Entity Creation Failure*/
+#define CPJ_CFG_REAS_UE_CREAT_FAIL         2  /*!< UE CB Creation Failure */
+#define CPJ_CFG_REAS_INVALID_PDCPID        3  /*!< Invalid PDCP ID */
+#define CPJ_CFG_REAS_PDCPID_PRSNT          4  /*!< PDCP ID already present */
+#define CPJ_CFG_REAS_INVALID_RLCMODE       5  /*!< Invalid RLC Mode */
+#define CPJ_CFG_REAS_PDCPID_UNKWN          6  /*!< PDCP ID Unknown */
+#define CPJ_CFG_REAS_UE_UNKWN              7  /*!< UE Cb Unknown */
+#define CPJ_CFG_REAS_CIPHER_ALGO_INVALID   8  /*!< Invalid Cipher Algo */
+#define CPJ_CFG_REAS_ENT_DEL_FAIL          9  /*!< PDCP Entity Deletion Failure */
+#define CPJ_CFG_REAS_UE_DEL_FAIL           10 /*!< UE Cb Deletion Failure */
+#define CPJ_CFG_REAS_REEST_FAIL            11 /*!< PDCP Reestablish Failure */
+#define CPJ_CFG_REAS_COMP_ALGO_INVALID     12 /*!< Compression Algo not
+                                               supported */
+#define CPJ_CFG_REAS_RECFG_FAIL            13 /*!< PDCP Reconfiguration Failed */
+#define CPJ_CFG_REAS_INVALID_CFG           14 /*!< Invalid Configuration Type */
+#define CPJ_CFG_REAS_SAME_UEID             15 /*!< UE IDs match in ChngUeId 
+                                                   Request*/
+#define CPJ_CFG_REAS_SAME_RBID             16 /*!< UE IDs match in ChngUeId 
+                                                   Request */
+#define CPJ_CFG_REAS_INVALID_RBID          17 /*!< Invalid RB ID */
+
+#define  CPJ_CFG_REAS_INTINIT_FAILED      18 /*!< Integrity Init Failed */
+#define  CPJ_CFG_REAS_CCIPHR_FAILED       19 /*!< Control Plane Cihper Init Failed */
+#define  CPJ_CFG_REAS_UCIPHR_FAILED       20 /*!< User Plane Cipher Init Failed */
+
+#define  CPJ_CFG_REAS_NO_DRBS             21 /*!< No DRBs Present */
+#define  CPJ_CFG_REAS_OBD_TIMEOUT         22 /*!< No DRBs Present */
+#define  CPJ_CFG_REAS_INVALID_STATE       23 /*!< Invalid state to perform re-establishment */
+
+#define CPJ_CFG_TRANSID_SIZE               9 /*!< Macro for Transaction ID size */
+
+/* CPJ Configuration confirmations */
+#define CPJ_CFG_CFM_OK                      1 /*!< Confirm status OK */
+#define CPJ_CFG_CFM_NOK                     2 /*!< Confirm status NOK */
+   
+/*Event Code*/
+#define CPJ_EVC_RESET_FAILED                1 /*!< Reset Failed */ 
+
+#define EVTCPJBNDREQ         0x20            /*!< Bind Request */
+#define EVTCPJBNDCFM         0x21            /*!< Bind Confirmation */ 
+#define EVTCPJUBNDREQ        0x22            /*!< Unbind Request */
+#define EVTCPJCFGREQ         0x23            /*!< Config Request */
+#define EVTCPJCFGCFM         0x24            /*!< Config Confirmation */
+#define EVTCPJUEIDCHGREQ     0x25            /*!< UE ID Change Request */ 
+#define EVTCPJUEIDCHGCFM     0x26            /*!< UE ID Change Confirmation */
+#define EVTCPJSECCFGREQ      0x27            /*!< Security Config Request */
+#define EVTCPJSECCFGCFM      0x28            /*!< Security Config Confirm */
+#define EVTCPJREESTREQ       0x29            /*!< Count C Request */
+#define EVTCPJREESTCFM       0x2A            /*!< Count C Confirm */
+#define EVTCPJCOUNTREQ       0x2B            /*!< Count C Request */
+#define EVTCPJCOUNTCFM       0x2C            /*!< Count C Confirm */
+#define EVTCPJSDUSTAREQ      0x2D            /*!< SDU Status Request */
+#define EVTCPJSDUSTACFM      0x2E            /*!< SDU Status Confirm */
+#define EVTCPJKDFREQ         0x2F            /*!< Key derivation primitive
+                                                  request event*/
+#define EVTCPJKDFCFM         0x30            /*!< Configuration Confirm
+                                                  event*/
+#define EVTCPJSTARTDATAFWDREQ      0x31            /*!< Data Forward Request */
+#define EVTCPJDATRESUMEREQ      0x32            /*!< Data Resume Request */
+#define EVTCPJDATRESUMECFM      0x33            /*!< Data Resume Confirm */
+
+#define CPJ_CIPHER_KEY_LEN       16          /*!< Ciphering key length */
+#define CPJ_INTG_KEY_LEN         16          /*!< Integrity key length */
+#define CPJ_MAX_ROHC_PROF_LIST   9           /*!< ROHC profile list */
+#define CPJ_MAX_CFM              10          /*!< Maximum number of confirm */ 
+
+#define CPJ_CFG_ADD            0x01          /*!< Configure new PDCP entity
+                                               in the requested UE */
+#define CPJ_CFG_MODIFY         0x02          /*!< Reconfigure PDCP entity
+                                               in the requested UE */
+#define CPJ_CFG_DELETE         0x03          /*!< Delete PDCP entity
+                                               in the requested UE */
+#define CPJ_CFG_REESTABLISH    0x04          /*!< Reestablish PDCP entity
+                                               in the requested UE */
+#define CPJ_CFG_DELETE_UE      0x05          /*!< Delete UE in PDCP */
+
+
+#define CPJ_SEC_INTG_INFO      0x01          /*!< Integrity information */
+#define CPJ_SEC_CIPHER_INFO    0x02          /*!< Ciphering information */
+
+#ifdef CPJ_V2
+#define CPJ_SEC_ALG_NULL       0x00          /*!< NULL algorithm */
+#define CPJ_SEC_ALG_SNOW3G     0x01          /*!< Snow 3G algorithm */
+#define CPJ_SEC_ALG_AES        0x02          /*!< AES algorithm */
+#define CPJ_SEC_ALG_ZUC        0x03          /*!< ZUC algorithm */
+#else
+#define CPJ_SEC_ALG_NULL       0x01          /*!< NULL algorithm */
+#define CPJ_SEC_ALG_SNOW3G     0x02          /*!< Snow 3G algorithm */
+#define CPJ_SEC_ALG_AES        0x03          /*!< AES algorithm */
+#define CPJ_SEC_ALG_ZUC        0x04          /*!< ZUC algorithm */
+#endif
+
+
+/* Defines which is used in ModCfg to set the bitflag */
+#define CPJ_RECFG_DISRQD  0x01               /*!< Discard Required is present*/
+#define CPJ_RECFG_CFMREQ  0x02               /*!< Confirm Required is present */
+#define CPJ_RECFG_REORDTMR  0x04             /*!< t-Reorder reconfiguration is present */
+
+/* Flags will be used to fill the Hand off information */
+#define CPJ_HO_NOT_PRSNT  0       /*!< Hand of Info is not present */
+#define CPJ_HO_UL         1       /*!< Uplink count present */
+#define CPJ_HO_DL         2       /*!< Downlink count present */
+
+
+#define CPJ_KDF_TYPE1     0       /*!< eNodeB key type for for deriving eNodeB*
+                                       Key(Horizontal key derivation 
+                                       ref: ts 33.401)*/ 
+#define CPJ_KDF_TYPE2     1       /*!< eNodeB key type for for deriving AS
+                                       security keys */
+#define CPJ_KDF_TYPE3     2       /*!< NH key type for for deriving eNodeB* Key
+                                       (Verticall key derivation
+                                       ref: ts 33.401) */
+
+#define CPJ_SEC_KEY_LEN   32      /*!< size of the security keys*/
+
+/* cpj_h_001.main_2 added support for L2 Measurement */   
+#ifdef LTE_L2_MEAS
+#define CPJ_MAX_QCI           10
+#endif
+
+/* Error Codes */
+#define ECPJXXX              0   
+#define ERRCPJ               0
+
+#define ECPJ001         (ERRCPJ + 1)
+#define ECPJ002         (ERRCPJ + 2)
+#define ECPJ003         (ERRCPJ + 3)
+#define ECPJ004         (ERRCPJ + 4)
+#define ECPJ005         (ERRCPJ + 5)
+#define ECPJ006         (ERRCPJ + 6)
+#define ECPJ007         (ERRCPJ + 7)
+#define ECPJ008         (ERRCPJ + 8)
+#define ECPJ009         (ERRCPJ + 9)
+#define ECPJ010         (ERRCPJ + 10)
+#define ECPJ011         (ERRCPJ + 11)
+#define ECPJ012         (ERRCPJ + 12)
+#define ECPJ013         (ERRCPJ + 13)
+#define ECPJ014         (ERRCPJ + 14)
+#define ECPJ015         (ERRCPJ + 15)
+#define ECPJ016         (ERRCPJ + 16)
+#define ECPJ017         (ERRCPJ + 17)
+#define ECPJ018         (ERRCPJ + 18)
+#define ECPJ019         (ERRCPJ + 19)
+#define ECPJ020         (ERRCPJ + 20)
+#define ECPJ021         (ERRCPJ + 21)
+#define ECPJ022         (ERRCPJ + 22)
+#define ECPJ023         (ERRCPJ + 23)
+#define ECPJ024         (ERRCPJ + 24)
+#define ECPJ025         (ERRCPJ + 25)
+#define ECPJ026         (ERRCPJ + 26)
+#define ECPJ027         (ERRCPJ + 27)
+#define ECPJ028         (ERRCPJ + 28)
+#define ECPJ029         (ERRCPJ + 29)
+#define ECPJ030         (ERRCPJ + 30)
+#define ECPJ031         (ERRCPJ + 31)
+#define ECPJ032         (ERRCPJ + 32)
+#define ECPJ033         (ERRCPJ + 33)
+#define ECPJ034         (ERRCPJ + 34)
+#define ECPJ035         (ERRCPJ + 35)
+#define ECPJ036         (ERRCPJ + 36)
+#define ECPJ037         (ERRCPJ + 37)
+#define ECPJ038         (ERRCPJ + 38)
+#define ECPJ039         (ERRCPJ + 39)
+#define ECPJ040         (ERRCPJ + 40)
+#define ECPJ041         (ERRCPJ + 41)
+#define ECPJ042         (ERRCPJ + 42)
+#define ECPJ043         (ERRCPJ + 43)
+#define ECPJ044         (ERRCPJ + 44)
+#define ECPJ045         (ERRCPJ + 45)
+#define ECPJ046         (ERRCPJ + 46)
+#define ECPJ047         (ERRCPJ + 47)
+#define ECPJ048         (ERRCPJ + 48)
+#define ECPJ049         (ERRCPJ + 49)
+#define ECPJ050         (ERRCPJ + 50)
+#define ECPJ051         (ERRCPJ + 51)
+#define ECPJ052         (ERRCPJ + 52)
+#define ECPJ053         (ERRCPJ + 53)
+#define ECPJ054         (ERRCPJ + 54)
+#define ECPJ055         (ERRCPJ + 55)
+#define ECPJ056         (ERRCPJ + 56)
+#define ECPJ057         (ERRCPJ + 57)
+#define ECPJ058         (ERRCPJ + 58)
+#define ECPJ059         (ERRCPJ + 59)
+#define ECPJ060         (ERRCPJ + 60)
+#define ECPJ061         (ERRCPJ + 61)
+#define ECPJ062         (ERRCPJ + 62)
+#define ECPJ063         (ERRCPJ + 63)
+#define ECPJ064         (ERRCPJ + 64)
+#define ECPJ065         (ERRCPJ + 65)
+#define ECPJ066         (ERRCPJ + 66)
+#define ECPJ067         (ERRCPJ + 67)
+#define ECPJ068         (ERRCPJ + 68)
+#define ECPJ069         (ERRCPJ + 69)
+#define ECPJ070         (ERRCPJ + 70)
+#define ECPJ071         (ERRCPJ + 71)
+#define ECPJ072         (ERRCPJ + 72)
+#define ECPJ073         (ERRCPJ + 73)
+#define ECPJ074         (ERRCPJ + 74)
+#define ECPJ075         (ERRCPJ + 75)
+#define ECPJ076         (ERRCPJ + 76)
+#define ECPJ077         (ERRCPJ + 77)
+#define ECPJ078         (ERRCPJ + 78)
+#define ECPJ079         (ERRCPJ + 79)
+#define ECPJ080         (ERRCPJ + 80)
+#define ECPJ081         (ERRCPJ + 81)
+#define ECPJ082         (ERRCPJ + 82)
+#define ECPJ083         (ERRCPJ + 83)
+#define ECPJ084         (ERRCPJ + 84)
+#define ECPJ085         (ERRCPJ + 85)
+#define ECPJ086         (ERRCPJ + 86)
+#define ECPJ087         (ERRCPJ + 87)
+#define ECPJ088         (ERRCPJ + 88)
+#define ECPJ089         (ERRCPJ + 89)
+#define ECPJ090         (ERRCPJ + 90)
+#define ECPJ091         (ERRCPJ + 91)
+#define ECPJ092         (ERRCPJ + 92)
+#define ECPJ093         (ERRCPJ + 93)
+#define ECPJ094         (ERRCPJ + 94)
+#define ECPJ095         (ERRCPJ + 95)
+#define ECPJ096         (ERRCPJ + 96)
+#define ECPJ097         (ERRCPJ + 97)
+#define ECPJ098         (ERRCPJ + 98)
+#define ECPJ099         (ERRCPJ + 99)
+#define ECPJ100         (ERRCPJ + 100)
+#define ECPJ101         (ERRCPJ + 101)
+#define ECPJ102         (ERRCPJ + 102)
+#define ECPJ103         (ERRCPJ + 103)
+#define ECPJ104         (ERRCPJ + 104)
+#define ECPJ105         (ERRCPJ + 105)
+#define ECPJ106         (ERRCPJ + 106)
+#define ECPJ107         (ERRCPJ + 107)
+#define ECPJ108         (ERRCPJ + 108)
+#define ECPJ109         (ERRCPJ + 109)
+#define ECPJ110         (ERRCPJ + 110)
+#define ECPJ111         (ERRCPJ + 111)
+#define ECPJ112         (ERRCPJ + 112)
+#define ECPJ113         (ERRCPJ + 113)
+#define ECPJ114         (ERRCPJ + 114)
+#define ECPJ115         (ERRCPJ + 115)
+#define ECPJ116         (ERRCPJ + 116)
+#define ECPJ117         (ERRCPJ + 117)
+#define ECPJ118         (ERRCPJ + 118)
+#define ECPJ119         (ERRCPJ + 119)
+#define ECPJ120         (ERRCPJ + 120)
+#define ECPJ121         (ERRCPJ + 121)
+#define ECPJ122         (ERRCPJ + 122)
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __CPJ_H__ */
+
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/cm/cpj.x b/src/cm/cpj.x
new file mode 100755 (executable)
index 0000000..d28df1a
--- /dev/null
@@ -0,0 +1,1655 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE PDCP Interface  
+    
+        Type:    C include file
+  
+        Desc:    This file contains the Data structures for LTE PDCP Interface
+        File:    cpj.x
+  
+*********************************************************************21*/
+#ifndef __CPJ_X__
+#define __CPJ_X__
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif  /*for extern "C"*/
+
+/**
+ * @file 
+ * @brief CPJ Interface file
+ */
+
+/*************************************************************************
+ *                      START OF STRUCTURES
+ ************************************************************************/
+/**
+ * @brief
+ * Cipher Key type information.
+ */
+typedef U8        CpjCipherKey;
+
+/**
+ * @brief
+ * Integrity Key type information.
+ */
+typedef U8        CpjIntegrityKey;
+
+/**
+  * @brief
+  * RLC Parameter Information in AM mode.
+ */
+typedef struct cpjRlcAm
+{
+   Bool           statusRepReqd; /*!< Status report required */
+   U8             pdcpSNSize; /*!< Length of PDCP sequence number */
+}CpjRlcAm;
+
+/**
+ * @brief
+ * RLC Parameter Information in UM mode.
+ */
+typedef struct cpjRlcUm
+{
+   U8             pdcpSNSize; /*!< Length of PDCP sequence number */
+}CpjRlcUm;
+
+/**
+ * @brief
+ * Mapped RLC Entity Information in RLC for the PDCP Entity
+ */
+typedef struct cpjRlcInfo
+{
+   U8             dir;       /*!< UPLINK/DOWNLINK/BOTH */
+   U8             mode;      /*!< RLC Mode */ 
+   union
+   {
+      CpjRlcAm    rlcAm;     /*!< RLC in AM mode */
+      CpjRlcUm    rlcUm;     /*!< RLC in UM mode */
+   }m;
+}CpjRlcInfo;
+
+
+/**
+ * @brief
+ * Ciphering Information to be configured per UE in PDCP.
+ */
+typedef struct cpjCipherInfo         
+{
+   CpjCipherKey   ctrlplnKey[CPJ_CIPHER_KEY_LEN];   /*!< Control plane
+                                                        ciphering key */
+   CpjCipherKey   usrplnKey[CPJ_CIPHER_KEY_LEN];    /*!< User plane
+                                                        ciphering key */
+   U8             algoType;                         /*!< Algorithm type.
+                                                    Allowed values are:
+                                                    -# CPJ_SEC_ALG_NULL 
+                                                    -# CPJ_SEC_ALG_SNOW3G
+                                                    -# CPJ_SEC_ALG_AES
+                                                    */
+}CpjCipherInfo;
+
+/**
+ * @brief
+ * Integrity protection paramater information. 
+*/
+typedef struct cpjIntegInfo
+{
+   U8                algoType;                  /*!< Algorithm type.
+                                                   Allowed values are:
+                                                   -# CPJ_SEC_ALG_AES
+                                                   -# CPJ_SEC_ALG_SNOW3G
+                                                   */
+   CpjIntegrityKey   intKey[CPJ_INTG_KEY_LEN];  /*!< Integrity key */
+} CpjIntegInfo;
+
+/**
+ * @brief
+ * PDCP Security configuration parameter.
+ */
+typedef struct cpjSecCfg 
+{
+   Bool           selSecAct;        /*!< Selective security activation flag.
+
+   PDCP applies only Integrity algorithm for the first UL and first DL
+   messages (security activation procedure), applies both Integrity and
+   ciphering for all the other messages (including handover which involves
+   reconfiguration messages). selSecAct enables to identify whether
+   PDCP needs to selectively apply only Integrity for first UL/DL message.
+   */
+   U8             isHo;
+   CpjIntegInfo   integInfo;        /*!< Integrity configuration */
+   CpjCipherInfo  cipherInfo;       /*!< Ciphering configuration */
+} CpjSecCfg;
+
+/**
+ * @brief
+ * ROHC Compression protocol information structure. 
+ */
+typedef struct cpjRohcInfo
+{
+   U16            maxCid;                          /*!< Maximum CID */
+   Bool           profLst[CPJ_MAX_ROHC_PROF_LIST]; /*!< ROHC profile
+                                                     information */
+}CpjRohcInfo;
+
+/**
+ * @brief
+ * ROHC Configuration information for PDCP entity. 
+ */
+typedef struct cpjHdrCompCfg
+{
+   Bool           hdrCompUsed;   /*!< Header Compression Used/Not */
+   CpjRohcInfo    rohcInfo;      /*!< ROHC configuration information */
+}CpjHdrCompCfg;
+
+/**
+ * @brief
+ * Handover Information for RB.
+ */
+typedef struct cpjHoInfo
+{
+   U8             isHoPres;   /*!< Last 2bits (from LSB)is used to convey handover information is present or
+                                not. @n Allowed values are:
+                                    -# CPJ_HO_NOT_PRSNT  00
+                                    -# CPJ_HO_UL         01
+                                    -# CPJ_HO_DL         10
+                                    */
+   U8            snLen;          /*!< PDCP SN len  12/15 bit */
+   U32            dlCount;       /*!< DL COUNT to assign for new SDUs */
+   U32            ulCount;       /*!< UL First Missing SN */
+   U16             numBits;       /*!< Number of bits in UL bitmap */
+   U8             *ulBitMap;     /*!< UL SN bitmap excluding FMS to be used 
+                                      as status report */
+} CpjHoInfo;
+
+/**
+ * @brief
+ * Configuraiton Structure to add an RB.
+ */
+typedef struct cpjAddCfgEnt
+{        
+   Bool           discReqd;   /*!< Discard required/not for PDUs
+                                with Integrity Verification failure */
+   Bool           cfmReqd;    /*!< Confirm required/not for SDUs 
+                                received by the peer PDCP entity. */
+  /* cpj_x_001.main_3 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+   U8             qci;        /*!< qCI value Associated with that RB */
+#endif /* LTE_L2_MEAS */
+
+   CpjRlcInfo     rlcInfo;    /*!< Corresponding RLC entity information. */
+   S16            discardTmr; /*!< Discard timer. @n The value for this parameter
+                                is expected in milli seconds. @n Value of infinity
+                                is also allowed and -1 must be passed for
+                                the same. */
+   U16          reOrdrTmrVal; /*!< t-Reorder Timer value in milli sec */
+   CpjHdrCompCfg  hdrCompCfg; /*!< PDCP compression information */
+}CpjAddCfgEnt;         
+         
+/**
+ * @brief
+ * Configuraiton Structure to modify an RB.
+ */
+typedef struct cpjModCfgEnt
+{
+      
+   U8             bitFlag;     /*!< List of Modified Elements 
+                                   Each bit respresents one element  */
+
+   Bool           discReqd;   /*!< Discard required/not for PDUs
+                                with Integrity Verification failure.
+                                bitFlag=0x01 */
+   Bool           cfmReqd;    /*!< Confirm required/not for SDUs 
+                                received by the peer PDCP entity.
+                                bitFlag=0x02 */
+   CpjHdrCompCfg  hdrCompCfg; /*!< PDCP compression information */
+   CpjHoInfo      hoInfo;     /*!< Handover Information */
+   U16          reOrdrTmrVal; /*!< t-Reorder Timer value */
+}CpjModCfgEnt;
+
+
+/**
+ * @brief
+ * Configuration structure for PDCP entity. 
+ */
+typedef struct cpjCfgEnt
+{
+   U8             rbId;       /*!< PDCP ID. */
+   U8             cfgType;    /*!< Configuration request type -
+                                -# CPJ_CFG_ADD,
+                                -# CPJ_CFG_MODIFY,
+                                -# CPJ_CFG_DELETE,
+                                -# CPJ_REESTABLISH,
+                                -# CPJ_CFG_DELETE_UE */
+   U8             rbType;     /*!< RB type.  
+                                -# CM_LTE_SRB
+                                -# CM_LTE_DRB */
+
+   union{
+        CpjAddCfgEnt     addCfg; /*!< Configuration parameters for
+                                    cfgType CPJ_CFG_ADD */
+        CpjModCfgEnt     modCfg; /*!< Configuration parameters for
+                                    cfgType CPJ_CFG_MODIFY */
+   }m;
+}CpjCfgEnt;
+
+
+
+/**
+ * @brief
+ * PDCP Configuration structure. Parameters are filled by RRC 
+   layer while configuring the PDCP layer.  
+ */
+typedef struct cpjCfgReqInfo
+{
+   CmLteRnti      ueId;                 /*!< UE ID */
+   CmLteCellId    cellId;               /*!< Cell ID */
+   U32            transId;              /*!< Transaction ID */
+   U8             numEnt;               /*!< Number of entities to be
+                                          configured in the Config request.*/
+   U8             isHo;
+#ifdef TENB_MULT_CELL_SUPPRT
+   SpId           rlcUlSapId;
+   SpId           rlcDlSapId;
+#endif
+   CpjCfgEnt      cfgEnt[CPJ_MAX_CFG];  /*!< Config paramater for
+                                          PDCP entity. */
+}CpjCfgReqInfo;
+
+/**
+ * @brief
+ * PDCP Confirm parameter structure for PDCP entity. 
+ */
+typedef struct cpjCfmEnt
+{
+   U8             rbId;       /*!< RB ID */
+   U8             rbType;     /*!< RB Type */
+   Status         status;     /*!< ROK or RFAILED */
+   Reason         reason;     /*!< Reason for failure */
+}CpjCfmEnt;
+
+/**
+ * @brief
+ * PDCP Configuration Confirm structure. 
+ */
+typedef struct cpjCfgCfmInfo
+{
+   CmLteRnti      ueId;                   /*!< UE ID */
+   CmLteCellId    cellId;                 /*!< Cell ID */
+   U32            transId;                /*!< Transcation ID */
+   U8             numEnt;                 /*!< Number of entities */
+   CpjCfmEnt      cfmEnt[CPJ_MAX_CFM];    /*!< Confirm parameter for
+                                               PDCP entity */
+}CpjCfgCfmInfo;
+
+/**
+ * @brief
+ * Re-estabishment Request structure for SRB1 of an UE.
+ */
+typedef struct cpjReEstReqInfo
+{
+   CmLtePdcpId    pdcpId;                          /*!< PDCP ID */
+   U32            transId;                         /*!< Transcation ID */
+   U8             intKey[CPJ_INTG_KEY_LEN];         /*!< Integrity key */
+   CpjCipherKey   ctrlplnKey[CPJ_CIPHER_KEY_LEN];  /*!< Control plane
+                                                        ciphering key */
+   CpjCipherKey   usrplnKey[CPJ_CIPHER_KEY_LEN];   /*!< User plane
+                                                        ciphering key */
+}CpjReEstReqInfo;
+
+/**
+ * @brief
+ * Data Forwarding Request structure
+ */
+typedef struct cpjDataFwdReqInfo
+{
+   CmLteRnti      ueId;       /*!< UE ID */
+   CmLteCellId    cellId;     /*!< Cell ID */
+   U32            transId;                         /*!< Transcation ID */
+   Bool           isUlDatFwdReq;  /*!< UL Data Fwd reqd or not */
+}CpjDataFwdReqInfo;
+
+
+/**
+ * @brief
+ * Data Resume Request structure
+ */
+typedef struct cpjDatResumeReqInfo
+{
+   CmLteRnti      ueId;       /*!< UE ID */
+   CmLteCellId    cellId;     /*!< Cell ID */
+   U32            transId;                         /*!< Transcation ID */
+}CpjDatResumeReqInfo;
+/**
+ * @brief
+ * Re-establishment Confirmation structure for an UE.
+ */
+typedef struct cpjReEstCfmInfo
+{
+   CmLteRnti      ueId;             /*!< UE ID */
+   CmLteCellId    cellId;           /*!< Cell ID */
+   U32            transId;          /*!< Transcation ID */
+   Status       status;           /*!< Status of reestablishment.
+                                     Allowed values are:
+                                     -# LCM_PRIM_OK
+                                     -# LCM_PRIM_NOK
+                                     */
+}CpjReEstCfmInfo;
+
+/**
+ * @brief
+ * PDCP Security Configuration structure. Parameters are filled by RRC
+ * while configuring the security parameters.
+ */
+typedef struct cpjSecCfgReqInfo
+{
+   CmLteRnti      ueId;       /*!< UE ID */
+   CmLteCellId    cellId;     /*!< Cell ID */
+   U32            transId;    /*!< Transcation ID */
+   CpjSecCfg      secCfg;     /*!< Configuration paramater for PDCP entity */
+}CpjSecCfgReqInfo;
+
+/**
+ * @brief
+ * PDCP Security Configuration confirm structure. 
+ */
+typedef struct cpjSecCfgCfmInfo
+{
+   CmLteRnti      ueId;       /*!< UE ID */
+   CmLteCellId    cellId;     /*!< Cell ID */
+   U32            transId;    /*!< Transcation ID */
+   Status         status;     /*!< ROK or RFAILED */
+   Reason         reason;     /*!< Reason for failure */
+}CpjSecCfgCfmInfo;
+
+/**
+ *  @brief
+ *  UE ID Information
+ */
+typedef struct cpjUeInfo
+{
+   CmLteCellId    cellId;     /*!< Cell ID */
+   CmLteRnti      ueId;       /*!< UE ID */
+}CpjUeInfo;
+
+/**
+ *  @brief
+ *  PDCP Count Request Information from RRC.
+ */
+typedef struct cpjCountReqInfo
+{
+   CmLteRnti      ueId;       /*!< UE ID */
+   CmLteCellId    cellId;     /*!< Cell ID */
+   U32            transId;    /*!< Transaction ID */
+} CpjCountReqInfo;
+
+/**
+ *  @brief
+ *  PDCP Count Information for a DRB.
+ */
+typedef struct cpjCountInfo
+{
+   U8             rbId;       /*!< RB ID */
+   U8             dir;        /*!< Direction of the RB */
+   U32            ulCount;    /*!< UL Count value */
+   U32            dlCount;    /*!< DL Count value */
+} CpjCountInfo;
+/**
+ *  @brief
+ *  PDCP Count Request Confirmation to RRC.
+ */
+typedef struct cpjCountCfmInfo
+{
+   CmLteRnti      ueId;                   /*!< UE ID */
+   CmLteCellId    cellId;                 /*!< Cell ID */
+   U32            transId;                /*!< Transaction ID */
+   U8             numRb;                  /*!< Number of DRBs */
+   CpjCountInfo   countInfo[CPJ_MAX_DRB]; /*!< CountInfo of DRBs */
+   Status         status;                 /*!< ROK or RFAILED */
+   Reason         reason;                 /*!< Reason for failure */
+} CpjCountCfmInfo;
+
+/**
+ *  @brief
+ *  PDCP SDU Status Request Information from RRC - Used for reestablishment
+ *  during handover.
+ */
+typedef struct cpjSduStaReqInfo
+{
+   CmLteRnti      ueId;       /*!< UE ID */
+   CmLteCellId    cellId;     /*!< Cell ID */
+   U32            transId;    /*!< Transaction ID */
+} CpjSduStaReqInfo;
+
+/**
+ *  @brief
+ *  PDCP UL SDU Status Information for a DRB mapped to RLC AM.
+ */
+typedef struct cpjUlSduStaInfo
+{
+   U16             numBits;    /*!< Number of bits in UL bitmap */
+   U8             *ulBitMap;  /*!< Status Report of PDUs recieved during
+                                re-establishment. @n
+                                The MSB of the first octet of the type "Bitmap"
+                                indicates whether or not the PDCP SDU with the
+                                SN (FMS + 1) modulo 4096 is received. @n
+                                The LSB of the first octet of the type "Bitmap"
+                                indicates whether or not the PDCP SDU with the
+                                SN (FMS + 8) modulo 4096 has been received
+                                correctly.
+                                */
+   U32            count;      /*!< UL Count value with First Missing
+                                Sequence Number */
+} CpjUlSduStaInfo;
+
+/**
+ *  @brief
+ *  PDCP DL SDU Status Information for a DRB mapped to RLC AM.
+ */
+typedef struct cpjDlSduStaInfo
+{
+   U32            count;      /*!< Count with the next SN to be assigned
+                                for a SDU */
+} CpjDlSduStaInfo;
+
+/**
+ *  @brief
+ *  PDCP SDU Status Information for a DRB mapped to RLC AM.
+ */
+typedef struct cpjSduStaInfo
+{
+   U8                   rbId;         /*!< RB ID */
+   U8                   dir;          /*!< Direction of the RB */
+   U8                   snLen;        /*!< PDCP-SN length 12/15 bits */
+   CpjUlSduStaInfo      ulSduStaInfo; /*!< SDU Status Info for UL */
+   CpjDlSduStaInfo      dlSduStaInfo; /*!< SDU Status Info for DL */ 
+} CpjSduStaInfo;
+
+/**
+ *  @brief
+ *  PDCP SDU Status Request Confirmation for an UE.
+ */
+typedef struct cpjSduStaCfmInfo
+{
+   CmLteRnti      ueId;                   /*!< UE ID */
+   CmLteCellId    cellId;                 /*!< Cell ID */
+   U32            transId;                /*!< Transaction ID */
+   U8             numRb;                  /*!< Number of RBs */
+   CpjSduStaInfo  sduStaInfo[CPJ_MAX_DRB]; /*!< SDU Status Info of DRBs mapped
+                                             to RLC AM */
+   Status         status;                 /*!< ROK or RFAILED */
+   Reason         reason;                 /*!< Reason for Failure */
+} CpjSduStaCfmInfo;
+
+/**
+ *  @brief
+ *  PDCP Data Resume Request Confirmation for an UE.
+ */
+typedef struct cpjDatResumeCfmInfo
+{
+   CmLteRnti      ueId;                   /*!< UE ID */
+   CmLteCellId    cellId;                 /*!< Cell ID */
+   U32            transId;                /*!< Transaction ID */
+   Status         status;                 /*!< ROK or RFAILED */
+   Reason         reason;                 /*!< Reason for Failure */
+} CpjDatResumeCfmInfo;
+/********************************************************************************************************************************/
+                              /*START OF KEY DERIVATION FUNTION (KDF) REQUEST STRUCTURES*/
+/********************************************************************************************************************************/
+
+/*AS key generation input information structure*/
+typedef struct cpjAsKeyInfo{
+           U8 intgAlgoType;            /*!SNOW3g or AES, used in key 
+                                          derivation as well */
+           U8 ciphAlgoType;            /*!SNOW3g or AES, used in key 
+                                          derivation as well */
+           U8 secKey[CPJ_SEC_KEY_LEN]; /*!< eNodeB key received in initial 
+                                            context setup */
+}CpjAsKeyInfo;
+
+/*Horizontal keNB derivation input information structure*/
+typedef struct cpjKenbStarInfo{
+           U16 dlCarrFreq;             /*!< DL UARFCN*/ 
+           U16 physCellId;             /*!< Physical cell ID*/
+           U8 secKey[CPJ_SEC_KEY_LEN]; /*!< Current eNodeB key at App used to 
+                                            derive keNB*. Horizontal KD */
+}CpjKenbStarInfo;
+
+/*Vertical keNB derivation input information structure*/
+typedef struct cpjNhKeyInfo{
+           U16 dlCarrFreq;             /*!< DL UARFCN*/ 
+           U16 physCellId;             /*!< Physical cell ID*/
+           U8 secKey[CPJ_SEC_KEY_LEN]; /*!< NH key provided by MME used to 
+                                            derive keNB*. Vertical KD */
+}CpjNhKeyInfo;
+
+typedef struct cpjKdfReqInfo {
+   U8    keyDerType;                   /*!< Keyderivation type: for AS security
+                                            keys/keNB* from keNB/keNB* 
+                                            from NH key */
+   union
+   {
+      CpjAsKeyInfo      kEnbInf;       /*!< eNodeB key for for deriving AS 
+                                            security keys */
+      CpjKenbStarInfo   kEnbStarInf;   /*!< eNodeB key for for deriving eNodeB*
+                                            Key (Horizontal key derivation ref:
+                                            ts 33.401) */
+      CpjNhKeyInfo      nhKeyInf;      /*!< NH key for for deriving eNodeB* Key
+                                            (Verticall key derivation ref: 
+                                            ts 33.401) */
+   } u;
+} CpjKdfReqInfo;
+
+/** 
+  @brief Transaction ID between CPJ and User. */
+typedef struct cpjCfgTransId {
+   U8 trans[CPJ_CFG_TRANSID_SIZE]; /*!< User transaction ID */
+} CpjCfgTransId;
+
+
+/********************************************************************************************************************************/
+                              /*END OF REQUEST STRUCTURES*/
+/********************************************************************************************************************************/
+
+
+/********************************************************************************************************************************/
+                              /*START OF KEY DERIVATION FUNTION (KDF) CONFIRM STRUCTURES*/
+/********************************************************************************************************************************/
+
+/*AS key generation output information structure*/
+typedef struct cpjAskeyCfmInfo{
+          U8 intKey[CPJ_SEC_KEY_LEN];    /*!< eNodeB key received in initial
+                                              context setup */
+          U8 upCiphKey[CPJ_SEC_KEY_LEN]; /*!< eNodeB key received in initial
+                                              context setup */
+          U8 cpCiphKey[CPJ_SEC_KEY_LEN]; /*!< eNodeB key received in initial
+                                              context setup */
+}CpjAskeyCfmInfo;
+
+/*Horizontal keNB derivation output information structure*/
+typedef struct cpjKenbStarCfmInfo{
+           U8 secKey[CPJ_SEC_KEY_LEN];   /*!< Current eNodeB key at App used
+                                              to derive keNB*. Horizontal KD */
+}CpjKenbStarCfmInfo;
+
+/*Vertical keNB derivation output information structure*/
+typedef struct cpjNhKeyCfmInfo{
+           U8 secKey[CPJ_SEC_KEY_LEN];   /*!< NH key provided by MME used to 
+                                              derive keNB*. Vertical KD */
+}CpjNhKeyCfmInfo;
+
+typedef struct cpjKdfCfmInfo {
+   U8    keyDerType;                     /*!< Keyderivation type: for AS 
+                                              security keys/keNB* from 
+                                              keNB/keNB* from NH key */
+   union
+   {
+      CpjAskeyCfmInfo      kEnbInf;      /*!< AS security keys */
+      CpjKenbStarCfmInfo   kEnbStarInf;  /*!< eNodeB* Key (Horizontal key 
+                                              derivation ref: ts 33.401) */
+      CpjNhKeyCfmInfo      nhKeyInf;     /*!< eNodeB* Key (Verticall key 
+                                              derivation ref: ts 33.401) */
+   } u;
+} CpjKdfCfmInfo;
+
+/*************************************************************************
+ *                      END OF STRUCTURES
+ ************************************************************************/
+
+/*************************************************************************
+ *                   Start of Pointer Interface primitives
+ ************************************************************************/
+typedef S16 (*CpjBndReq)      ARGS((Pst *pst, SuId suId, SpId spId));
+typedef S16 (*CpjBndCfm)      ARGS((Pst *pst, SuId suId, U8 status));
+typedef S16 (*CpjUbndReq)     ARGS((Pst *pst, SpId spId, Reason reason));
+typedef S16 (*CpjCfgReq)      ARGS((Pst *pst, SpId spId, CpjCfgReqInfo *cfgReq));
+typedef S16 (*CpjCfgCfm)      ARGS((Pst *pst, SuId suId, CpjCfgCfmInfo *cfgCfm));
+typedef S16 (*CpjReEstReq)    ARGS((Pst *pst, SpId spId, CpjReEstReqInfo *reEstReq));
+typedef S16 (*CpjReEstCfm)    ARGS((Pst *pst, SuId suId, CpjReEstCfmInfo *reEstCfm));
+typedef S16 (*CpjSecCfgReq)   ARGS((Pst *pst, SpId spId, CpjSecCfgReqInfo *secCfgReq));
+typedef S16 (*CpjSecCfgCfm)   ARGS((Pst *pst, SuId suId, CpjSecCfgCfmInfo *secCfgCfm));
+typedef S16 (*CpjUeIdChgReq)  ARGS((Pst *pst, SpId spId, U32 transId, 
+                                    CpjUeInfo *oldUeInfo,
+                                    CpjUeInfo *newUeInfo));
+typedef S16 (*CpjUeIdChgCfm)  ARGS((Pst *pst, SuId suId, U32 transId, 
+                                    CpjUeInfo  *ueInfo, CmStatus status));
+typedef S16 (*CpjCountReq)   ARGS((Pst *pst, SpId spId, CpjCountReqInfo *countReq));
+typedef S16 (*CpjCountCfm)   ARGS((Pst *pst, SuId suId, CpjCountCfmInfo *countCfm));
+typedef S16 (*CpjSduStaReq)  ARGS((Pst *pst, SpId spId, CpjSduStaReqInfo *staReq));
+typedef S16 (*CpjSduStaCfm)  ARGS((Pst *pst, SuId suId, CpjSduStaCfmInfo *staCfm));
+typedef S16 (*CpjDataFwdReq)  ARGS((Pst *pst, SpId spId, CpjDataFwdReqInfo *dataFwdReq));
+typedef S16 (*CpjDatResumeReq)  ARGS((Pst *pst, SpId spId, CpjDatResumeReqInfo
+         *DatResumeReq));
+typedef S16 (*CpjDatResumeCfm)  ARGS((Pst *pst, SuId suId, CpjDatResumeCfmInfo *dataResCfm));
+typedef S16 (*CpjKdfReq) ARGS((
+   Pst*                 pst,
+   SpId                 spId,
+   CpjCfgTransId        transId,
+   CpjKdfReqInfo*       cfgReqInfo));
+
+/* Configuration Confirm from PHY to User. */
+typedef S16 (*CpjKdfCfm) ARGS((
+   Pst*                 pst,
+   SuId                 suId,
+   CpjCfgTransId        transId,
+   CpjKdfCfmInfo*       kdfCfmInfo,
+   U8                   status));
+
+
+/*************************************************************************
+ *                   End of Pointer Interface primitives
+ ************************************************************************/
+/* cpj_x_001.main_2 */
+/*************************************************************************
+ *                   Start of Extern Interface Declarations
+ ************************************************************************/
+/**
+ * @brief Bind request primitive
+ * @details
+ * The function binds the PDCP service user entity (RRC) to the PDCP product.
+ * PDCP acknowledges the receipt of the bind request by sending a PjUiCpjBndCfm
+ * primitive.
+ *
+ * @param[in] pst     - Pointer to the post structure.
+ * @param[in] suId    - Service user ID. This is the reference number used by
+ * PDCP service user to identify its SAP. This reference number is 
+ * provided by PDCP in any further primitives sent by PDCP to the service user.
+ * @param[in] spId    - Service provider ID. This is the reference number used
+ * by PDCP service user to identify its SAP. This reference number is
+ * provided by PDCP in any further primitives sent by PDCP to the service user.
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUiCpjBndReq ARGS((Pst *pst, SuId suId, SpId spId));
+
+/**
+ * @brief Bind confirmation primitive
+ * @details
+ * PDCP invokes the bind confirm primitive to acknowledge the receipt of
+ * the PjUiCpjBndReq primitive from the RRC layer. The status field indicates
+ * whether the bind request succeeded or failed. The bind request may fail due
+ * to invalid parameters in the bind request from the service user
+ * (for example, an invalid spId).
+ *
+ * @param[in] pst    - Pointer to the pst structure.
+ * @param[in] suId   - Service user ID. This is the reference number used
+ * by PDCP service user (RRC layer) to identify its SAP.
+ * @param[in] status - Status field indicates whether the bind request
+ * succeeded or failed. 
+ *  -# TRUE, for successful bind.
+ *  -# FALSE, otherwise.
+ *
+ *  @return ROK.
+ */
+EXTERN S16 PjUiCpjBndCfm ARGS((Pst *pst, SuId suId, U8 status));
+
+/**
+ * @brief Unbind request primitive
+ * @details
+ * The PDCP service user (RRC) initiates this primitive for performing
+ * an unbind operation. This function brings the link between RRC and PDCP 
+ * down if it is already up, and releases all the resources associated for
+ * this SAP at PDCP.
+ *
+ * @param[in] pst    - Pointer to the post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] reason - Unbind reason. Not used in the current implementation. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUiCpjUbndReq ARGS((Pst *pst, SpId spId, Reason reason));
+
+/**
+ * @brief Configuration request primitive
+ * @details
+ * RRC uses this primitive to configure PDCP system parameters. The
+ * various parameters are configured by RRC. In one configuration request,
+ * multiple PDCP entities can be configured based on the rbId.
+ * For PDCP on target eNB, RRC can configure the handover information.
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] pdcpCfg - PDCP configuration structure. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUiCpjCfgReq ARGS((Pst *pst, SpId spId, CpjCfgReqInfo *cfgReq));
+
+/**
+ * @brief Configuration confirmation primitive
+ * @details
+ * This primitive is invoked by PDCP to inform to PDCP User (RRC) about
+ * the PDCP configuration request primitive execution status.
+ *
+ * @param[in] pst    - Pointer to the post structure.
+ * @param[in] suId   - Service user ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] pdcpCfgCfm - PDCP configuration confirm structure. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUiCpjCfgCfm ARGS((Pst *pst, SuId suId, CpjCfgCfmInfo *cfgCfm));
+
+/**
+ * @brief Reestablishment request primtive
+ * @details
+ * RRC uses this primitive to reestablish the PDCP entity.
+ * This primitive is initiation of reestablishment procedure.
+ * This prmitive and corresponding confirmation are followed by
+ * PjUiCpjCfgReq procedure for entire reestablishment procedure to complete.
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used by
+ * PDCP to identify its SAP.
+ * @param[in] reEstReq - PDCP reestablishment request structure. 
+ *
+ */
+EXTERN S16 PjUiCpjReEstReq ARGS((Pst *pst, SpId spId, CpjReEstReqInfo *reEstReq));
+
+/**
+ * @brief Reestablishment confirmation primitive
+ * @details
+ * This primitive is invoked by PDCP to inform PDCP User (RRC) about the PDCP
+ * (SRB1) reestablishment request primitive execution status.
+ *
+ * @param[in] pst    - Pointer to the post structure.
+ * @param[in] suId   - Service user ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] reEstCfm - PDCP reestablishment confirm structure. 
+ *
+ */
+EXTERN S16 PjUiCpjReEstCfm ARGS((Pst *pst, SuId suId, CpjReEstCfmInfo *reEstCfm));
+
+/**
+ * @brief Security Configuration request primitive
+ * @details
+ * RRC uses this primitive to configure PDCP security parameters.
+ * Integrity protection and/or Ciphering are configured by RRC based on the
+ * selSecAct flag. Integrity Protection/Ciphering are configured per UE and applicable
+ * to all PDCP entities in that UE. Both Integrity protection and ciphering are
+ * configured during reestablishment. 
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used by
+ * PDCP to identify its SAP.
+ * @param[in] pdcpSecCfg - PDCP security configuration structure. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUiCpjSecCfgReq ARGS((Pst *pst, SpId spId,
+         CpjSecCfgReqInfo *secCfgReq));
+
+/**
+ * @brief Security Configuration confirmation primitive.
+ * @details
+ * This primitive is invoked by PDCP to inform to PDCP User (RRC) about
+ * the PDCP secutiry configuration request primitive execution status.
+ *
+ * @param[in] pst    - Pointer to the post structure.
+ * @param[in] suId   - Service user ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] pdcpSecCfgCfm - PDCP configuration confirm structure. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUiCpjSecCfgCfm ARGS( (Pst *pst, SuId suId,
+         CpjSecCfgCfmInfo *secCfgCfm));
+
+/**
+ * @brief UE ID change request primitive
+ * @details
+ * This primitive is used by RRC to change the UeId for the existing UE context.
+ *
+ * @param[in] pst       - Point to the post structure
+ * @param[in] spId      - The ID of the service provider SAP in the PDCP layer.
+ * @param[in] transId   - Transaction ID. This field uniquely identifies
+ * transaction between RRC and PDCP.
+ * @param[in] oldUeInfo - Old UE ID info for which the change request has come.
+ * @param[in] newUeInfo - New UE ID info for existing UE context. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUiCpjUeIdChgReq ARGS((Pst *pst, SpId spId, U32 transId,
+                                  CpjUeInfo *oldUeInfo, CpjUeInfo  *newUeInfo));
+
+/**
+ * @brief UE ID change confirmation primitive
+ * @details
+ * This primitive is used by PDCP to confirm the UeId change requested by RRC.
+ * The different values for status are:\n
+ * ROK       -  Success\n
+ * RFAILED   -  Failure\n
+ *
+ * The different reasons for the failure are:
+ * CPJ_CFG_REAS_UE_CREAT_FAIL -  UE Cb update failure \n
+ * CPJ_CFG_REAS_UE_UNKWN      -  Request received for an unknown UE ID. 
+ *
+ * @param [in] pst       - Point to the post structure.
+ * @param [in] suId      - The ID of the service user SAP associated with PDCP
+ * @param [in] transId   - Transaction ID. This field uniquely identifies
+ *                         transaction between RRC and PDCP.
+ * @param [in] ueInfo    - UE Identity which is changed with the new ID
+ *                         for the same context.
+ * @param [in] CmStatus  - Confirmation status with appropriate reason
+ *                         information.
+ * @return ROK
+ */
+EXTERN S16 PjUiCpjUeIdChgCfm  ARGS((Pst *pst, SuId suId, U32 transId,
+                                  CpjUeInfo *ueInfo, CmStatus status));
+
+/**
+ * @brief Count request primitive
+ * @details
+ * RRC uses this primitive to request count value for all DRBs in a UE.
+ * PDCP sends the UL and DL count values in the confirmation of this request.
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] countReq - PDCP Count Request Information. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUiCpjCountReq ARGS((Pst *pst, SpId spId, CpjCountReqInfo *countReq));
+
+/**
+ * @brief Count confirmation primitive
+ * @details
+ * PDCP uses this primitive to send the count values for all
+ * DRBs in a UE to RRC. PDCP sends the RB ID, direction 
+ * and count value(s) ( UL, DL or both based on direction of the RB)
+ * for each DRB. 
+ *
+ * @param[in] pst       - Pointer to post structure.
+ * @param[in] suId      - The ID of the service user SAP associated with PDCP.
+ * @param[in] countCfm  - PDCP Count Confirmation Info. 
+ *
+ * @return ROK
+*/
+EXTERN S16 PjUiCpjCountCfm ARGS((Pst *pst, SuId suId, CpjCountCfmInfo *countCfm));
+
+/**
+ * @brief SDU Status Request primitive
+ * @details
+ * RRC uses this primitive to request the status of the SDUs for DRBs in an UE.
+ * Its used as a reestablishment request during handover.
+ * This primitive is used to forward the handover control Information to the target
+ * eNodeB.
+ *
+ * @param[in] pst    - Pointer to post structure.
+ * @param[in] spId   - Service provider ID. This is the reference number used
+ * by PDCP to identify its SAP.
+ * @param[in] sduStaReq - PDCP SDU Status Request Information. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUiCpjSduStaReq ARGS((Pst *pst, SpId spId, CpjSduStaReqInfo *staReq));
+
+/**
+ * @brief SDU Status confirmation primitive
+ * @details
+ * PDCP uses this primitive to send the SDU status for the DRBs in 
+ * the requested UE. PDCP sends the RB ID, direction of the RB,status report 
+ * and count(to indicate the first missing SN) in UL and count(to indicate 
+ * the next SN to be assigned) in DL for each requested DRB mapped on to RLC AM.
+ *
+ * @param[in] pst       - Pointer to post structure.
+ * @param[in] suId      - The ID of the service user SAP associated with PDCP.
+ * @param[in] sduStaCfm - PDCP SDU Status Confirmation Info. 
+ *
+ * @return ROK
+*/
+EXTERN S16 PjUiCpjSduStaCfm ARGS((Pst *pst, SuId suId, CpjSduStaCfmInfo *staCfm));
+
+#ifdef FLAT_BUFFER_OPT
+EXTERN S16 PjUiCpjDatResumeReqFB ARGS((Pst *pst, SpId spId, CpjDatResumeReqInfo
+         *dataResReq));
+
+EXTERN S16 PjUiCpjDatForwardReqFB ARGS(( Pst *pst, SpId spId,
+         CpjDataFwdReqInfo *dataFwdReq));
+#endif
+
+
+EXTERN S16 PjUiCpjDatResumeReq ARGS((Pst *pst, SpId spId, CpjDatResumeReqInfo
+         *dataResReq));
+
+EXTERN S16 PjUiCpjDatForwardReq ARGS(( Pst *pst, SpId spId,
+         CpjDataFwdReqInfo *dataFwdReq));
+
+EXTERN S16 PjUiCpjDatResumeCfm ARGS(( Pst *pst, SuId suId, CpjDatResumeCfmInfo
+         *datResCfm));
+/**
+* @brief This API is used to receive a Bind confirm from PDCP to Application.
+*
+* @details
+*
+*  @param[in]   pst - Post structure
+*  @param[in]   suId - Service User Id
+*  @param[in]   transId - Transaction Id
+*  @param[in]   kdfCfmInf - Generated keys
+*  @param[in]   status - status of KDF request
+*  @return   S16
+*      -# ROK
+**/
+EXTERN S16 PjUiCpjKdfCfm ARGS ((
+Pst* pst,
+SuId suId,
+CpjCfgTransId transId,
+CpjKdfCfmInfo *kdfCfmInf,
+U8 status
+));
+
+EXTERN S16 PjUiCpjKdfReq ARGS((
+Pst*           pst, 
+SpId           spId, 
+CpjCfgTransId  transId,
+CpjKdfReqInfo *kdfReqInfo
+));
+
+EXTERN S16 cmPkCpjKdfReq ARGS((
+   Pst*           pst,
+   SpId           spId,
+   CpjCfgTransId  transId,
+   CpjKdfReqInfo *kdfReqInfo
+));
+/* Configuration Request from User to PHY for 
+ * cell or dedicated configuration.
+*/
+EXTERN S16 cmUnpkCpjKdfReq ARGS((
+   CpjKdfReq            func,
+   Pst*                 pst,
+   Buffer               *mBuf
+));
+/* Configuration Confirm from PHY to User. */
+EXTERN S16 cmPkCpjKdfCfm ARGS((
+   Pst*                 pst,
+   SuId                 suId,
+   CpjCfgTransId        transId,
+   CpjKdfCfmInfo        *kdfCfmInfo,
+   U8                   status
+));
+/* Configuration Confirm from PHY to User. */
+EXTERN S16 cmUnpkCpjKdfCfm ARGS((
+   CpjKdfCfm            func,
+   Pst*                 pst,
+   Buffer               *mBuf
+));
+
+
+/************ Dummy Extern interface primitives ***********************/
+#ifdef DM
+EXTERN S16 DmUiCpjBndReq ARGS((Pst *, SuId, SpId));
+
+EXTERN S16 DmUiCpjUbndReq ARGS((Pst *, SpId, Reason));
+
+EXTERN S16 DmUiCpjBndCfm ARGS((Pst *, SuId, U8));
+
+EXTERN S16 DmUiCpjCfgReq ARGS( (Pst *, SpId , CpjCfgReqInfo *));
+
+EXTERN S16 DmUiCpjCfgCfm ARGS( (Pst *, SuId , CpjCfgCfmInfo *));
+
+EXTERN S16 DmUiCpjSecCfgReq ARGS((Pst *, SpId ,CpjSecCfgReqInfo *));
+
+EXTERN S16 DmUiCpjSecCfgCfm ARGS((Pst *, SuId ,CpjSecCfgCfmInfo *));
+
+EXTERN S16 DmUiCpjUeIdChgReq ARGS( (Pst *, SpId , U32, CpjUeInfo *, CpjUeInfo *));
+
+EXTERN S16 DmUiCpjUeIdChgCfm ARGS( (Pst *, SuId , U32, CpjUeInfo *, CmStatus));
+
+EXTERN S16 DmUiCpjReEstReq ARGS((Pst *, SpId , CpjReEstReqInfo *));
+
+EXTERN S16 DmUiCpjReEstCfm ARGS (( Pst *, SuId , CpjReEstCfmInfo *));
+
+EXTERN S16 DmUiCpjCountReq ARGS((Pst *, SpId ,CpjCountReqInfo *));
+
+EXTERN S16 DmUiCpjCountCfm ARGS((Pst *, SuId ,CpjCountCfmInfo *));
+
+EXTERN S16 DmUiCpjSduStaReq ARGS((Pst *, SpId ,CpjSduStaReqInfo *));
+
+EXTERN S16 DmUiCpjStartDataFwdReq ARGS((Pst *, SpId ,CpjDataFwdReqInfo *));
+
+EXTERN S16 DmUiCpjDatResumeReq ARGS((Pst *, SpId ,CpjDatResumeReqInfo *));
+
+EXTERN S16 DmUiCpjSduStaCfm ARGS((Pst *, SuId ,CpjSduStaCfmInfo *));
+
+EXTERN S16 DmUiCpjDatForwardReq ARGS((Pst *,SpId ,CpjDataFwdReqInfo *));
+
+
+#endif
+
+/************ LTE RRC Extern interface primitives ***********************/
+#ifdef NH    /* LTE-RRC */
+EXTERN S16 NhLiCpjBndReq ARGS((Pst *, SuId, SpId));
+
+EXTERN S16 NhLiCpjUbndReq ARGS((Pst *, SpId, Reason));
+
+EXTERN S16 NhLiCpjBndCfm ARGS((Pst *, SuId, U8));
+
+EXTERN S16 NhLiCpjCfgReq ARGS( (Pst *, SpId , CpjCfgReqInfo *));
+
+EXTERN S16 NhLiCpjCfgCfm ARGS( (Pst *, SuId , CpjCfgCfmInfo *));
+
+EXTERN S16 NhLiCpjSecCfgReq ARGS((Pst *, SpId , CpjSecCfgReqInfo *));
+
+EXTERN S16 NhLiCpjSecCfgCfm ARGS((Pst *, SuId , CpjSecCfgCfmInfo *));
+
+EXTERN S16 NhLiCpjUeIdChgReq ARGS( (Pst *, SpId , U32 , CpjUeInfo *, CpjUeInfo *));
+
+EXTERN S16 NhLiCpjUeIdChgCfm ARGS( (Pst *, SuId , U32, CpjUeInfo *, CmStatus));
+
+EXTERN S16 NhLiCpjReEstReq ARGS((Pst *pst, SpId spId, CpjReEstReqInfo *reEstReq));
+
+EXTERN S16 NhLiCpjReEstCfm ARGS (( Pst *pst, SuId suId, CpjReEstCfmInfo *cfmInfo));
+
+EXTERN S16 NhLiCpjCountReq ARGS((Pst *, SpId , CpjCountReqInfo *));
+
+EXTERN S16 NhLiCpjCountCfm ARGS((Pst *, SuId , CpjCountCfmInfo *));
+
+EXTERN S16 NhLiCpjSduStaReq ARGS((Pst *, SpId , CpjSduStaReqInfo *));
+
+EXTERN S16 NhLiCpjSduStaCfm ARGS((Pst *, SuId , CpjSduStaCfmInfo *));
+
+EXTERN S16 NhLiCpjDatResumeCfm ARGS((Pst *, SuId , CpjDatResumeCfmInfo *));
+
+EXTERN S16 NhLiCpjStartDataFwdReq ARGS((Pst *post,  SpId spId, CpjDataFwdReqInfo
+         *pdcpDataFwdReq )); 
+EXTERN S16 NhLiCpjDatResumeReq ARGS((Pst *post, SpId spId, CpjDatResumeReqInfo
+         *pdcpDatResumeReq ));
+#endif
+/*************************************************************************
+ *                   End of Extern Interface Declarations                *
+ ************************************************************************/
+
+/***********************************************************************
+ *                    Start of pack/unpack functions                   *
+ * *********************************************************************/
+#ifdef LCCPJ
+
+PUBLIC S16 cmPkCpjBndReq ARGS((
+Pst * pst,
+SuId suId,
+SpId spId
+));
+PUBLIC S16 cmUnpkCpjBndReq ARGS((
+CpjBndReq func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjBndCfm ARGS((
+Pst * pst,
+SuId suId,
+U8 status
+));
+PUBLIC S16 cmUnpkCpjBndCfm ARGS((
+CpjBndCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjUbndReq ARGS((
+Pst * pst,
+SpId spId,
+Reason reason
+));
+PUBLIC S16 cmUnpkCpjUbndReq ARGS((
+CpjUbndReq func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjCfgReq ARGS((
+Pst * pst,
+SpId spId,
+CpjCfgReqInfo * cfgReq
+));
+PUBLIC S16 cmUnpkCpjCfgReq ARGS((
+CpjCfgReq func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjCfgCfm ARGS((
+Pst * pst,
+SuId suId,
+CpjCfgCfmInfo * cfgCfm
+));
+PUBLIC S16 cmUnpkCpjCfgCfm ARGS((
+CpjCfgCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjReEstReq ARGS((
+Pst * pst,
+SpId spId,
+CpjReEstReqInfo * reEstReq
+));
+PUBLIC S16 cmUnpkCpjReEstReq ARGS((
+CpjReEstReq func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjReEstCfm ARGS((
+Pst * pst,
+SuId suId,
+CpjReEstCfmInfo * reEstCfm
+));
+PUBLIC S16 cmUnpkCpjReEstCfm ARGS((
+CpjReEstCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjSecCfgReq ARGS((
+Pst * pst,
+SpId spId,
+CpjSecCfgReqInfo * secCfgReq
+));
+PUBLIC S16 cmUnpkCpjSecCfgReq ARGS((
+CpjSecCfgReq func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjSecCfgCfm ARGS((
+Pst * pst,
+SuId suId,
+CpjSecCfgCfmInfo * secCfgCfm
+));
+PUBLIC S16 cmUnpkCpjSecCfgCfm ARGS((
+CpjSecCfgCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjUeIdChgReq ARGS((
+Pst * pst,
+SpId spId,
+U32 transId,
+CpjUeInfo * oldUeInfo,
+CpjUeInfo * newUeInfo
+));
+PUBLIC S16 cmUnpkCpjUeIdChgReq ARGS((
+CpjUeIdChgReq func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjUeIdChgCfm ARGS((
+Pst * pst,
+SuId suId,
+U32 transId,
+CpjUeInfo  * ueInfo,
+CmStatus status
+));
+PUBLIC S16 cmUnpkCpjUeIdChgCfm ARGS((
+CpjUeIdChgCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjCountReq ARGS((
+Pst * pst,
+SpId spId,
+CpjCountReqInfo * countReq
+));
+PUBLIC S16 cmUnpkCpjCountReq ARGS((
+CpjCountReq func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjCountCfm ARGS((
+Pst * pst,
+SuId suId,
+CpjCountCfmInfo * countCfm
+));
+PUBLIC S16 cmUnpkCpjCountCfm ARGS((
+CpjCountCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjSduStaReq ARGS((
+Pst * pst,
+SpId spId,
+CpjSduStaReqInfo * staReq
+));
+PUBLIC S16 cmUnpkCpjSduStaReq ARGS((
+CpjSduStaReq func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjStartDataFwdReq ARGS((
+Pst * pst,
+SpId spId,
+CpjDataFwdReqInfo * dataFwdReq
+));
+PUBLIC S16 cmUnpkCpjStartDataFwdReq ARGS((
+CpjDataFwdReq func,
+Pst *pst,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjDatResumeReq ARGS((
+Pst * pst,
+SpId spId,
+CpjDatResumeReqInfo * dataFwdReq
+));
+
+PUBLIC S16 cmUnpkCpjDatResumeReq ARGS((
+CpjDatResumeReq func,
+Pst *pst,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjSduStaCfm ARGS((
+Pst * pst,
+SuId suId,
+CpjSduStaCfmInfo * staCfm
+));
+PUBLIC S16 cmUnpkCpjSduStaCfm ARGS((
+CpjSduStaCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjRlcAm ARGS((
+CpjRlcAm *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjRlcAm ARGS((
+CpjRlcAm *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjRlcUm ARGS((
+CpjRlcUm *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjRlcUm ARGS((
+CpjRlcUm *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjRlcInfo ARGS((
+CpjRlcInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjRlcInfo ARGS((
+CpjRlcInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjCipherInfo ARGS((
+CpjCipherInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjCipherInfo ARGS((
+CpjCipherInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjIntegInfo ARGS((
+CpjIntegInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjIntegInfo ARGS((
+CpjIntegInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjSecCfg ARGS((
+CpjSecCfg *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjSecCfg ARGS((
+CpjSecCfg *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjRohcInfo ARGS((
+CpjRohcInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjRohcInfo ARGS((
+CpjRohcInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjHdrCompCfg ARGS((
+CpjHdrCompCfg *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjHdrCompCfg ARGS((
+CpjHdrCompCfg *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjHoInfo ARGS((
+Pst *pst,
+CpjHoInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjHoInfo ARGS((
+Pst *pst,
+CpjHoInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjCfgEnt ARGS((
+Pst *pst,
+CpjCfgEnt *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjCfgEnt ARGS((
+Pst *pst,
+CpjCfgEnt *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjAddCfgEnt ARGS((
+CpjAddCfgEnt *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjAddCfgEnt ARGS((
+CpjAddCfgEnt *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjModCfgEnt ARGS((
+Pst *pst,
+CpjModCfgEnt *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjModCfgEnt ARGS((
+Pst *pst,
+CpjModCfgEnt *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjCfgReqInfo ARGS((
+Pst *pst,
+CpjCfgReqInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjCfgReqInfo ARGS((
+Pst *pst,
+CpjCfgReqInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjCfmEnt ARGS((
+CpjCfmEnt *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjCfmEnt ARGS((
+CpjCfmEnt *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjCfgCfmInfo ARGS((
+CpjCfgCfmInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjCfgCfmInfo ARGS((
+CpjCfgCfmInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjReEstReqInfo ARGS((
+CpjReEstReqInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjReEstReqInfo ARGS((
+CpjReEstReqInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjReEstCfmInfo ARGS((
+CpjReEstCfmInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjReEstCfmInfo ARGS((
+CpjReEstCfmInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjSecCfgReqInfo ARGS((
+CpjSecCfgReqInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjSecCfgReqInfo ARGS((
+CpjSecCfgReqInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjSecCfgCfmInfo ARGS((
+CpjSecCfgCfmInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjSecCfgCfmInfo ARGS((
+CpjSecCfgCfmInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjUeInfo ARGS((
+CpjUeInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjUeInfo ARGS((
+CpjUeInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjCountReqInfo ARGS((
+CpjCountReqInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjCountReqInfo ARGS((
+CpjCountReqInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjCountInfo ARGS((
+CpjCountInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjCountInfo ARGS((
+CpjCountInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjCountCfmInfo ARGS((
+CpjCountCfmInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjCountCfmInfo ARGS((
+CpjCountCfmInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjSduStaReqInfo ARGS((
+CpjSduStaReqInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjSduStaReqInfo ARGS((
+CpjSduStaReqInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjStartDataFwdReqInfo ARGS((
+CpjDataFwdReqInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjStartDataFwdReqInfo ARGS((
+CpjDataFwdReqInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjDatResumeReqInfo ARGS((
+CpjDatResumeReqInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjDatResumeReqInfo ARGS((
+CpjDatResumeReqInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjUlSduStaInfo ARGS((
+Pst *pst,
+CpjUlSduStaInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjUlSduStaInfo ARGS((
+Pst *pst,
+CpjUlSduStaInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjDlSduStaInfo ARGS((
+CpjDlSduStaInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjDlSduStaInfo ARGS((
+CpjDlSduStaInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjSduStaInfo ARGS((
+Pst *pst,
+CpjSduStaInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjSduStaInfo ARGS((
+Pst *pst,
+CpjSduStaInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmPkCpjSduStaCfmInfo ARGS((
+Pst *pst,
+CpjSduStaCfmInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjSduStaCfmInfo ARGS((
+Pst *pst,
+CpjSduStaCfmInfo *param,
+Buffer *mBuf
+));
+PUBLIC S16 cmUnpkCpjDatResumeCfmInfo ARGS((
+Pst *pst,
+CpjDatResumeCfmInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjDataResCfmInfo ARGS((
+Pst *pst,
+CpjDatResumeCfmInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmUnpkCpjDatResumeCfm ARGS((
+CpjDatResumeCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjDatResumeCfm ARGS((
+Pst * pst,
+SuId suId,
+CpjDatResumeCfmInfo * dataResCfm
+));
+
+PUBLIC S16 cmUnpkCpjDatResumeCfm ARGS((
+CpjDatResumeCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmUnpkCpjNhKeyCfmInfo ARGS((
+CpjNhKeyCfmInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmUnpkCpjKenbStarCfmInfo ARGS((
+CpjKenbStarCfmInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmUnpkCpjAskeyCfmInfo ARGS((
+CpjAskeyCfmInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmUnpkCpjKdfCfmInfo ARGS((
+CpjKdfCfmInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmUnpkCpjCfgTransId ARGS((
+CpjCfgTransId *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjNhKeyInfo ARGS((
+CpjNhKeyInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjKenbStarInfo ARGS((
+CpjKenbStarInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjAskeyInfo ARGS((
+CpjAsKeyInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjKdfReqInfo ARGS((
+CpjKdfReqInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjCfgTransId ARGS((
+CpjCfgTransId *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmUnpkCpjNhKeyInfo ARGS((
+CpjNhKeyInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmUnpkCpjKenbStarInfo ARGS((
+CpjKenbStarInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmUnpkCpjAskeyInfo ARGS((
+CpjAsKeyInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmUnpkCpjKdfReqInfo ARGS((
+CpjKdfReqInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjNhKeyCfmInfo ARGS((
+CpjNhKeyCfmInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjKenbStarCfmInfo ARGS((
+CpjKenbStarCfmInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjAskeyCfmInfo ARGS((
+CpjAskeyCfmInfo *param,
+Buffer *mBuf
+));
+
+PUBLIC S16 cmPkCpjKdfCfmInfo ARGS((
+CpjKdfCfmInfo *param,
+Buffer *mBuf
+));
+
+#endif
+
+/***********************************************************************
+ *                    End of pack/unpack functions                     *
+ * *********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __CPJ_X__ */
+
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/cm/lpj.h b/src/cm/lpj.h
new file mode 100755 (executable)
index 0000000..aa92975
--- /dev/null
@@ -0,0 +1,237 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LPJ PDCP Layer Manager Interface
+    
+        Type:    C include file
+  
+        Desc:    This file Contains the Hash defines for LPJ Interface
+        File:    lpj.h
+  
+*********************************************************************21*/
+
+#ifndef __LPJ_H__
+#define __LPJ_H__
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif  /*for extern "C"*/
+
+#define STUDXSAP           189
+
+#define LPJ_SEL_LC         0
+#ifdef TENB_SPLIT_ARCH
+#define LPJ_MODE_PDCP_UL   0x1
+#define LPJ_MODE_PDCP_DL   0x2
+#endif
+
+/* KWU Interface Hash Defines */
+#define LPJ_MAX_NUM_RB     24      /*!< Maximum number of RBs. */
+
+/* Event codes at the PDCP management interface */
+#define LPJ_EVT_CFG_REQ    0x50    /*!< General configuration request. */
+#define LPJ_EVT_CFG_CFM    0x51    /*!< General configuration confirm. */
+#define LPJ_EVT_CNTRL_REQ  0x52    /*!< Control request. */
+#define LPJ_EVT_CNTRL_CFM  0x53    /*!< Control confirm. */
+#define LPJ_EVT_STA_IND    0x54    /*!< Unsolicited status indication. */
+#define LPJ_EVT_STA_REQ    0x55    /*!< Solicited status request. */
+#define LPJ_EVT_STA_CFM    0x56    /*!< Solicited status confirm. */
+#define LPJ_EVT_STS_REQ    0x57    /*!< Statistics request. */
+#define LPJ_EVT_STS_CFM    0x58    /*!< Statistics confirm. */
+#define LPJ_EVT_TRC_IND    0x59    /*!< Trace indication. */
+/* lpj_h_001.main_2 added support for L2 Measurement */
+#define LPJ_EVT_L2MEAS_REQ 0x60    /*!< L2 Measurement Request. */
+#define LPJ_EVT_L2MEAS_CFM 0x61    /*!< L2 Measurement Confirm. */
+#ifdef LTE_L2_MEAS
+#define LPJ_EVT_MEAS_HALT  0x62    /*!< Measurement is halted due to RB deletion */
+#define LPJ_EVT_L2MEAS_SEND_REQ  0x63   /*!< L2 Measurement Send Request*/
+#define LPJ_EVT_L2MEAS_STOP_REQ  0x64   /*!< L2 Measurement Stop Request*/
+#define LPJ_EVT_L2MEAS_STOP_CFM  0x65   /*!< L2 Measurement Stop Confirm*/    
+#endif
+#define LPJ_EVT_L2MEAS_SEND_REQ 0x63    /*!< L2 Measurement send request*/
+#define LPJ_EVT_L2MEAS_STOP_REQ 0x64   /*!< L2 Measurement stop request.*/
+#define LPJ_EVT_L2MEAS_STOP_CFM 0x65   /*!< L2 Measurement stop confirm*/
+
+#define LPJ_ZEROSTS        0       /*!< Reset the statistics counters. */
+#define LPJ_NOZEROSTS      1       /*!< No reset of statistics counters. */
+
+/********************************************************************KW**
+ Specific event values
+*********************************************************************KW*/
+#define LPJ_EVENT_RGU_BND_CFM        (LCM_EVENT_LYR_SPECIFIC + 1)
+#define LPJ_EVENT_KWU_BND_REQ        (LCM_EVENT_LYR_SPECIFIC + 2)
+#define LPJ_EVENT_CKW_BND_REQ        (LCM_EVENT_LYR_SPECIFIC + 3)
+#define LPJ_EVENT_CPJ_BND_REQ        (LCM_EVENT_LYR_SPECIFIC + 4)
+#define LPJ_EVENT_PJU_BND_REQ        (LCM_EVENT_LYR_SPECIFIC + 5)
+
+/********************************************************************KW**
+ Specific cause values
+*********************************************************************KW*/
+#define LPJ_CAUSE_UNKNOWN        (LCM_CAUSE_LYR_SPECIFIC + 1)
+#define LPJ_CAUSE_SAP_BNDENB     (LCM_CAUSE_LYR_SPECIFIC + 2)
+#define LPJ_CAUSE_SAP_BNDDIS     (LCM_CAUSE_LYR_SPECIFIC + 3)
+#define LMG_CAUSE_RSRC_UNAVAIL   (LCM_CAUSE_LYR_SPECIFIC + 4)
+/* lpj_h_001.main_2 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+#define LPJ_CAUSE_MEM_FAILED         (LCM_CAUSE_LYR_SPECIFIC + 5)
+#define LPJ_CAUSE_INVALID_MEASTYPE   (LCM_CAUSE_LYR_SPECIFIC  + 6)
+#define LPJ_CAUSE_EXCEED_MEASREQ     (LCM_CAUSE_LYR_SPECIFIC  + 7)
+#define LPJ_CAUSE_EXCEED_NUMQCI      (LCM_CAUSE_LYR_SPECIFIC  + 8)
+#define LPJ_CAUSE_MEAS_ALREADY_ENA   (LCM_CAUSE_LYR_SPECIFIC  + 9)
+#define LPJ_CAUSE_INVALID_QCI        (LCM_CAUSE_LYR_SPECIFIC + 10)
+#define LPJ_CAUSE_ZERO_MEASPERIOD    (LCM_CAUSE_LYR_SPECIFIC + 11)
+#define LPJ_CAUSE_RB_DELETION        (LCM_CAUSE_LYR_SPECIFIC + 12)
+#endif
+/************************************************************************
+ *                         Events
+ ***********************************************************************/
+#define LPJ_EVT_BND_REQ       0     /*!< Bind Request Event. */
+#define LPJ_EVT_BND_CFM       1     /*!< Bind Confirm Event. */
+#define LPJ_EVT_UBND_REQ      2     /*!< Unbind Request Event. */
+#define LPJ_EVT_WAIT_BNDCFM   3     /*!< Wait Bind Confirm Event. */
+
+/*************************************************************************
+ *                            KWU SAPs
+ ************************************************************************/
+#define LPJ_RRC_SAP   0x00         /*!< RLU SAP ID for RRC */
+#define LPJ_PDCP_SAP  0x01         /*!< RLU SAP ID for PDCP */
+
+/********************************************************************KW**
+ Usta defines
+*********************************************************************KW*/
+#define LPJ_USTA_DGNVAL_NONE     1
+#define LPJ_USTA_DGNVAL_MEM      2
+#define LPJ_USTA_DGNVAL_SAPID    3
+#define LPJ_USTA_DGNVAL_UEID     4
+#define LPJ_USTA_MAX_DGNVAL      256
+/********************************************************************KW**
+ Specific event values
+*********************************************************************KW*/
+#define LPJ_EVENT_LI_BND_CFM        (LCM_EVENT_LYR_SPECIFIC + 1)
+
+#define LPJ_PART_NUM_STR_LEN        10        /*!< Part Number String Length. */
+
+/* lpj_h_001.main_2 added support for L2 Measurement */
+/********************************************************************KW**
+ L2 MEASUREMENT VALUES 
+*********************************************************************KW*/
+#ifdef LTE_L2_MEAS
+#define LPJ_L2MEAS_NONE       0x0000
+#define LPJ_L2MEAS_DL_DELAY   0x0001
+#define LPJ_L2MEAS_DL_DISC    0x0002
+#define LPJ_L2MEAS_UL_LOSS    0x0004
+#define LPJ_L2MEAS_DLDP_BIT_RATE 0x0008 /*Added for L2 Meas*/
+#define LPJ_L2MEAS_ULDP_BIT_RATE 0x0010
+#define LPJ_L2MEAS_DLCP_BIT_RATE 0x0020 
+#define LPJ_L2MEAS_ULCP_BIT_RATE 0x0040
+#define LPJ_L2CPU_PERCORE_STATS  0x0080
+#define LPJ_L2MEM_PERPOOL_STATS  0x0100
+
+#define LPJ_MAX_L2MEAS        5 
+#define LPJ_MAX_QCI             10
+#endif
+/* lpj_h_001.main_1 */
+#define LPJ_FULL_TRACE              -1        /*!< Trace macro to get full trace */   
+/* Added Log Error for LPJ Interface */
+#define LPJLOGERROR(_pst, _errCls, _errCode, _errVal, _errDesc) \
+        SLogError(_pst->srcEnt, _pst->srcInst, _pst->srcProcId, \
+                   __FILE__, __LINE__, _errCls, _errCode, _errVal, _errDesc)
+
+/* Error Codes */
+#define   ERRLPJ         0
+
+#define ELPJ001         (ERRLPJ + 1)
+#define ELPJ002         (ERRLPJ + 2)
+#define ELPJ003         (ERRLPJ + 3)
+#define ELPJ004         (ERRLPJ + 4)
+#define ELPJ005         (ERRLPJ + 5)
+#define ELPJ006         (ERRLPJ + 6)
+#define ELPJ007         (ERRLPJ + 7)
+#define ELPJ008         (ERRLPJ + 8)
+#define ELPJ009         (ERRLPJ + 9)
+#define ELPJ010         (ERRLPJ + 10)
+#define ELPJ011         (ERRLPJ + 11)
+#define ELPJ012         (ERRLPJ + 12)
+#define ELPJ013         (ERRLPJ + 13)
+#define ELPJ014         (ERRLPJ + 14)
+#define ELPJ015         (ERRLPJ + 15)
+#define ELPJ016         (ERRLPJ + 16)
+#define ELPJ017         (ERRLPJ + 17)
+#define ELPJ018         (ERRLPJ + 18)
+#define ELPJ019         (ERRLPJ + 19)
+#define ELPJ020         (ERRLPJ + 20)
+#define ELPJ021         (ERRLPJ + 21)
+#define ELPJ022         (ERRLPJ + 22)
+#define ELPJ023         (ERRLPJ + 23)
+#define ELPJ024         (ERRLPJ + 24)
+#define ELPJ025         (ERRLPJ + 25)
+#define ELPJ026         (ERRLPJ + 26)
+#define ELPJ027         (ERRLPJ + 27)
+#define ELPJ028         (ERRLPJ + 28)
+#define ELPJ029         (ERRLPJ + 29)
+#define ELPJ030         (ERRLPJ + 30)
+#define ELPJ031         (ERRLPJ + 31)
+#define ELPJ032         (ERRLPJ + 32)
+#define ELPJ033         (ERRLPJ + 33)
+#define ELPJ034         (ERRLPJ + 34)
+#define ELPJ035         (ERRLPJ + 35)
+#define ELPJ036         (ERRLPJ + 36)
+#define ELPJ037         (ERRLPJ + 37)
+#define ELPJ038         (ERRLPJ + 38)
+#define ELPJ039         (ERRLPJ + 39)
+#define ELPJ040         (ERRLPJ + 40)
+#define ELPJ041         (ERRLPJ + 41)
+#define ELPJ042         (ERRLPJ + 42)
+#define ELPJ043         (ERRLPJ + 43)
+#define ELPJ044         (ERRLPJ + 44)
+#define ELPJ045         (ERRLPJ + 45)
+#define ELPJ046         (ERRLPJ + 46)
+#define ELPJ047         (ERRLPJ + 47)
+#define ELPJ048         (ERRLPJ + 48)
+#define ELPJ049         (ERRLPJ + 49)
+#define ELPJ050         (ERRLPJ + 50)
+#define ELPJ051         (ERRLPJ + 51)
+#define ELPJ052         (ERRLPJ + 52)
+#define ELPJ053         (ERRLPJ + 53)
+#define ELPJ054         (ERRLPJ + 54)
+#define ELPJ055         (ERRLPJ + 55)
+#define ELPJ056         (ERRLPJ + 56)
+#define ELPJ057         (ERRLPJ + 57)
+#define ELPJ058         (ERRLPJ + 58)
+#define ELPJ059         (ERRLPJ + 59)
+#define ELPJ060         (ERRLPJ + 60)
+#define ELPJ061         (ERRLPJ + 61)
+#define ELPJ062         (ERRLPJ + 62)
+#define ELPJ063         (ERRLPJ + 63)
+#define ELPJ064         (ERRLPJ + 64)
+#define ELPJ065         (ERRLPJ + 65)
+#define ELPJ066         (ERRLPJ + 66)
+#define ELPJ067         (ERRLPJ + 67)
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __LPJ_H__ */
+
+\f  
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/cm/lpj.x b/src/cm/lpj.x
new file mode 100755 (executable)
index 0000000..c1d05c8
--- /dev/null
@@ -0,0 +1,951 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    PDCP Layer Manager Interface: LPJ
+    
+        Type:    C include file
+  
+        Desc:    This file Contains the Data structures and prototypes
+                 for LPJ Interface
+        File:    lpj.x
+  
+*********************************************************************21*/
+
+#ifndef __LPJ_X__
+#define __LPJ_X__
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif  /* __cplusplus */
+
+#if (defined(KW_PDCP) || defined(TENB_SPLIT_ARCH))
+/*typedef U32  CntrSts;*/
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+
+/** @struct PjOBPst
+ *  Post Info for Off-board Entities */
+typedef struct pjObdPst
+{
+   Pst           cmpPst;                    /*!< Service user post structure
+                                                 for compression */
+   Pst           secPst;                    /*!< Service user post structure
+                                                 for security algorithm */
+}PjObdPst;
+#endif /* PJ_SEC_ASYNC || PJ_CMP_ASYNC */
+
+/** @brief
+    General Configuration Structure. */
+typedef struct pjGenCfg
+{
+   Pst               lmPst;         /*!< Post structure for communicating
+                                         with LM. */
+   Ticks             timeRes;       /*!< Time resolution. */
+   U8                mode;      /*!< Pdcp mode DL / UL */
+   U8                maxPjuSaps;    /*!< Number of PDCP Data SAPs */
+   U8                maxKwuSaps;    /*!< Number of PDCP Data SAPs */
+   U8                maxUdxSaps;    /*!< Number of Udx  SAPs */
+   U8                nmbUlBins;     /*!< Number of bins which is used for 
+                                         RxBuff to store */
+   U8                nmbDlBins;     /*!< Number of bins which is used for 
+                                         RxBuff to store */
+   U32               maxUe;
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+   S32               obdTmrInt;     /*!< Timer Interval used while 
+                                         waiting for an output data from 
+                                         Off-board entities */
+   S32               obdWtTmrInt;   /*!< OBD wait timer used while opening
+                                         and closing the context with 
+                                         Off-board entities */
+   PjObdPst          obdPst;        /*!< Post Information for off-board Interface */
+#endif /* PJ_SEC_ASYNC || PJ_CMP_ASYNC */
+}PjGenCfg;
+
+/** @brief
+    SAP Configuration Structure */
+typedef struct pjSapCfg
+{
+   Selector          selector;      /*!< Selector for LC/TC. */
+   MemoryId          mem;           /*!< Region and pool. */
+   ProcId            procId;        /*!< Processor ID. */
+   Ent               ent;           /*!< Entity ID. */
+   Inst              inst;          /*!< Instance ID. */
+
+   SpId              sapId;         /*!< SAP ID. */
+   U16               bndTmrIntvl;   /*!< Bind timer interval. */
+   Priority          priority;      /*!< Priority. */
+   Route             route;         /*!< Route. */
+}PjSapCfg;
+
+/** @brief 
+*   Configuration Structure 
+*/
+typedef struct pjCfg
+{
+   union
+   {
+      PjGenCfg       gen;           /*!< General configuraton. */
+      PjSapCfg       sap;           /*!< SAP configuration. */
+   }s;
+}PjCfg;
+
+/** @brief 
+    General Statistics Structure */
+typedef struct pjGenSts
+{
+   CntrSts           numUe;
+   CntrSts           numOfRb;       /*!< Total number of RBs in PDCP */
+   CntrSts           rxPdus;        /*!< Number of PDUs received Layer from RLC. */
+   CntrSts           txPdus;        /*!< Number of PDUs sent to RLC. */
+   CntrSts           errorPdusRecv; /*!< Format error PDUs received from RLC. */
+   CntrSts           numSdusDisc;   /*!< Number of SDUs discarded due to PDCP
+                                         discard timer expiry. */
+   CntrSts           numCmpFails;     /*!< Number of Compression fails */
+   CntrSts           numDecmpFails;   /*!< Number of Decompression fails */
+   CntrSts           numIntgPrtFails; /*!< Number of Integration Protection fails */
+   CntrSts           numIntgVrfFails; /*!< Number of Integration Verification fails */
+   CntrSts           numCiphFails;    /*!< Number of Ciphering fails */
+   CntrSts           numDeciphFails;  /*!< Number of Deciphering fails */
+   CntrSts           numPdusDiscObdTmrExp;   /*!< Number of PDUs discarded in UL
+                                                  due to Off-board timer expiry. */
+   CntrSts           numSdusDiscObdTmrExp;   /*!< Number of SDUs discarded in DL
+                                                  due to Off-board timer expiry. */
+   CntrSts           numPktsFrwd;   /*!< Number of Packets forwarded to X2
+                                         interface */
+   CntrSts           numPktsRcvd;   /*!< Number of Packets recieved to X2
+                                         interface */
+}PjGenSts;
+
+/** @brief 
+    General Statistics Structure */
+typedef struct pjPjuSts
+{
+   /* lpj_x_001.main_1 modified from suId to spId */
+   SpId              spId;          /*!< Service provider ID. */
+   CntrSts           rxSdus;        /*!< Number of SDUs received Layer from UL. */
+   CntrSts           txSdus;        /*!< Number of SDUs sent to UL. */
+}PjPjuSts;
+/** @brief 
+    Statistics Structure */
+typedef struct pjSts
+{
+   DateTime       dt;               /*!< Date and Time structure. */
+   union
+   {
+      PjGenSts       gen;           /*!< General Statistics. */
+      PjPjuSts       pjuSap;        /*!< PJU SAP Statistics. */
+   }s;
+}PjSts;
+
+/** @brief 
+    PDCP Data Plane Upper SAP Status Structure */
+typedef struct pjPjuSapSta
+{
+   SpId              spId;          /*!< Service provider ID. */
+   State             state;         /*!< State of the SAP. */
+}PjPjuSapSta;
+
+/** @brief 
+    PDCP Uplink Downlink SAP Status Structure */
+typedef struct pjUdxSapSta
+{
+   SpId              spId;          /*!< Service provider ID. */
+   State             state;         /*!< State of the SAP. */
+}PjUdxSapSta;
+
+
+/** @brief 
+    PDCP Data Plane Upper SAP Status Structure */
+typedef struct pjKwuSapSta
+{
+   SpId              spId;          /*!< Service provider ID. */
+   State             state;         /*!< State of the SAP. */
+}PjKwuSapSta;
+
+/** @brief 
+    PDCP Control Plane SAP Status Structure */
+typedef struct pjCpjSapSta
+{
+   SpId              spId;          /*!< Service provider ID. */
+   State             state;         /*!< State of the SAP. */
+}PjCpjSapSta;
+
+/** @brief 
+    Status Structure */
+typedef struct pjSSta
+{
+   DateTime          dt;            /*!< Date and Time structure. */
+   union
+   {
+      SystemId       sysId;         /*!< System ID. */
+      PjCpjSapSta    cpjSap;        /*!< PDCP Control plane Upper SAP Status. */
+      PjPjuSapSta    pjuSap;        /*!< PDCP Data plane Upper SAP status. */
+      PjKwuSapSta    kwuSap;        /*!< PDCP Data plane Upper SAP status. */
+      PjUdxSapSta    udxSap;        /*!< PDCP Data plane Upper SAP status. */
+   }s;
+}PjSSta;
+
+/** @brief 
+    Trace Control Structure */
+typedef struct pjTrcCntrl
+{
+   U8                trcMask;       /*!< Trace mask. */
+   S16               trcLen;        /*!< Trace length. */
+}PjTrcCntrl;
+
+/** @brief 
+    Debug Control Structure */
+typedef struct pjDbgCntrl
+{
+   U32               dbgMask;       /*!< Debug mask. Assign non zero value to enable
+                                          and zero to disable debug */
+}PjDbgCntrl;
+
+/** @brief 
+    SAP Control Structure */
+typedef struct pjSapCntrl
+{
+   SuId              suId;          /*!< Service user ID. */
+   SpId              spId;          /*!< Service provider ID. */
+}PjSapCntrl;
+
+/** @brief 
+    Control Structure */
+typedef struct pjCntrl
+{
+   DateTime          dt;            /*!< Date and Time structure. */
+   U8                action;        /*!< Action. */
+   U8                subAction;     /*!< Sub action. */
+   union
+   {
+      PjTrcCntrl     trcCntrl;      /*!< Trace Control Structure. */
+      PjDbgCntrl     dbgCntrl;      /*!< Debug Control Structure. */
+#ifdef SS_DIAG
+      U32            logMask;       /*!< Logging Control Structure. */
+#endif
+      PjSapCntrl     sapCntrl;      /*!< Debug Control Structure. */
+   }s;
+}PjCntrl;
+
+/** @brief 
+    Unsolicited Status Structure */
+typedef struct pjUSta
+{
+   DateTime          dt;            /*!< Date and Time structure. */
+   CmAlarm           alarm;         /*!< Alarm. */
+   SuId              suId;          /*!< Service user ID. */
+   U32               ueId;          /*!< Urnti UE ID. */
+  /* lpj_x_001.main_1 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+   U8                qci;           /*!< QCI */
+#endif
+}PjUSta;
+
+/** @brief 
+    Trace Structure */
+typedef struct pjTrc
+{
+   DateTime          dt;            /*!< Date and Time structure. */
+   U16               event;         /*!< Event. Events defined in the different PDCP
+                                         interfaces are possible values here.*/
+}PjTrc;
+
+/** @brief 
+    Layer Management Structure */
+typedef struct _pjMngmt
+{
+   Header            hdr;           /*!< common header. */
+   CmStatus          cfm;           /*!< Status of confirmation. */
+   union 
+   {
+      PjCfg          cfg;           /*!< General Configuration. */
+      PjCntrl        cntrl;         /*!< Control Structure. */
+      PjSts          sts;           /*!< Statistics. */
+      PjSSta         ssta;          /*!< Status. */
+      PjUSta         usta;          /*!< Unsolicited Status. */
+      PjTrc          trc;           /*!< Trace Structre. */
+   }t;
+}PjMngmt;
+
+/* lpj_x_001.main_1 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+/** @brief Measurement Request Params Structure. */
+typedef struct pjL2MeasReqInfo
+{
+   U16  measType;            /*!< Type of measurement */
+   U8   numQci;              /*!< Number of qCI to take measurement for */
+   U8   qci[LPJ_MAX_QCI];    /*!< QCI for the measurement */
+}PjL2MeasReqInfo;
+
+/** @brief Measurement Request Structure. */
+typedef struct pjL2MeasReqEvt
+{
+   U32              transId;    /*!< Transaction identifier */
+   U16              measPeriod; /*!< Time period of measurement */
+   PjL2MeasReqInfo  measReq;    /*!< Measurement request */
+}PjL2MeasReqEvt;
+
+/** @brief Measurement Confirm Params Structure. */
+typedef struct pjL2MeasCfmInfo
+{
+   U8     qci;      /*!< Qci */
+   U32    dlDelay;  /*!< DL Delay */
+   U32    dlDisc;   /*!< DL Discard */
+   U32    ulLoss;   /*!< UL Loss */
+   U32    ulBitRate; /*!< UL Data Plane Bit Rate*/
+   U32    dlBitRate; /*!< DL Data Plane Bit Rate*/
+   U32    dlCpBitRate;/*!<Dl Control Plane Bit Rate*/
+   U32    ulCpBitRate;/*!<Ul Control Plane Bit Rate*/
+}PjL2MeasCfmInfo;
+
+/** @brief Measurement Confirm Structure. */
+typedef struct pjL2MeasCfmEvt
+{
+   U32              transId; /*!< Transaction identifier */
+   CmStatus         status;  /*!<Status */
+   U16              measType; /*!< Measurement type */
+   CmLteMemInfo     memoryInfo;
+   U16              numQciCfm;  /*!< Number of confirm */
+   PjL2MeasCfmInfo  measCfm[LPJ_MAX_QCI]; /*!< Measurement confirm */
+   U16              numCores;
+   CmLteCpuUtilInfo cmLteCpuInfo[CM_MAX_CPU_CORES]; 
+}PjL2MeasCfmEvt;
+#endif /*  LTE_L2_MEAS */
+
+/* Control primitives towards LTE PDCP */
+/* Pointer functions to pack/unpack primitives */
+typedef S16 (*LpjCfgReq)   ARGS((Pst *pst, PjMngmt *cfg));
+typedef S16 (*LpjCfgCfm)   ARGS((Pst *pst, PjMngmt *cfgCfm));
+
+typedef S16 (*LpjCntrlReq) ARGS((Pst *pst, PjMngmt *cntl));
+typedef S16 (*LpjCntrlCfm) ARGS((Pst *pst, PjMngmt *cntlCfm));
+
+typedef S16 (*LpjStaInd)   ARGS((Pst *pst, PjMngmt *staInd)); 
+typedef S16 (*LpjStaReq)   ARGS((Pst *pst, PjMngmt *staReq));
+typedef S16 (*LpjStaCfm)   ARGS((Pst *pst, PjMngmt *staCfm));
+
+typedef S16 (*LpjStsReq)   ARGS((Pst *pst, Action, PjMngmt *sts));
+typedef S16 (*LpjStsCfm)   ARGS((Pst *pst, Action, PjMngmt *stsCfm));
+
+typedef S16 (*LpjTrcInd)   ARGS((Pst *pst, PjMngmt *trc, Buffer *mBuf));
+
+/* lpj_x_001.main_1 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+typedef S16 (*LpjL2MeasReq)   ARGS((Pst *pst, PjL2MeasReqEvt *measEvt));
+typedef S16 (*LpjL2MeasCfm)   ARGS((Pst *pst, PjL2MeasCfmEvt *measEvt));
+typedef S16 (*LpjL2MeasStopReq)   ARGS((Pst *pst, U16 measType));
+typedef S16 (*LpjL2MeasSendReq)   ARGS((Pst *pst, U16 measType));
+typedef S16 (*LpjL2MeasStopCfm)   ARGS((Pst *pst, U16 measType,U8 status));
+#endif /*  LTE_L2_MEAS */
+/* Layer primitives */
+/** @details This function processes configuration requests received from the
+ * layer manager.The configuration requests are general configuration, or
+ * configuration of RGU, PJU, and PJU SAPs. The type of the configuration request is determined from the elmId field in the header of the layer manager message.This function is called by the layer manager to configure PDCP.
+
+@param[in] pst  - Pointer to post structure
+@param[in] cfg  - Configuration management structure
+@return ROK if success , RFAILED if failure
+
+*/
+EXTERN S16 PjMiLpjCfgReq ARGS((Pst *pst, PjMngmt *cfg));
+
+/**
+@details This function is called by the PjMiLpjCfgReq function for responding to configuration requests.The cfm field in the PjMngmt structure contains the response value.
+
+@param[in] pst  - Pointer to post structure
+@param[in] cfm  - Configuration management structure
+@return ROK if success, RFAILED if failure
+*/
+EXTERN S16 PjMiLpjCfgCfm ARGS((Pst *pst, PjMngmt *cfgCfm));
+
+/**
+@details
+The layer manager initiates and uses the management-control procedure to control
+PDCP elements.The PDCP control request primitive (PjMiLpjCntrlReq) can be called
+more than once and at any time after the management-configuration procedure.The
+control request primitive is confirmed by a PjMiLpjCntrlCfm primitive.
+
+@param[in] pst  - Pointer to post structure
+@param[in] cntl - Configuration management structure
+@return ROK if success , RFAILED if failure
+*/
+EXTERN S16 PjMiLpjCntrlReq ARGS((Pst *pst, PjMngmt *cntl));
+
+/**
+@details
+This function is called by the PjMiLpjCntrlReq function to send a control confirm to the layer management module.
+
+@param[in] pst  - Pointer to post structure
+@param[in] cfm  - Configuration management structure
+@return ROK if success , RFAILED if failure
+*/
+EXTERN S16 PjMiLpjCntrlCfm ARGS((Pst *pst, PjMngmt *cntlCfm));
+
+/**
+@details
+This function processes solicited status requests received from the layer manage
+r.The layer manager can request status information regarding the system ID, RGSA
+P,KWSAP, or CKSAP.
+
+@param[in] pst  - Pointer to post structure
+@param[in] cfg  - Configuration management structure
+@return ROK if success , RFAILED if failure
+*/
+EXTERN S16 PjMiLpjStaReq ARGS((Pst *pst, PjMngmt *staInd));
+
+/**
+@details
+This function is called by the PjMiLpjStaReq function to send the requested stat
+us information to the layer manager.
+
+@param[in] pst   - Pointer to post structure
+@param[in] stacfm - Configuration management structure
+@return ROK if success , RFAILED if failure
+*/
+EXTERN S16 PjMiLpjStaCfm ARGS((Pst *pst, PjMngmt *staCfm));
+
+/**
+@details
+This function processes statistics requests received from the layer manager. Aft
+er collecting the statistics, this function calls the statistics confirm functio
+n to send the statistics to the layer manager.
+
+@param[in] pst   - Pointer to post structure  
+@param[in] acton - action 
+@param[in] sts   - Configuration management structure
+@return ROK if success , RFAILED if failure
+*/
+EXTERN S16 PjMiLpjStsReq ARGS((Pst *pst, Action, PjMngmt *sts));
+/**
+@details
+This function is called by the PjMiLpjStsReq function for responding to statisti
+cs requests.
+
+@param[in] pst   - Pointer to post structure
+@param[in] action - action 
+@param[in] cfg  - Configuration management structure
+@return ROK if success , RFAILED if failure
+*/
+EXTERN S16 PjMiLpjStsCfm ARGS((Pst *pst, Action action, PjMngmt *stsCfm));
+/**
+@details
+This function can be used by PDCP module to send unsolicited trace indications to
+the layer manager, when tracing is enabled by the layer manager through a previo
+us control request.
+
+@param[in] pst  - Pointer to post structure
+@param[in] cfg  - Configuration management structure
+@param[in] buf  - buffer 
+@return ROK if success , RFAILED if failure
+*/
+EXTERN S16 PjMiLpjTrcInd ARGS ((Pst *pst, PjMngmt *trc, Buffer *mBuf));
+
+/**
+@details This function can be used by PDCP to send unsolicited status information t
+o the layer manager, when the unsolicited status flag is enabled by the layer ma
+nager through a previous control request.
+
+@param[in] pst  - Pointer to post structure
+@param[in] staReq - Configuration management structure
+@return ROK if success , RFAILED if failure
+*/
+EXTERN S16 PjMiLpjStaInd ARGS((Pst *pst, PjMngmt *staReq));
+
+/* lpj_x_001.main_1 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+/**
+@details This function is called by the Layer Manger function to request 
+for Measurement  responding to statisti cs requests.
+
+@param[in] pst  - Pointer to post structure
+@param[in] measEvt - Measurement Request structure
+@return ROK if success , RFAILED if failure
+*/
+EXTERN S16 PjMiLpjL2MeasReq ARGS((Pst *pst, PjL2MeasReqEvt *measEvt));
+EXTERN S16 PjMiLpjL2MeasStopReq ARGS((Pst *pst, U16 measType));
+EXTERN S16 PjMiLpjL2MeasSendReq ARGS((Pst *pst, U16 measType));
+EXTERN S16 PjMiLpjL2MeasStopCfm ARGS((Pst *pst, U16 measType, U8 status));
+/**
+@details This function can be used by PDCP to send the measurement values
+after doing L2 measurement that was requested by the layer manager.
+
+@param[in] pst  - Pointer to post structure
+@param[in] measEvt - Measurement confirmation structure
+@return ROK if success , RFAILED if failure
+*/
+EXTERN S16 PjMiLpjL2MeasCfm ARGS((Pst *pst, PjL2MeasCfmEvt *measCfm));
+EXTERN S16 SmMiLpjL2MeasStopCfm ARGS((
+Pst     *pst,          
+U16      measType,
+U8      status
+));
+EXTERN S16 PjMiLpjL2MeasStopCfm ARGS((  
+Pst *pst,
+U16  measType,
+U8  status
+));
+#endif /*  LTE_L2_MEAS */
+
+EXTERN Void pjSendLmAlarm ARGS ((U16 category,
+      U16  event,
+      U16 cause,
+      SuId suId,
+      U32 ueId));
+
+#ifdef SM
+EXTERN S16 SmMiLpjCfgCfm   ARGS((
+       Pst *,
+       PjMngmt *
+       ));
+
+EXTERN S16 SmMiLpjCntrlCfm ARGS((
+       Pst *,
+       PjMngmt *
+       ));
+
+EXTERN S16 SmMiLpjStaInd   ARGS((
+       Pst *,
+       PjMngmt *
+       ));
+
+EXTERN S16 SmMiLpjStaCfm   ARGS((
+       Pst *,
+       PjMngmt *
+       ));
+
+EXTERN S16 SmMiLpjStsCfm   ARGS((
+       Pst *,
+       Action,
+       PjMngmt *
+       ));
+
+EXTERN S16 SmMiLpjTrcInd   ARGS((
+       Pst *,
+       PjMngmt *,
+       Buffer *
+       ));
+
+EXTERN S16 SmMiLpjStsReq   ARGS((
+       Pst *,
+       Action,
+       PjMngmt *
+       ));
+
+EXTERN S16 SmMiLpjStaReq   ARGS((
+       Pst *,
+       PjMngmt *
+       ));
+
+EXTERN S16 SmMiLpjCntrlReq ARGS((
+       Pst *,
+       PjMngmt *
+       ));
+
+EXTERN S16 SmMiLpjCfgReq   ARGS((
+       Pst *,
+       PjMngmt *
+       ));
+
+/* lpj_x_001.main_1 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+EXTERN S16 SmMiLpjL2MeasReq   ARGS((
+       Pst *,
+       PjL2MeasReqEvt *
+       ));
+EXTERN S16 SmMiLpjL2MeasCfm   ARGS((
+       Pst *,
+       PjL2MeasCfmEvt *
+       ));
+EXTERN S16 SmMiLpjL2MeasStopReq   ARGS((
+       Pst *pst,
+       U16  measType
+       ));
+
+EXTERN S16 SmMiLpjL2MeasSendReq   ARGS((
+       Pst *pst,
+       U16  measType
+       ));
+EXTERN S16 SmMiLpjL2MeasStopCfm   ARGS((
+       Pst *pst,
+       U16 measType,
+       U8 stauts
+       ));
+#endif /*  LTE_L2_MEAS */
+#endif
+
+EXTERN S16 smPjActvInit    ARGS((Ent ent, Inst inst, Region region, Reason reason));
+EXTERN S16 smPjActvTsk     ARGS((Pst *pst, Buffer *mBuf));
+
+/* pack/unpack functions */
+#ifdef LCLPJ 
+
+EXTERN S16 cmPkLpjCfgReq ARGS((
+Pst * pst,
+PjMngmt * cfg
+));
+EXTERN S16 cmUnpkLpjCfgReq ARGS((
+LpjCfgReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjCfgCfm ARGS((
+Pst * pst,
+PjMngmt * cfgCfm
+));
+EXTERN S16 cmUnpkLpjCfgCfm ARGS((
+LpjCfgCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjCntrlReq ARGS((
+Pst * pst,
+PjMngmt * cntl
+));
+EXTERN S16 cmUnpkLpjCntrlReq ARGS((
+LpjCntrlReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjCntrlCfm ARGS((
+Pst * pst,
+PjMngmt * cntlCfm
+));
+EXTERN S16 cmUnpkLpjCntrlCfm ARGS((
+LpjCntrlCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjStaInd ARGS((
+Pst * pst,
+PjMngmt * staInd
+));
+EXTERN S16 cmUnpkLpjStaInd ARGS((
+LpjStaInd func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjStaReq ARGS((
+Pst * pst,
+PjMngmt * staReq
+));
+EXTERN S16 cmUnpkLpjStaReq ARGS((
+LpjStaReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjStaCfm ARGS((
+Pst * pst,
+PjMngmt * staCfm
+));
+EXTERN S16 cmUnpkLpjStaCfm ARGS((
+LpjStaCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjStsReq ARGS((
+Pst * pst,
+Action actn,
+PjMngmt * sts
+));
+EXTERN S16 cmUnpkLpjStsReq ARGS((
+LpjStsReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjStsCfm ARGS((
+Pst * pst,
+Action actn,
+PjMngmt * stsCfm
+));
+EXTERN S16 cmUnpkLpjStsCfm ARGS((
+LpjStsCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjTrcInd ARGS((
+Pst * pst,
+PjMngmt * trc,
+Buffer * mBuf
+));
+EXTERN S16 cmUnpkLpjTrcInd ARGS((
+LpjTrcInd func,
+Pst *pst,
+Buffer *mBuf
+));
+/* lpj_x_001.main_1 added support for L2 Measurement */
+#ifdef LTE_L2_MEAS
+EXTERN S16 cmPkLpjL2MeasReq ARGS((
+Pst * pst,
+PjL2MeasReqEvt * measReqEvt
+));
+EXTERN S16 cmUnpkLpjL2MeasReq ARGS((
+LpjL2MeasReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjL2MeasStopReq ARGS((
+Pst * pst,
+U16 measType
+));
+EXTERN S16 cmUnpkLpjL2MeasStopReq ARGS((
+LpjL2MeasStopReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjL2MeasSendReq ARGS((
+Pst * pst,
+U16 measType
+));
+EXTERN S16 cmUnpkLpjL2MeasSendReq ARGS((
+LpjL2MeasSendReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjL2MeasCfm ARGS((
+Pst * pst,
+PjL2MeasCfmEvt *measCfmEvt
+));
+EXTERN S16 cmUnpkLpjL2MeasCfm ARGS((
+LpjL2MeasCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjL2MeasReqInfo ARGS((
+PjL2MeasReqInfo * measReqInfo,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjL2MeasReqInfo ARGS((
+PjL2MeasReqInfo * measReqInfo,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjL2MeasCfmInfo ARGS((
+PjL2MeasCfmInfo * measCfmInfo,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjL2MeasCpuCfmInfo ARGS((
+CmLteCpuUtilInfo * measCpuCfmInfo,
+Buffer *mBuf
+)); 
+
+EXTERN S16 cmPkPjL2MeasMemoryCfmInfo ARGS((
+CmLteMemInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjL2MeasCpuCfmInfo ARGS((
+CmLteCpuUtilInfo * measCpuCfmInfo,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjL2MeasMemoryCfmInfo ARGS((
+CmLteMemInfo *param,
+Buffer *mBuf
+));
+
+EXTERN S16 cmUnpkPjL2MeasCfmInfo ARGS((
+PjL2MeasCfmInfo * measCfmInfo,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjL2MeasStopReq ARGS((
+Pst * pst,
+U16  measType
+));
+EXTERN S16 cmUnpkLpjL2MeasStopReq ARGS((
+LpjL2MeasStopReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkLpjL2MeasSendReq ARGS((
+Pst * pst,
+U16  measType
+));
+EXTERN S16 cmUnpkLpjL2MeasSendReq ARGS((
+LpjL2MeasSendReq func,
+Pst *pst,
+Buffer *mBuf
+));
+
+EXTERN S16 cmPkLpjL2MeasStopCfm ARGS((
+Pst * pst,
+U16 measType,
+U8 status
+));
+EXTERN S16 cmUnpkLpjL2MeasStopCfm ARGS((
+LpjL2MeasStopCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+#endif /*  LTE_L2_MEAS */
+
+#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
+EXTERN S16 cmPkPjObdPst ARGS((
+PjObdPst *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjObdPst ARGS((
+PjObdPst *param,
+Buffer *mBuf
+));
+#endif /* PJ_SEC_ASYNC || PJ_CMP_ASYNC */
+
+EXTERN S16 cmPkPjGenCfg ARGS((
+PjGenCfg *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjGenCfg ARGS((
+PjGenCfg *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjSapCfg ARGS((
+PjSapCfg *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjSapCfg ARGS((
+PjSapCfg *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjCfg ARGS((
+PjMngmt *cfg,
+Elmnt elmnt,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjCfg ARGS((
+PjMngmt *cfg,
+Elmnt elmnt,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjGenSts ARGS((
+PjGenSts *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjGenSts ARGS((
+PjGenSts *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjPjuSts ARGS((
+PjPjuSts *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjPjuSts ARGS((
+PjPjuSts *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjSts ARGS((
+PjMngmt *sts,
+Elmnt elmnt,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjSts ARGS((
+PjMngmt *sts,
+Elmnt elmnt,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjPjuSapSta ARGS((
+PjPjuSapSta *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjPjuSapSta ARGS((
+PjPjuSapSta *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjCpjSapSta ARGS((
+PjCpjSapSta *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjCpjSapSta ARGS((
+PjCpjSapSta *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjSSta ARGS((
+PjMngmt *ssta,
+Elmnt elmnt,
+Event eventType,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjSSta ARGS((
+PjMngmt *ssta,
+Elmnt elmnt,
+Event eventType,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjTrcCntrl ARGS((
+PjTrcCntrl *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjTrcCntrl ARGS((
+PjTrcCntrl *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjDbgCntrl ARGS((
+PjDbgCntrl *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjDbgCntrl ARGS((
+PjDbgCntrl *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjCntrl ARGS((
+PjMngmt *cntrl,
+Elmnt elmnt,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjCntrl ARGS((
+PjMngmt *cfm,
+Elmnt elmnt,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjUSta ARGS((
+PjMngmt *usta,
+Elmnt elmnt,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjUSta ARGS((
+PjMngmt *usta,
+Elmnt elmnt,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjTrc ARGS((
+PjMngmt *trc,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjTrc ARGS((
+PjMngmt *trc,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjMngmt ARGS((
+PjMngmt *param,
+Event eventType,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjMngmt ARGS((
+PjMngmt *param,
+Event eventType,
+Buffer *mBuf
+));
+
+#endif
+#endif /* TENB_SPLIT_ARCH */
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __LPJ_X__ */
+
+\f  
+/********************************************************************30**
+         End of file
+**********************************************************************/
diff --git a/src/cm/pju.h b/src/cm/pju.h
new file mode 100755 (executable)
index 0000000..a324ccd
--- /dev/null
@@ -0,0 +1,185 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE PDCP Interface  
+    
+        Type:    C include file
+  
+        Desc:    This file contains the defines required by PDCP user.
+        File:    pju.h
+  
+*********************************************************************21*/
+\f
+#ifndef __PJU_H__
+#define __PJU_H__
+
+#ifdef __cplusplus
+EXTERN "C" {
+#endif  /*for extern "C"*/
+
+/**
+ * @file 
+ * @brief Macro for PJU Interface 
+ */
+
+\f
+#define PJU_SEL_LC         0
+/* cause for status Indication */   
+#define PJU_INTVER_FAILED      1      /*!< Integrity Verification Failed */
+#define PJU_DCIP_FAILED        2      /*!< Deciphering Failed */
+#define PJU_DCOMP_FAILED       3      /*!< Decompression Failed */
+#define PJU_COMP_FAILED        4      /*!< Compression Failed */
+#define PJU_INTPROT_FAILED     5      /*!< Integrity Protection Failed */
+#define PJU_CIPHER_FAILED      6      /*!< Ciphering Failed */
+#define PJU_MAX_SDU_SIZ_EXCEED 7      /*!< Maximum SDU Size Exceeded */
+
+/* event values 0x00 - 0x40 is used for CPJ interface */
+
+#define EVTPJUBNDREQ      0x40    /*!< Bind request */
+#define EVTPJUBNDCFM      0x41    /*!< Bind confirm */
+#define EVTPJUUBNDREQ     0x42    /*!< Unbind request */
+#define EVTPJUDATREQ      0x43    /*!< Data reqest */
+#define EVTPJUDATIND      0x44    /*!< PJU data indication */
+#define EVTPJUDATCFM      0x45    /*!< Data request confirm */ 
+#define EVTPJUSTAIND      0x46    /*!< PJU status indication */
+#define EVTPJUDATFWDREQ   0x47    /*!< PJU status indication */
+#define EVTPJUDATFWDIND   0x48    /*!< PJU status indication */
+#ifdef TENB_AS_SECURITY
+#define EVTPJUTTIIND      0x49    /*!< TTI Indication from CL just in case
+                                    PDCP wants to do some periodic activity*/
+#endif
+#define EVTFPPJUDATIND    0x50    /*!< PJU data indication for BC */
+#define EVTPCAPIPDATIND    0x51    /*!< PJU data indication for PCAP Data Indication */
+
+#define PJU_DAT_CFM_SUCCESS 0     /*!< Data confirm status */
+#define PJU_RLC_TRANS_FAIL  1     /*!< RLC transaction failed */
+#define PJU_DISCARD_TMR_EXP 2     /*!< Discard timer expiry */
+
+/* MAX values */
+#define PJU_MAX_SDU_CFM    1024     /*!< Maximum SDUs that can be 
+                                       confirmed in a DatCfm */
+
+/* Error Codes */
+#define EPJUXXX                     0
+#define ERRPJU                      0
+
+#define EPJU001         (ERRPJU + 1)
+#define EPJU002         (ERRPJU + 2)
+#define EPJU003         (ERRPJU + 3)
+#define EPJU004         (ERRPJU + 4)
+#define EPJU005         (ERRPJU + 5)
+#define EPJU006         (ERRPJU + 6)
+#define EPJU007         (ERRPJU + 7)
+#define EPJU008         (ERRPJU + 8)
+#define EPJU009         (ERRPJU + 9)
+#define EPJU010         (ERRPJU + 10)
+#define EPJU011         (ERRPJU + 11)
+#define EPJU012         (ERRPJU + 12)
+#define EPJU013         (ERRPJU + 13)
+#define EPJU014         (ERRPJU + 14)
+#define EPJU015         (ERRPJU + 15)
+#define EPJU016         (ERRPJU + 16)
+#define EPJU017         (ERRPJU + 17)
+#define EPJU018         (ERRPJU + 18)
+#define EPJU019         (ERRPJU + 19)
+#define EPJU020         (ERRPJU + 20)
+#define EPJU021         (ERRPJU + 21)
+#define EPJU022         (ERRPJU + 22)
+#define EPJU023         (ERRPJU + 23)
+#define EPJU024         (ERRPJU + 24)
+#define EPJU025         (ERRPJU + 25)
+#define EPJU026         (ERRPJU + 26)
+#define EPJU027         (ERRPJU + 27)
+#define EPJU028         (ERRPJU + 28)
+#define EPJU029         (ERRPJU + 29)
+#define EPJU030         (ERRPJU + 30)
+#define EPJU031         (ERRPJU + 31)
+#define EPJU032         (ERRPJU + 32)
+#define EPJU033         (ERRPJU + 33)
+#define EPJU034         (ERRPJU + 34)
+#define EPJU035         (ERRPJU + 35)
+#define EPJU036         (ERRPJU + 36)
+#define EPJU037         (ERRPJU + 37)
+#define EPJU038         (ERRPJU + 38)
+#define EPJU039         (ERRPJU + 39)
+#define EPJU040         (ERRPJU + 40)
+#define EPJU041         (ERRPJU + 41)
+#define EPJU042         (ERRPJU + 42)
+#define EPJU043         (ERRPJU + 43)
+#define EPJU044         (ERRPJU + 44)
+#define EPJU045         (ERRPJU + 45)
+#define EPJU046         (ERRPJU + 46)
+#define EPJU047         (ERRPJU + 47)
+#define EPJU048         (ERRPJU + 48)
+#define EPJU049         (ERRPJU + 49)
+#define EPJU050         (ERRPJU + 50)
+#define EPJU051         (ERRPJU + 51)
+#define EPJU052         (ERRPJU + 52)
+#define EPJU053         (ERRPJU + 53)
+#define EPJU054         (ERRPJU + 54)
+#define EPJU055         (ERRPJU + 55)
+#define EPJU056         (ERRPJU + 56)
+#define EPJU057         (ERRPJU + 57)
+#define EPJU058         (ERRPJU + 58)
+#define EPJU059         (ERRPJU + 59)
+#define EPJU060         (ERRPJU + 60)
+#define EPJU061         (ERRPJU + 61)
+#define EPJU062         (ERRPJU + 62)
+#define EPJU063         (ERRPJU + 63)
+#define EPJU064         (ERRPJU + 64)
+#define EPJU065         (ERRPJU + 65)
+#define EPJU066         (ERRPJU + 66)
+#define EPJU067         (ERRPJU + 67)
+#define EPJU068         (ERRPJU + 68)
+#define EPJU069         (ERRPJU + 69)
+#define EPJU070         (ERRPJU + 70)
+#define EPJU071         (ERRPJU + 71)
+#define EPJU072         (ERRPJU + 72)
+#define EPJU073         (ERRPJU + 73)
+#define EPJU074         (ERRPJU + 74)
+#define EPJU075         (ERRPJU + 75)
+#define EPJU076         (ERRPJU + 76)
+#define EPJU077         (ERRPJU + 77)
+#define EPJU078         (ERRPJU + 78)
+#define EPJU079         (ERRPJU + 79)
+#define EPJU080         (ERRPJU + 80)
+#define EPJU081         (ERRPJU + 81)
+#define EPJU082         (ERRPJU + 82)
+#define EPJU083         (ERRPJU + 83)
+#define EPJU084         (ERRPJU + 84)
+#define EPJU085         (ERRPJU + 85)
+#define EPJU086         (ERRPJU + 86)
+#define EPJU087         (ERRPJU + 87)
+#define EPJU088         (ERRPJU + 88)
+#define EPJU089         (ERRPJU + 89)
+#define EPJU090         (ERRPJU + 90)
+#define EPJU091         (ERRPJU + 91)
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __PJU_H__ */
+
+\f
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/
diff --git a/src/cm/pju.x b/src/cm/pju.x
new file mode 100755 (executable)
index 0000000..5808d5b
--- /dev/null
@@ -0,0 +1,787 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/********************************************************************20**
+  
+        Name:    LTE PDCP Interface  
+    
+        Type:    C include file
+  
+        Desc:    This file contains the Data structures for LTE PDCP Interface.
+        File:    pju.x
+  
+*********************************************************************21*/
+#ifndef __PJU_X__
+#define __PJU_X__
+
+#ifdef __cplusplus
+EXTERN "C" { 
+#endif  /*for extern "C"*/
+   
+/**
+ * @file 
+ * @brief PJU Interface File
+ */
+
+/*************************************************************************
+ *                      START OF STRUCTURES
+ ************************************************************************/
+typedef U32       PjuSduId;            /*!< SDU ID */
+typedef U32       PjuSduLen;           /*!< Length of SDU in bytes */
+
+/**
+ * @brief   Data Confirmation Status parameters.
+*/
+
+typedef struct pjuDatCfmSta
+{
+   PjuSduId       sduId;               /*!< SDU ID for AM */
+   U8             status;              /*!< Status, Value can be
+
+                                            -# PJU_DAT_CFM_SUCCESS,
+                                            -# PJU_RLC_TRANS_FAIL,
+                                            -# PJU_DISCARD_TMR_EXP */
+}PjuDatCfmSta;
+
+/**
+ * @brief   Data Confirmation parameters
+*/
+
+typedef struct pjuDatCfmInfo      
+{
+   U16            numSdus;                  /*!< Number of SDUs for which cfm is sent */
+   PjuDatCfmSta   cfmSta[PJU_MAX_SDU_CFM];  /*!< Data Confirm Status */
+}PjuDatCfmInfo;
+
+/**
+ * @brief   Status Indication parameters
+*/
+typedef struct pjuStaIndInfo      
+{
+   U8   cause;                         /*!< Error cause */
+}PjuStaIndInfo;
+
+/**
+ * @brief   Data Forward Information
+*/
+typedef struct pjuDatFwdInfo
+{
+   PjuSduId       sduId;               /*!< SDU ID */
+   U16            sn;                  /*!< SN associated with the SDU */
+   Buffer         *sdu;                /*!< Forwarded SDU sent / received during 
+                                            handover */
+}PjuDatFwdInfo;
+
+/**
+ * @brief   Data Forward Request parameters for PDCP 
+            entity mapped to RLC AM
+*/
+
+typedef struct pjuDatFwdReqInfo
+{
+   U8             dir;                 /*!< Data forwarded for 
+                                            UL/DL PDCP entity */
+   U16            numSdus;             /*!< Number of SDUs in DatFwdReq */
+   PjuDatFwdInfo  *datFwdInfo;         /*!< Data Forward Information */
+   Bool           isLastDatFwdInd;     /*!< Last Data Foward Indication */
+}PjuDatFwdReqInfo;        
+
+/**
+ * @brief   Data Forward Indication parameters for PDCP
+            entity mapped to RLC AM
+*/
+typedef PjuDatFwdReqInfo PjuDatFwdIndInfo;
+typedef struct pjuDatReqInfo
+{
+  SpId         spId;
+  CmLtePdcpId  pdcpId;
+  PjuSduId     sduId;
+}PjuDatReqInfo;
+typedef struct pjuDatIndInfo
+{
+  SuId         suId;
+  CmLtePdcpId  pdcpId;
+}PjuDatIndInfo;
+/*************************************************************************
+ *                      END OF STRUCTURES
+ ************************************************************************/
+
+/******************************************************************************
+ *                   Prototypes for the selector matrices                     *
+ ******************************************************************************/
+
+
+typedef S16 (*PjuBndReq)     ARGS((
+        Pst *, 
+        SuId, 
+        SpId
+        ));
+
+typedef S16 (*PjuBndCfm)     ARGS((
+        Pst *, 
+        SuId, 
+        U8
+        ));
+
+typedef S16 (*PjuUbndReq)    ARGS((
+        Pst *, 
+        SpId,  
+        Reason
+        ));
+
+typedef S16 (*PjuDatReq)     ARGS((
+        Pst *, 
+        SpId, 
+        CmLtePdcpId *,
+        PjuSduId,
+        Buffer *
+        ));
+
+#ifdef FLAT_BUFFER_OPT
+typedef S16 (*PjuDatReqFB)     ARGS((
+        Pst *, 
+        SpId, 
+        CmLtePdcpId *,
+        PjuSduId,
+        FlatBuffer *
+        ));
+#endif
+
+
+typedef S16 (*PjuDatCfm)     ARGS((
+        Pst *, 
+        SuId, 
+        CmLtePdcpId *,
+        PjuDatCfmInfo *
+        ));
+
+typedef S16 (*PjuDatInd)     ARGS((
+        Pst *, 
+        SuId, 
+        CmLtePdcpId *,
+        Buffer *
+        ));
+
+typedef S16 (*PjuStaInd)     ARGS((
+        Pst *, 
+        SuId, 
+        CmLtePdcpId *,
+        PjuStaIndInfo *,
+        Buffer *
+        ));
+
+typedef S16 (*PjuDatFwdReq)     ARGS((
+        Pst *, 
+        SpId, 
+        CmLtePdcpId *,
+        PjuDatFwdReqInfo *
+        ));
+
+typedef S16 (*PjuDatFwdInd)     ARGS((
+        Pst *, 
+        SuId, 
+        CmLtePdcpId *,
+        PjuDatFwdIndInfo *
+        ));
+
+/* pju_x_001.main_2 */
+/*************************************************************************
+ *                   Start of Extern Interface Declarations
+ ************************************************************************/
+/**
+  * @brief Bind request primitive 
+  * @details
+  * The function binds the PDCP service user entity to the PDCP product.
+  * The PDCP service user must bind each PJU SAP individually before sending
+  * any other request. PDCP acknowledges the receipt of the bind request by
+  * sending a @ref PjUiPjuBndCfm primitive.
+  *
+  * @param[in] pst   - Pointer to the pst structure.
+  * @param[in] suId  - Service user ID. This is the reference number used by the 
+  * PDCP service user to identify its SAP. This reference number is
+  * provided by PDCP in any further primitives sent by PDCP to the service user.
+  * @param[in] spId  - Service provider ID. This is the reference number
+  * used by the PDCP service user (Relay) to identify its SAP. This reference number
+  * is provided by PDCP in any further primitives sent by the PDCP
+  * to the service user.
+  *
+  * @return ROK
+  */
+EXTERN S16 PjUiPjuBndReq ARGS(( Pst* , SuId , SpId));
+
+/**
+ * @brief Bind confirm primitive
+ * @details
+ * PDCP invokes the bind confirm primitive to acknowledge the receipt 
+ * of the @ref PjUiPjuBndReq primitive from the service user. The status
+ * field indicates whether the bind request succeeded or failed. The bind
+ * request may fail due to invalid parameters in the bind request from the
+ * service user (for example, an invalid spId).
+ *
+ * @param[in] pst    - Pointer to the pst structure.
+ * @param[in] suId   - Service user ID. This is the reference number used
+ * by the PDCP service user (Relay or RRC layer) to identify its SAP.
+ * @param[in] status - Status field indicates whether the bind request
+ * succeeded or failed. 
+ *  -# TRUE, if successful bind.
+ *  -# FALSE, otherwise.
+ *
+ *  @return ROK.
+ */
+EXTERN S16 PjUiPjuBndCfm ARGS(( Pst*, SuId, U8));
+
+/**
+ * @brief Unbind request primitive 
+ * @details
+ * The PDCP service user initiates this primitive for performing an unbind
+ * operation. This function brings the link between PDCP and its service user 
+ * down if it is already up, and releases all the resources associated for 
+ * this SAP at PDCP.
+ *
+ * @param[in] pst   - Pointer to pst structure.
+ * @param[in] spId  - Service provider ID. This is the reference number
+ * used by the PDCP service user (Relay) to identify its SAP. This reference number
+ * is provided by the PDCP in any further primitives sent by the PDCP
+ * to the service user.
+ * @param[in] reason - Unbind reason. Not used in the current implementation. 
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUiPjuUbndReq ARGS(( Pst*, SpId, Reason));
+
+/**
+ * @brief Data request primitive
+ * @details
+ * This primitive is used by the PDCP service user to request the PDCP
+ * for data transfer.
+ *
+ * @param[in] pst    - Pointer to pst structure.
+ * @param[in] spId   - Service provider ID. This is the reference number
+ * used by the PDCP service user (Relay) to identify its SAP. This reference number
+ * is provided by the PDCP in any further primitives sent by the PDCP
+ * to the service user.
+ * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP ID is used to 
+ * uniquely identify a PDCP entity. 
+ * @param[in] sduId  - SDU ID. 
+ * @param[in] mBuf   - Pointer to data buffer.
+ *
+ * @return ROK
+ */
+EXTERN S16 PjUiPjuDatReq ARGS(( Pst*, SpId, CmLtePdcpId *, PjuSduId, Buffer*));
+#ifdef FLAT_BUFFER_OPT
+EXTERN S16 PjUiPjuDatReqFB ARGS(( Pst*, SpId, CmLtePdcpId *, PjuSduId, FlatBuffer*));
+#endif
+
+/**
+ * @brief Data confirm primitive
+ * @details
+ * This primitive is sent to the PDCP user to acknowledge the status of the SDU delivered
+ * to the lower layer. Its applicable only for PDCP entities mapped with RLC AM.
+ *
+ * @param[in] pst    - Pointer to pst structure.
+ * @param[in] suId   - Service user ID. This is the reference number used by the PDCP
+ user to identify its SAP.
+ * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP ID is used to 
+ uniquely identify a PDCP entity. 
+ * @param[in] datCfm - Pointer to data confirm structure. 
+ *
+ *  @return ROK.
+ */
+EXTERN S16 PjUiPjuDatCfm ARGS((Pst*, SuId, CmLtePdcpId *, PjuDatCfmInfo *));
+
+/**
+ * @brief Data indication primitive
+ * @details
+ * This primitive is used to send the data received from the lower layer 
+ * to the service user.
+ *
+ * @param[in] pst    - Pointer to pst structure.
+ * @param[in] suId   - Service user ID. This is the reference number used
+ * by the PDCP user to identify its SAP.
+ * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP ID is used
+ * to uniquely identify a PDCP entity. 
+ * @param[in] mBuf   - Pointer to data buffer.
+ *
+ *  @return ROK.
+ */
+EXTERN S16 PjUiPjuDatInd ARGS((Pst*, SuId, CmLtePdcpId *, Buffer*));
+
+/**
+ * @brief Status indication primitive
+ * @details
+ * This primitive is used by the PDCP to indicate to the PDCP service user about 
+ * the arrival of invalid PDUs (integrity protection or ciphering failed). 
+ *
+ * @param[in] pst    - Pointer to pst structure.
+ * @param[in] suId   - Service user ID. This is the reference number used
+ * by the PDCP user to identify its SAP.
+ * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP ID is used to 
+ * uniquely identify a PDCP entity. 
+ * @param[in] staInd - Pointer to status indication structure. 
+ * @param[in] mBuf   - PDU for which integrity protection failed.
+ *
+ *  @return ROK.
+ */
+EXTERN S16 PjUiPjuStaInd ARGS((Pst*, SuId, CmLtePdcpId *, PjuStaIndInfo *, Buffer *));
+
+
+/**
+ * @brief Data Forward Request primitive
+ * @details
+ * This primitive is used by PDCP user to forward the SDUs along with its SN
+ * as part of handover (SDUs forwarded from PDCP on source eNB through X2-U 
+ * interface to the PDCP on target eNB).
+ *
+ * @param[in] pst       - Pointer to pst structure.
+ * @param[in] spId      - Service provider ID. This is the reference number
+ * used by PDCP service user (Relay) to identify its SAP. This reference number
+ * is provided by PDCP in any further primitives sent by PDCP
+ * to the service user.
+ * @param[in] pdcpId    - Pointer to CmLtePdcpId structure, PDCP ID is used to 
+ * uniquely identify a PDCP entity. 
+ * @param[in] datFwdReq - Pointer to data forward information structure.
+ *
+ *  @return ROK.
+ */
+EXTERN S16 PjUiPjuDatFwdReq ARGS((Pst*, SpId, CmLtePdcpId *, PjuDatFwdReqInfo *));
+
+
+/**
+ * @brief Data Forward Indication primitive
+ * @details
+ * This primitive is used by PDCP to forward the SDUs along with its SN
+ * as part of handover (SDUs forwarded from PDCP on source eNB through X2-U 
+ * interface to the PDCP on target eNB).
+ *
+ * @param[in] pst       - Pointer to pst structure.
+ * @param[in] suId      - Service user ID. This is the reference number used
+ * by the PDCP user to identify its SAP.
+ * @param[in] pdcpId    - Pointer to CmLtePdcpId structure, PDCP ID is used to 
+ * uniquely identify a PDCP entity. 
+ * @param[in] datFwdInd - Pointer to data forward information structure.
+ *
+ *  @return ROK.
+ */
+EXTERN S16 PjUiPjuDatFwdInd ARGS((Pst*, SuId, CmLtePdcpId *, PjuDatFwdIndInfo *));
+
+
+/*************************************************************************
+ *                   End of Extern Interface Declarations
+ ************************************************************************/
+
+#ifdef DM
+EXTERN S16 DmUiPjuBndReq ARGS((
+                     Pst*,                       
+                     SuId,                    
+                     SpId
+                     ));
+
+EXTERN S16 DmUiPjuUbndReq ARGS((
+                     Pst*,                       
+                     SpId,                     
+                     Reason
+                     ));
+
+
+EXTERN S16 DmUiPjuBndCfm ARGS((
+                     Pst*,                       
+                     SuId,                     
+                     U8
+                     ));
+
+EXTERN S16 DmUiPjuDatReq ARGS((
+                     Pst*,                      
+                     SpId,                    
+                     CmLtePdcpId *,         
+                     PjuSduId ,
+                     Buffer*
+                     ));
+
+EXTERN S16 DmUiPjuDatInd ARGS((
+                     Pst*,                     
+                     SuId,                   
+                     CmLtePdcpId *,         
+                     Buffer*
+                     ));
+
+EXTERN S16 DmUiPjuDatCfm ARGS((
+                     Pst*,                      
+                     SuId,                    
+                     CmLtePdcpId *,         
+                     PjuDatCfmInfo *
+                     ));
+
+EXTERN S16 DmUiPjuStaInd ARGS((
+                     Pst*,                     
+                     SuId,                   
+                     CmLtePdcpId *,         
+                     PjuStaIndInfo * 
+                     ));
+
+EXTERN S16 DmUiPjuDatFwdReq ARGS((
+                     Pst*,                      
+                     SpId,                    
+                     CmLtePdcpId *,         
+                     PjuDatFwdReqInfo *
+                     ));
+
+EXTERN S16 DmUiPjuDatFwdInd ARGS((
+                     Pst*,                     
+                     SuId,                   
+                     CmLtePdcpId *,         
+                     PjuDatFwdIndInfo *
+                     ));
+#endif /* DM */
+
+/******************************************************************************
+*                        Prototypes for LTE-PDCP layer                           *
+******************************************************************************/
+
+#ifdef PX  /* for LTE PDCP to PX (Relay) */ 
+
+EXTERN S16 PxLiPjuBndReq     ARGS((
+       Pst *, 
+       SuId, 
+       SpId
+       ));
+
+EXTERN S16 PxLiPjuUbndReq    ARGS((
+       Pst *, 
+       SuId, 
+       Reason
+       ));
+
+EXTERN S16 PxLiPjuDatReq     ARGS((
+       Pst *, 
+       SpId, 
+       CmLtePdcpId *,
+       PjuSduId,
+       Buffer *
+       ));
+
+EXTERN S16 PxLiPjuBndCfm ARGS((
+       Pst *,
+       SuId,
+       U8
+       ));
+
+EXTERN S16 PxLiPjuDatInd ARGS((
+       Pst *,
+       SuId,
+       CmLtePdcpId *,
+       Buffer *
+       ));
+
+EXTERN S16 PxLiPjuDatCfm    ARGS((
+       Pst *,
+       SuId ,
+       CmLtePdcpId *,
+       PjuDatCfmInfo *
+       ));
+
+EXTERN S16 PxLiPjuStaInd ARGS((
+       Pst*,                     
+       SuId,                   
+       CmLtePdcpId *,         
+       PjuStaIndInfo * ,
+       Buffer *
+       ));
+
+EXTERN S16 PxLiPjuDatFwdReq     ARGS((
+       Pst *, 
+       SpId, 
+       CmLtePdcpId *,
+       PjuDatFwdReqInfo *
+       ));
+
+
+EXTERN S16 PxLiPjuDatFwdInd ARGS((
+       Pst *,
+       SuId, 
+       CmLtePdcpId *,                  
+       PjuDatFwdIndInfo *
+       ));
+
+#endif /* PX */
+
+#ifdef NH  /* for LTE RLC to NH  */
+
+EXTERN S16 NhLiPjuBndReq     ARGS((
+       Pst *, 
+       SuId, 
+       SpId
+       ));
+
+EXTERN S16 NhLiPjuUbndReq    ARGS((
+       Pst *, 
+       SuId, 
+       Reason
+       ));
+
+EXTERN S16 NhLiPjuDatReq     ARGS((
+       Pst *, 
+       SpId, 
+       CmLtePdcpId *,
+       PjuSduId,
+       Buffer *
+       ));
+
+EXTERN S16 NhLiPjuBndCfm ARGS((
+       Pst *,
+       SuId,
+       U8
+       ));
+
+EXTERN S16 NhLiPjuDatInd ARGS((
+       Pst *,
+       SuId,
+       CmLtePdcpId *,
+       Buffer *
+       ));
+
+EXTERN S16 NhLiPjuDatCfm    ARGS((
+       Pst *,
+       SuId ,
+       CmLtePdcpId *,
+       PjuDatCfmInfo *
+       ));
+
+EXTERN S16 NhLiPjuStaInd ARGS((
+       Pst*,                     
+       SuId,                   
+       CmLtePdcpId *,         
+       PjuStaIndInfo * ,
+       Buffer *
+       ));
+
+EXTERN S16 NhLiPjuDatFwdReq     ARGS((
+       Pst *, 
+       SpId, 
+       CmLtePdcpId *,
+       PjuDatFwdReqInfo *
+       ));
+
+
+EXTERN S16 NhLiPjuDatFwdInd ARGS((
+       Pst *,
+       SuId, 
+       CmLtePdcpId *,                  
+       PjuDatFwdIndInfo *
+       ));
+
+#endif /* NH */
+
+/******************************************************************************
+ *                           pack/unpack functions                            *
+ ******************************************************************************/
+
+#ifdef LCPJU
+
+EXTERN S16 cmPkPjuBndReq ARGS((
+Pst* pst,
+SpId suId,
+SuId spId
+));
+EXTERN S16 cmUnpkPjuBndReq ARGS((
+PjuBndReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjuBndCfm ARGS((
+Pst* pst,
+SuId suId,
+U8 status
+));
+EXTERN S16 cmUnpkPjuBndCfm ARGS((
+PjuBndCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjuUbndReq ARGS((
+Pst* pst,
+SpId spId,
+Reason reason
+));
+EXTERN S16 cmUnpkPjuUbndReq ARGS((
+PjuUbndReq func,
+Pst *pst,
+Buffer *mBuf
+));
+#ifdef SS_RBUF
+EXTERN S16 cmPkFpPjuDatReq ARGS((
+Pst* pst,
+SpId spId,
+CmLtePdcpId * pdcpId,
+PjuSduId sduId,
+Buffer * mBuf
+));
+#endif
+EXTERN S16 cmPkPjuDatReq ARGS((
+Pst* pst,
+SpId spId,
+CmLtePdcpId * pdcpId,
+PjuSduId sduId,
+Buffer * mBuf
+));
+#ifdef FLAT_BUFFER_OPT
+EXTERN S16 cmPkPjuDatReqFB ARGS((
+Pst* pst,
+SpId spId,
+CmLtePdcpId * pdcpId,
+PjuSduId sduId,
+FlatBuffer * mBuf
+));
+#endif
+
+#ifdef SS_RBUF
+EXTERN S16 cmUnpkFpPjuDatReq ARGS((
+PjuDatReq func,
+Pst *pst,
+Buffer *mBuf
+));
+#endif
+EXTERN S16 cmUnpkPjuDatReq ARGS((
+PjuDatReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjuDatCfm ARGS((
+Pst* pst,
+SuId suId,
+CmLtePdcpId * pdcpId,
+PjuDatCfmInfo * datCfm
+));
+EXTERN S16 cmUnpkPjuDatCfm ARGS((
+PjuDatCfm func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjuDatInd ARGS((
+Pst* pst,
+SuId suId,
+CmLtePdcpId * pdcpId,
+Buffer * mBuf
+));
+EXTERN S16 cmUnpkPjuDatInd ARGS((
+PjuDatInd func,
+Pst *pst,
+Buffer *mBuf
+));
+
+#ifdef SS_RBUF
+EXTERN S16 cmPkFpPjuDatInd ARGS((
+Pst* pst,
+SuId suId,
+CmLtePdcpId * pdcpId,
+Buffer * mBuf
+));
+
+EXTERN S16 cmUnpkFpPjuDatInd ARGS((
+PjuDatInd func,
+Pst *pst,
+Buffer *mBuf
+));
+#endif
+
+EXTERN S16 cmPkPjuStaInd ARGS((
+Pst* pst,
+SuId suId,
+CmLtePdcpId * pdcpId,
+PjuStaIndInfo * staInd,
+Buffer *buff
+));
+EXTERN S16 cmUnpkPjuStaInd ARGS((
+PjuStaInd func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjuDatFwdReq ARGS((
+Pst* pst,
+SpId spId,
+CmLtePdcpId * pdcpId,
+PjuDatFwdReqInfo * datFwdReq
+));
+EXTERN S16 cmUnpkPjuDatFwdReq ARGS((
+PjuDatFwdReq func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjuDatFwdInd ARGS((
+Pst* pst,
+SuId suId,
+CmLtePdcpId * pdcpId,
+PjuDatFwdIndInfo * datFwdInd
+));
+EXTERN S16 cmUnpkPjuDatFwdInd ARGS((
+PjuDatFwdInd func,
+Pst *pst,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjuDatCfmInfoSta ARGS((
+PjuDatCfmSta *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjuDatCfmInfoSta ARGS((
+PjuDatCfmSta *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjuDatCfmInfo ARGS((
+PjuDatCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjuDatCfmInfo ARGS((
+PjuDatCfmInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjuStaIndInfo ARGS((
+PjuStaIndInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjuStaIndInfo ARGS((
+PjuStaIndInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjuDatFwdReqInfo ARGS((
+PjuDatFwdReqInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjuDatFwdReqInfo ARGS((
+Pst *pst,
+PjuDatFwdReqInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmPkPjuDatFwdInfo ARGS((
+PjuDatFwdInfo *param,
+Buffer *mBuf
+));
+EXTERN S16 cmUnpkPjuDatFwdInfo ARGS((
+PjuDatFwdInfo *param,
+Buffer *mBuf
+));
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __PJU_X__ */
+/********************************************************************30**
+  
+         End of file
+**********************************************************************/