1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /**********************************************************************
25 Desc: Source code for PDCP Utility Module
27 This file contains following functions:
41 **********************************************************************/
42 static const char* RLOG_MODULE_NAME="PDCP";
43 static int RLOG_FILE_ID=251;
44 static int RLOG_MODULE_ID=1024;
47 @brief PDCP Utility Module
50 /* header (.h) include files */
51 #include "envopt.h" /* environment options */
52 #include "envdep.h" /* environment dependent */
53 #include "envind.h" /* environment independent */
55 #include "gen.h" /* general */
56 #include "ssi.h" /* system services */
57 #include "cm5.h" /* common timer defines */
58 #include "cm_tkns.h" /* common tokens defines */
59 #include "cm_mblk.h" /* common memory allocation library defines */
60 #include "cm_llist.h" /* common link list defines */
61 #include "cm_hash.h" /* common hash list defines */
62 #include "cm_lte.h" /* common LTE defines */
63 #include "cpj.h" /* CPJ defines */
64 #include "pju.h" /* PJU defines */
65 #include "lpj.h" /* LPJ defines */
67 #include "pj_env.h" /* RLC environment options */
68 #include "pj.h" /* RLC defines */
71 #include "pj_err.h" /* Error defines */
73 /* extern (.x) include files */
74 #include "gen.x" /* general */
75 #include "ssi.x" /* system services */
77 #include "cm5.x" /* common timer library */
78 #include "cm_tkns.x" /* common tokens */
79 #include "cm_mblk.x" /* common memory allocation */
80 #include "cm_llist.x" /* common link list */
81 #include "cm_hash.x" /* common hash list */
82 #include "cm_lte.x" /* common LTE includes */
83 #include "cm_lib.x" /* common memory allocation library */
84 #include "cpj.x" /* CPJ */
85 #include "pju.x" /* PJU */
86 #include "lpj.x" /* LPJ */
88 #include "pj_udx.h" /* LIB */
89 #include "pj_udx.x" /* LIB */
92 #include "pj_lib.x" /* LIB */
96 #endif /* __cplusplus */
98 PRIVATE S16 pjUtlUlHdlSecInitCfm ARGS((PjCb *gCb,PjUlUeCb *ueCb,
99 U16 txIdx,PjAsyncCfm *asyncCfm, CpjSecCfgCfmInfo *secCfgCfm,CpjReEstCfmInfo *reEstCfm));
100 PRIVATE S16 pjUtlUlHdlCmpInitCfm ARGS((PjCb *gCb,PjUlUeCb *ueCb,
101 U16 txIdx,PjAsyncCfm *asyncCfm, CpjCfgCfmInfo *cfgCfm));
103 EXTERN S16 PjLibObdSwDecipherReq(PjLibTrans *libTrans, Buffer *mBuf, PjCb *gCb, Buffer **opSdu);
105 /********************************************************************
106 * Utility Handler for Sending to Offboarding unit *
107 *******************************************************************/
113 * Handler for opening the context with the compression unit (either
114 * synchronous or asynchronous) for RB within an UE.
118 * This function opens the context with the compression unit per RB per
119 * UE, by sending ROHC configuration elements using synchronous / asynchronous
120 * function calls with relevant input parameters.
123 * @param[in] pjRbCb PDCP RbCb
130 PUBLIC S16 pjUtlUlCmpInit
133 PjUlRbCb *pjRbCb /* PDCP RbCb */
136 PUBLIC S16 pjUtlUlCmpInit(pjRbCb)
138 PjUlRbCb *pjRbCb; /* PDCP RbCb */
143 RLOG2(L_DEBUG, "pjUtlUlCmpInit(pjRbCb(%d,%d))",
144 pjRbCb->rbId, pjRbCb->rbType);
147 pjRbCb->ueCb->libInfo.tCmpInitBitMask |= (1 << (pjRbCb->rbId - 1));
148 pjRbCb->ueCb->libInfo.tLibInitBitMask |= PJ_LIB_COMP_BIT_MASK;
149 pjRbCb->cmpCxt.cfgTxId = pjRbCb->ueCb->libInfo.nxtAvlbTxId;
151 PjLibObdCmpInitReq(&gCb->pjGenCfg.obdPst.cmpPst,
152 pjRbCb->cmpCxt, pjRbCb->rohc);
154 pjLibCmpInitReq(pjRbCb->cmpCxt, pjRbCb->rohc, &(pjRbCb->cmpCxtId));
155 #endif /* PJ_CMP_ASYNC */
159 } /* end of pjUtlCmpInit */
167 * Handler for opening the context with the Integration unit (either
168 * synchronous or asynchronous) for all SRBs of an UE.
172 * This function opens the context with the security algo unit per UE
173 * for Integration protection/verification by sending the configured
174 * Integrity Info using synchronous / asynchronous function calls with
175 * relevant input parameters.
177 * @param[in] pjRbCb Pointer to RB control Block
185 PUBLIC S16 pjUtlUlIntInit
188 PjUlUeCb *ueCb /* UE CB Ptr */
191 PUBLIC S16 pjUtlUlIntInit(ueCb)
193 PjUlUeCb *ueCb; /* UE CB Ptr */
198 Void *ctxId = NULL; /* KW_FIX */
201 U32 *libInitBitMask = NULLP;
207 RLOG2(L_DEBUG, "pjUtlUlIntInit(ueCb(%d,%d))",
208 ueCb->key.ueId, ueCb->key.cellId);
212 if(ueCb->libInfo.state == PJ_STATE_REEST)
214 for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
216 if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
217 (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM))
219 libInitBitMask = &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask;
224 else if(ueCb->libInfo.state == PJ_STATE_NORMAL)
226 libInitBitMask = &ueCb->libInfo.tLibInitBitMask;
231 (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_INT_BIT_MASK;
234 ret = PjLibObdIntInitReq(&gCb->pjGenCfg.obdPst.secPst,
235 ueCb->secInfo.secCxt, ueCb->secInfo.intInfo);
238 #ifdef QAT_TWO_INSTNACES
239 pjLibIntInitReq(gCb->u.ulCb->instHndl, ueCb->secInfo.intInfo,&ctxId);
241 pjLibIntInitReq(gCb, ueCb->secInfo.intInfo,&ctxId);
243 ueCb->secInfo.cpIntSessCxtId = ctxId;
245 pjLibIntInitReq(ueCb->secInfo.secCxt, ueCb->secInfo.intInfo,&(ctxId));
246 ueCb->secInfo.intCxtId = ctxId;
248 #endif /* PJ_SEC_ASYNC */
252 } /* end of pjUtlIntInit */
258 * Handler for opening the context with the Ciphering unit (either
259 * synchronous or asynchronous) for SRBs of an UE.
263 * This function opens the context with the security algo unit per UE
264 * for ciphering / deciphering by key by sending the configured
265 * Ciphering Info with control plane key using synchronous / asynchronous
266 * function calls with relevant input parameters.
268 * @param[in] pjRbCb Pointer to RB control Block
275 PUBLIC S16 pjUtlUlCpInit
278 PjUlUeCb *ueCb /* UE CB Ptr */
281 PUBLIC S16 pjUtlUlCpInit(ueCb)
283 PjUlUeCb *ueCb; /* UE CB Ptr */
288 Void *ctxId = NULL; /* KW_FIX */
291 U32 *libInitBitMask = NULLP;
297 RLOG2(L_DEBUG, "pjUtlCpInit(ueCb(%d,%d))",
298 ueCb->key.ueId, ueCb->key.cellId);
302 if(ueCb->libInfo.state == PJ_STATE_REEST)
304 for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
306 if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
307 (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM))
309 libInitBitMask = &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask;
314 else if(ueCb->libInfo.state == PJ_STATE_NORMAL)
316 libInitBitMask = &ueCb->libInfo.tLibInitBitMask;
321 (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_CP_CIP_BIT_MASK;
323 ret = PjLibObdCpInitReq(&gCb->pjGenCfg.obdPst.secPst, ueCb->secInfo.secCxt,
324 ueCb->secInfo.cipherInfo.algoType, ueCb->secInfo.cipherInfo.cpKey);
327 #ifdef QAT_TWO_INSTANCE
328 ret = pjLibCpInitReq(gCb->u.ulCb->instHndl, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
329 ueCb->secInfo.cipherInfo.cpKey, &ctxId);
331 ret = pjLibCpInitReq(gCb, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
332 ueCb->secInfo.cipherInfo.cpKey, &ctxId);
334 ueCb->secInfo.cpCiphSessCxtId = ctxId;
336 ret = pjLibCpInitReq(ueCb->secInfo.secCxt, (U8)ueCb->secInfo.cipherInfo.algoType,
337 ueCb->secInfo.cipherInfo.cpKey, &ctxId); /*KW_FIX*/
338 ueCb->secInfo.cpCxtId = ctxId;
339 #endif /* INTEL_QAT_DP */
340 #endif /* PJ_SEC_ASYNC */
344 } /* end of pjUtlCpInit */
350 * Handler for opening the context with the Ciphering unit (either
351 * synchronous or asynchronous) for DRBs of an UE.
355 * This function opens the context with the security algo unit per UE
356 * for ciphering / deciphering by sending the configured
357 * Ciphering Info with user plane key using synchronous / asynchronous
358 * function calls with relevant input parameters.
360 * @param[in] pjRbCb Pointer to RB control Block
367 PUBLIC S16 pjUtlUlUpInit
370 PjUlUeCb *ueCb /* UE CB Ptr */
373 PUBLIC S16 pjUtlUpInit(gCb,ueCb)
375 PjUlUeCb *ueCb; /* UE CB Ptr */
380 Void* ctxId = NULL; /* KW_FIX */
383 U32 *libInitBitMask = NULLP;
388 RLOG2(L_DEBUG, "pjUtlUpInit(ueCb(%d,%d))",
389 ueCb->key.ueId, ueCb->key.cellId);
393 if(ueCb->libInfo.state == PJ_STATE_REEST)
395 for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
397 if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
398 (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM))
400 libInitBitMask = &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask;
405 else if(ueCb->libInfo.state == PJ_STATE_NORMAL)
407 libInitBitMask = &ueCb->libInfo.tLibInitBitMask;
411 (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_UP_CIP_BIT_MASK;
413 ret = PjLibObdUpInitReq(&gCb->pjGenCfg.obdPst.secPst, ueCb->secInfo.secCxt,
414 ueCb->secInfo.cipherInfo.algoType, ueCb->secInfo.cipherInfo.upKey);
417 #ifdef QAT_TWO_INSTANCE
418 pjLibUpInitReq(gCb->u.ulCb->instHndl, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
419 ueCb->secInfo.cipherInfo.upKey, &ctxId);
421 pjLibUpInitReq(gCb, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
422 ueCb->secInfo.cipherInfo.upKey, &ctxId);
424 ueCb->secInfo.upCiphSessCxtId= ctxId;
426 pjLibUpInitReq(ueCb->secInfo.secCxt, (U8)ueCb->secInfo.cipherInfo.algoType,
427 ueCb->secInfo.cipherInfo.upKey, &ctxId); /*KW_FIX*/
428 ueCb->secInfo.upCxtId = ctxId;
429 #endif /* INTEL_QAT_DP */
430 #endif /* PJ_SEC_ASYNC */
434 } /* end of pjUtlUpInit */
441 * Handler for resetting the context with the compression unit (either
442 * synchronous or asynchronous) for RB within an UE.
446 * This function resets the context with the compression unit per RB per
447 * UE by using synchronous / asynchronous function calls.
450 * @param[in] cmpCxtId Context to be reset for compression
457 PUBLIC S16 pjUtlUlCmpReset
460 PjUlRbCb *pjRbCb /* Context to be reset for compression */
463 PUBLIC S16 pjUtlUlCmpReset(pjRbCb)
465 PjUlRbCb *pjRbCb; /* Context to be reset for compression */
468 TRC3(pjUtlUlCmpReset)
470 RLOG2(L_DEBUG, "pjUtlUlCmpReset(pjRbCb(%d,%d))",
471 pjRbCb->rbId, pjRbCb->rbType);
474 PjLibObdCmpResetReq(&gCb->pjGenCfg.obdPst.cmpPst, pjRbCb->cmpCxtId);
476 pjLibCmpResetReq(pjRbCb->cmpCxtId);
481 } /* end of pjUtlCmpReset */
488 * Handler for closing the UL context with the Ciphering unit (either
489 * synchronous or asynchronous) for SRBs of an UE.
493 * This function closes an existing UL context with the security algo unit per UE
494 * for ciphering / deciphering with control plane key using synchronous / asynchronous
495 * function calls with relevant input parameters.
498 * @param[in] cpCxtId Context Id for Ciphering to be closed
505 PUBLIC S16 pjUtlUlCipherClose
508 Void *cpCxtId /* Context Id for Ciphering to be closed */
511 PUBLIC S16 pjUtlUlCipherClose(cpCxtId)
513 Void *cpCxtId; /* Context Id for Ciphering to be closed */
517 TRC3(pjUtlUlCipherClose)
518 RLOG0(L_DEBUG, "pjUtlUlCipherClose");
521 #ifdef QAT_TWO_INSTANCE
522 ret = PjLibObdCipherCloseReq(gCb->u.ulCb->instHndl, cpCxtId);
524 ret = PjLibObdCipherCloseReq(gCb->instHndl, cpCxtId);
527 PjLibObdCipherCloseReq(cpCxtId);
531 #ifdef QAT_TWO_INSTANCE
532 ret = PjLibObdCipherCloseReq(gCb->u.ulCb->instHndl, cpCxtId);
534 ret = PjLibObdCipherCloseReq(gCb->instHndl, cpCxtId);
537 PjLibObdCipherCloseReq(&gCb->pjGenCfg.obdPst.secPst, cpCxtId);
541 } /* end of pjUtlCipherClose */
546 * Handler for closing the UL context with the Integration unit (either
547 * synchronous or asynchronous) for all RBs of an UE.
551 * This function closes an existing UL context with the security algo unit per UE
552 * for Integration protection/verification using synchronous / asynchronous function
553 * calls with relevant input parameters.
556 * @param[in] intCxtId Integration CxtId to be closed
563 PUBLIC S16 pjUtlUlIntClose
566 Void *intCxtId /* Integration CxtId to be closed */
569 PUBLIC S16 pjUtlUlIntClose(intCxtId)
571 Void *intCxtId; /* Integration CxtId to be closed */
575 TRC3(pjUtlUlIntClose)
576 RLOG0(L_DEBUG, "pjUtlUlIntClose");
578 #ifdef TENB_AS_SECURITY
580 #ifdef QAT_TWO_INSTANCE
581 ret = PjLibObdIntCloseReq(gCb->u.ulCb->instHndl,intCxtId);
583 ret = PjLibObdIntCloseReq(gCb->instHndl,intCxtId);
588 PjLibObdIntCloseReq(&gCb->pjGenCfg.obdPst.secPst,intCxtId);
590 PjLibObdIntCloseReq(intCxtId);
594 } /* end of pjUtlIntClose */
600 * Handler for redirecing deciphering request to either synchronous
601 * or asynchronous module.
605 * This function sends deciphering request as either synchronous or
606 * asynchronous function calls with relevant input parameters.
608 * @param[in] pjRbCb PDCP RbCb
609 * @param[in] secInp Input parameters for deciphering
610 * @param[in] mBuf Data to be deciphered
611 * @param[in] opSdu Deciphered SDU
618 #ifdef TENB_AS_SECURITY
620 PUBLIC S16 pjUtlDecipherReq
623 PjUlRbCb *pjRbCb, /* PDCP RbCb */
625 Buffer *mBuf, /* Data to be deciphered */
626 Buffer **opSdu /* Deciphered SDU */
629 PUBLIC S16 pjUtlDecipherReq(gCb, pjRbCb, count, mBuf, opSdu)
631 PjUlRbCb *pjRbCb; /* PDCP RbCb */
633 Buffer *mBuf; /* Data to be deciphered */
634 Buffer **opSdu; /* Deciphered SDU */
641 Void *cxtId = NULLP; /* Context Identifier */
643 TRC3(pjUtlDecipherReq)
646 if (pjRbCb->rbType == PJ_SRB)
648 cxtId = pjRbCb->ueCb->secInfo.cpCxtId;
652 cxtId = pjRbCb->ueCb->secInfo.upCxtId;
655 ulUeCb = pjRbCb->ueCb;
656 libTrans.pdcpInstance = gCb->init.inst;
657 libTrans.count = count;
658 libTrans.rbId = pjRbCb->rbId - 1;
659 libTrans.dir = PJ_SEC_DIR_UL;
660 libTrans.rbType = pjRbCb->rbType;
661 libTrans.snLen = pjRbCb->snLen;
662 libTrans.ciphAlgoType = ulUeCb->secInfo.cipherInfo.algoType;
663 libTrans.ueCb = (PTR)ulUeCb;
664 libTrans.ueId = ulUeCb->key.ueId;
665 libTrans.cellId = ulUeCb->key.cellId;
666 if(PJ_SRB == pjRbCb->rbType)
668 libTrans.key = ulUeCb->secInfo.cipherInfo.cpKey;
670 libTrans.sessCxtId = ulUeCb->secInfo.cpCiphSessCxtId;
671 #ifdef QAT_TWO_INSTANCE
672 libTrans.instHndl = gCb->u.ulCb->instHndl;
674 libTrans.instHndl = gCb->instHndl;
680 libTrans.key = ulUeCb->secInfo.cipherInfo.upKey;
682 libTrans.sessCxtId = ulUeCb->secInfo.upCiphSessCxtId;
683 #ifdef QAT_TWO_INSTANCE
684 libTrans.instHndl = gCb->u.ulCb->instHndl;
686 libTrans.instHndl = gCb->instHndl;
692 /* Start the timer if it is not started already */
693 if((pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE)
695 pjRbCb->ulCb.obdPdu = secInp.count;
696 pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
698 ret = PjLibObdDecipherReq(&(gCb->pjGenCfg.obdPst.secPst),
699 cxtId, secInp, libTrans, mBuf);
702 /* TODO: 3rd arg is unused can be removed */
703 ret = PjLibObdDecipherReq(&libTrans, mBuf, opSdu);
706 ret = PjLibObdDecipherReq(&libTrans, mBuf, opSdu);
708 ret = PjLibObdSwDecipherReq(&libTrans, mBuf, gCb,opSdu);
713 } /* end of pjUtlDecipherReq */
716 PUBLIC S16 pjUtlDecipherReq
718 PjCb *gCb, /* Cell Cb */
719 PjUlRbCb *pjRbCb, /* PDCP RbCb */
721 Buffer *mBuf, /* Data to be deciphered */
722 Buffer **opSdu /* Deciphered SDU */
725 PUBLIC S16 pjUtlDecipherReq(gCb, pjRbCb, count, mBuf, opSdu)
727 PjUlRbCb *pjRbCb; /* PDCP RbCb */
729 Buffer *mBuf; /* Data to be deciphered */
730 Buffer **opSdu; /* Deciphered SDU */
735 PjLibTrans libTrans; /* Transaction Id for deciphering */
738 #endif /* PJ_SEC_ASYNC */
739 PTR cxtId; /* Context Identifier */
740 TRC3(pjUtlDecipherReq)
741 if (pjRbCb->rbType == PJ_SRB)
743 cxtId = (PTR)pjRbCb->ueCb->secInfo.cpCxtId;
747 cxtId = (PTR)pjRbCb->ueCb->secInfo.upCxtId;
750 /* Assign transId and cxtId */
751 libTrans.count = count;
752 /* kw005.201 ccpu00114955 corrected the RB ID calculation */
753 libTrans.rbId = pjRbCb->rbId - 1;
754 libTrans.rbType = pjRbCb->rbType;
755 libTrans.ueCb = pjRbCb->ueCb;
756 /* Start the timer if it is not started already */
757 if((pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE)
759 pjRbCb->ulCb.obdPdu = secInp.count;
760 pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
762 ret = PjLibObdDecipherReq(&gCb->pjGenCfg.obdPst.secPst,
763 cxtId, secInp, libTrans, mBuf);
765 secInp.count = count;
766 secInp.rbId = pjRbCb->rbId - 1;
768 ret = pjLibDecipherReq(cxtId, secInp, mBuf, opSdu);
771 } /* end of pjUtlDecipherReq */
777 * Handler for redirecing Integration request to either synchronous
778 * or asynchronous module.
782 * This function sends Intergrity verification request as either synchronous or
783 * asynchronous function calls with relevant input parameters.
785 * @param[in] pjRbCb PDCP RbCb
786 * @param[in] secInp Input parameters for integrity
787 * @param[in] mBuf SDU to be compressed
788 * @param[out] status Integrity verification status
794 #ifdef TENB_AS_SECURITY
796 PUBLIC S16 pjUtlIntVerReq
799 PjUlRbCb *pjRbCb, /* PDCP RbCb */
800 PjSecInp secInp , /* Input parameters for integrity */
801 Buffer *mBuf, /* SDU to be compressed */
802 U32 macI, /* MAC-I to be verified with */
803 Status *status /* Integrity verification status */
806 PUBLIC S16 pjUtlIntVerReq(pjRbCb, secInp, mBuf, macI, status)
808 PjUlRbCb *pjRbCb; /* PDCP RbCb */
809 PjSecInp secInp; /* Input parameters for integrity */
810 Buffer *mBuf; /* SDU to be compressed */
811 U32 macI; /* MAC-I to be verified with */
812 Status *status; /* Integrity verification status */
819 Void *cxtId; /* Context Identifier */
824 cxtId = pjRbCb->ueCb->secInfo.intCxtId;
826 ulUeCb = pjRbCb->ueCb;
827 libTrans.pdcpInstance = gCb->init.inst;
828 libTrans.count = secInp.count;
829 libTrans.rbId = pjRbCb->rbId - 1;
830 libTrans.dir = secInp.dir;
831 libTrans.rbType = pjRbCb->rbType;
832 libTrans.intAlgoType = ulUeCb->secInfo.intInfo.algoType;
833 libTrans.ueCb = (PTR)ulUeCb;
834 libTrans.ueId = ulUeCb->key.ueId;
835 libTrans.cellId = ulUeCb->key.cellId;
836 libTrans.key = (U8*)&ulUeCb->secInfo.intInfo.intKey[0];
837 PJ_SEC_FILL_FRESH(libTrans.fresh, libTrans.rbId);
840 libTrans.sessCxtId = ulUeCb->secInfo.cpIntSessCxtId;
841 #ifdef QAT_TWO_INSTANCE
842 libTrans.instHndl = gCb->u.ulCb->instHndl;
844 libTrans.instHndl = gCb->instHndl;
848 /* Start the timer if it is not started already */
849 if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE)
851 pjRbCb->ulCb.obdPdu = secInp.count;
852 pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
854 ret = PjLibObdIntVerReq(&(gCb->pjGenCfg.obdPst.secPst), cxtId,
855 secInp, libTrans, mBuf, macI);
857 #ifdef INTEL_SW_INTEG
858 ret = PjLibObdIntVerReq(gCb, &libTrans, mBuf, macI);
860 ret = PjLibObdIntVerReq(&libTrans, mBuf, macI);
865 } /* end of pjUtlIntVerReq */
868 PUBLIC S16 pjUtlIntVerReq
871 PjUlRbCb *pjRbCb, /* PDCP RbCb */
872 PjSecInp secInp , /* Input parameters for integrity */
873 Buffer *mBuf, /* SDU to be compressed */
874 U32 macI, /* MAC-I to be verified with */
875 Status *status /* Integrity verification status */
878 PUBLIC S16 pjUtlIntVerReq(gCb, pjRbCb, secInp, mBuf, macI, status)
880 PjUlRbCb *pjRbCb; /* PDCP RbCb */
881 PjSecInp secInp; /* Input parameters for integrity */
882 Buffer *mBuf; /* SDU to be compressed */
883 U32 macI; /* MAC-I to be verified with */
884 Status *status; /* Integrity verification status */
889 PjLibTrans libTrans; /* Transaction Id for deciphering */
890 #endif /* PJ_SEC_ASYNC */
891 PTR cxtId; /* Context Identifier */
895 cxtId = (PTR)pjRbCb->ueCb->secInfo.intCxtId;
898 /* Assign transId and cxtId */
899 libTrans.count = secInp.count;
900 libTrans.rbId = pjRbCb->rbId - 1;
901 libTrans.rbType = pjRbCb->rbType;
902 libTrans.ueCb = pjRbCb->ueCb;
904 /* Start the timer if it is not started already */
905 if((pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE)
907 pjRbCb->ulCb.obdPdu = secInp.count;
908 pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
911 ret = PjLibObdIntVerReq(&gCb->pjGenCfg.obdPst.secPst, cxtId,
912 secInp, libTrans, mBuf, macI);
915 ret = pjLibIntVerReq(cxtId, secInp, mBuf, macI, status);
920 } /* end of pjUtlIntVerReq */
930 * Utility function that processes the CfgReq with type as
931 * REESTABLISH sent from RRC.
936 * 1. Marks the state of the RBs as PJ_STATE_REEST.
937 * 2. Calculates the number of RBs undergoing reestablishment.
939 * @param[in] ueCb UE Control Block Pointer.
940 * @param[in] numEnt Number of entities undergoing reestablishment
941 * @param[in] cfgEnt List of entities configured.
949 PUBLIC S16 pjUtlUlReEstSrb1
952 PjUlRbCb *pjRbCb /* PDCP Control Block Pointer */
955 PUBLIC S16 pjUtlUlReEstSrb1(pjRbCb)
957 PjUlRbCb *pjRbCb; /* PDCP Control Block Pointer */
964 RLOG2(L_DEBUG, "pjUtlReEstSrb1(pjRbCb(%d,%d))",
965 pjRbCb->rbId, pjRbCb->rbType);
969 ueCb->libInfo.state = PJ_STATE_REEST;
971 /* SRB Reconfiguration we can update the control Plane keys and
972 the Integrity Keys in the OBD module */
974 pjUtlUlUpdCpSecKeys(gCb,ueCb);
976 /* Perform uplink reestablishment of SRB1 */
977 pjUlmReEstSrb(gCb,pjRbCb);
979 /* Start security reconfiguration if SRB1 is the only RB */
980 if ((ueCb->numSrbs == 1) && (ueCb->numDrbs == 0))
982 pjUtlUlUpdUpSecKeys(gCb,ueCb);
986 } /* pjUtlReEstSrb1 */
992 * Handler to start reestablishment processing
997 * 1. Marks the state of the RBs as PJ_STATE_REEST_HO.
998 * 2. Calculates the number of RBs undergoing reestablishment.
1000 * @param[in] ueCb Number of RBs undergoing reestablishment
1008 PUBLIC S16 pjUtlUlReEstHO
1011 PjUlUeCb *ueCb /* Number of RBs undergoing reestablishment*/
1014 PUBLIC S16 pjUtlUlReEstHO(gCb,ueCb)
1016 PjUlUeCb *ueCb; /* Number of RBs undergoing reestablishment*/
1023 TRC2(pjUtlUlReEstHO);
1026 RLOG2(L_DEBUG, "pjUtlReEstHOStart(ueCb(%d,%d)))",
1027 ueCb->key.ueId, ueCb->key.cellId);
1029 RLOG2(L_DEBUG, "pjUtlReEstHOStart(ueCb(%d,%d))",
1030 ueCb->key.ueId, ueCb->key.cellId);
1033 /* Perform initialisations on the HO Info structure */
1034 PJ_ALLOC(gCb,ueCb->hoInfo, sizeof(PjUlHoInfo));
1035 #if (ERRCLASS & ERRCLS_ADD_RES)
1036 if (ueCb->hoInfo == NULLP)
1038 RLOG0(L_FATAL, "Memory Allocation failed.");
1041 #endif /* ERRCLASS & ERRCLS_ADD_RES */
1042 PJ_ALLOC(gCb,ueCb->hoInfo->hoCfmInfo,
1043 sizeof(PjUlHoCfmInfo) * PJ_MAX_DRB_PER_UE );
1045 #if (ERRCLASS & ERRCLS_ADD_RES)
1046 if (ueCb->hoInfo->hoCfmInfo == NULLP )
1048 RLOG0(L_FATAL, "Memory Allocation failed.");
1050 PJ_PST_FREE(gCb->u.ulCb->cpjSap.pst.region, gCb->u.ulCb->cpjSap.pst.pool, ueCb->hoInfo, sizeof(PjUlHoInfo));
1053 #endif /* ERRCLASS & ERRCLS_ADD_RES */
1055 /* Initialise the reestablishment states for the RBs */
1056 rbCbLst = ueCb->drbCb;
1057 for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt ++)
1059 /* Check of rbCb available */
1060 if( (pjRbCb = rbCbLst[rbCnt]) == NULLP)
1064 /* Fetch the rbCb and intialise the states */
1065 pjRbCb->state = PJ_STATE_REEST_HO;
1066 ueCb->libInfo.numReEstDrb++;
1068 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
1069 pjRbCb->ulCb.obdCnt = 0;
1070 pjRbCb->ulCb.transCmp = 0;
1071 if(pjRbCb->mode == PJ_DRB_AM)
1073 pjRbCb->ulCb.firstReEstCnt = pjRbCb->ulCb.rxDeliv;
1075 #endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
1081 } /* pjUtlReEstHOStart */
1087 * Handler to apply the new security algorithms and
1088 * reset the compression unit.
1093 * 1. Creates new contexts for Control Plane Ciphering and Integrity.
1094 * 2. Closes the old contexts for Control Plane Ciphering and Integrity.
1096 * @param[in] ueCb UE Control Block
1104 PUBLIC S16 pjUtlUlUpdUpSecKeys
1107 PjUlUeCb *ueCb /* UE Control Block */
1110 PUBLIC S16 pjUtlUlUpdUpSecKeys(gCb,ueCb)
1112 PjUlUeCb *ueCb; /* UE Control Block */
1117 TRC2(pjUtlUlUpdUpSecKeys);
1119 RLOG2(L_DEBUG, "pjUtlUlUpdUpSecKeys(ueCb(%d,%d))",
1120 ueCb->key.ueId, ueCb->key.cellId);
1122 if(ueCb->secInfo.secAct == TRUE)
1124 /* Initialisation is done first followed by closure since we
1125 * do not want the same ctxId to be returned for the new init.
1126 * In ASYNC case, we drop packets if they are returned from a
1127 * different ctxId. */
1130 tmpUpCxt = ueCb->secInfo.upCiphSessCxtId;
1132 tmpUpCxt = ueCb->secInfo.upCxtId;
1134 pjUtlUlUpInit(gCb,ueCb);
1135 pjUtlUlCipherClose(gCb,tmpUpCxt);
1139 } /* pjUtlUlUpdUpSecKeys */
1145 * Handler to apply the new security algorithms and
1146 * reset the compression unit.
1151 * 1. Creates new contexts for Control Plane Ciphering and Integrity.
1152 * 2. Closes the old contexts for Control Plane Ciphering and Integrity.
1154 * @param[in] ueCb UE Control Block
1162 PUBLIC S16 pjUtlUlUpdCpSecKeys
1165 PjUlUeCb *ueCb /* UE Control Block */
1168 PUBLIC S16 pjUtlUlUpdCpSecKeys(gCb,ueCb)
1170 PjDlUeCb *ueCb; /* UE Control Block */
1176 TRC2(pjUtlDlUpdCpSecKeys);
1178 RLOG2(L_DEBUG, "pjUtlUlUpdCpSecKeys(ueCb(%d,%d))",
1179 ueCb->key.ueId, ueCb->key.cellId);
1181 if(ueCb->secInfo.secAct == TRUE)
1183 /* Initialisation is done first followed by closure since we
1184 * do not want the same ctxId to be returned for the new init.
1185 * In ASYNC case, we drop packets if they are returned from a
1186 * different ctxId. */
1188 tmpIntCxt = ueCb->secInfo.cpIntSessCxtId;
1189 tmpCpCxt = ueCb->secInfo.cpCiphSessCxtId;
1192 tmpIntCxt = ueCb->secInfo.intCxtId;
1193 tmpCpCxt = ueCb->secInfo.cpCxtId;
1196 pjUtlUlCpInit(gCb,ueCb);
1197 pjUtlUlIntInit(gCb,ueCb);
1199 pjUtlUlIntClose(gCb,tmpIntCxt);
1200 pjUtlUlCipherClose(gCb,tmpCpCxt);
1204 } /* pjUtlDlUpdCpSecKeys */
1210 * Function to handle the REESTABLISHMENT COMPLETE
1211 * for each uplink RB
1217 * @param[in] ueCb UE Control Block
1225 PUBLIC S16 pjUtlUlHdlRbReEstComplete
1228 PjUlRbCb *pjRbCb /*RB Control Block */
1231 PUBLIC S16 pjUtlUlHdlRbReEstComplete(ueCb, pjRbCb)
1233 PjUlRbCb *pjRbCb; /* RB Control Block */
1238 TRC2(pjUtlUlHdlRbReEstComplete);
1240 RLOG1(L_DEBUG, "pjUtlUlHdlRbReEstComplete(rbCb(%d)",
1243 ueCb = pjRbCb->ueCb;
1244 if (ueCb->libInfo.numReEstDrb == 0)
1246 ueCb->libInfo.numReEstCmp++;
1251 ueCb->libInfo.numReEstDrb--;
1254 if (ueCb->libInfo.numReEstDrb == 0)
1256 if (ueCb->libInfo.state == PJ_STATE_REEST)
1258 /* Since we have received all the packets in uplink
1259 we can update the user keys */
1260 pjUtlUlUpdUpSecKeys(gCb, ueCb);
1265 pjUtlUlSndReEstCfgCfm(gCb,ueCb);
1267 else if (ueCb->libInfo.state == PJ_STATE_REEST_HO)
1269 pjUtlUlSndSduStaCfm(gCb,ueCb);
1274 } /* pjUtlUlHdlRbReEstComplete */
1280 * Function to sent the REESTABLISHMENT COMPPLETE
1286 * 1. Sends a ReEstablishment Confirm for normal reestablishment.
1287 * 2. Sends a SDU status confirm for handover reestablishment.
1289 * @param[in] ueCb UE Control Block
1297 PUBLIC S16 pjUtlUlSndReEstCfgCfm
1300 PjUlUeCb *ueCb /* UE Control Block */
1303 PUBLIC S16 pjUtlUlSndReEstCfgCfm(ueCb)
1305 PjUlUeCb *ueCb; /* UE Control Block */
1308 CpjCfgCfmInfo *cfgCfmInfo;
1310 PjAsyncCfm *asyncCfm = NULLP;
1313 TRC2(pjUtlSndReEstCfgCfm);
1315 RLOG2(L_DEBUG, "pjUtlSndReEstCfgCfm(ueCb(%d,%d))",
1316 ueCb->key.ueId, ueCb->key.cellId);
1318 /* Pick up the confirm info */
1319 for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
1321 if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
1322 (ueCb->libInfo.asyncCfm[txIdx]->cfmType & PJ_CFG_REEST_ASYNC_CFM))
1324 asyncCfm = ueCb->libInfo.asyncCfm[txIdx];
1329 /* its a reestablishment with only srb1 configured */
1330 if(asyncCfm == NULLP)
1334 /* Memory leak fix ccpu00135359 */
1335 cpjSap = &(gCb->u.ulCb->cpjSap);
1336 if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfgCfmInfo,
1337 sizeof (CpjCfgCfmInfo)) != ROK)
1339 RLOG0(L_FATAL, "Memory Allocation failed.");
1343 PJ_FILL_REEST_CFG_CFM_INFO(cfgCfmInfo, asyncCfm);
1344 PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
1346 PjUiCpjCfgCfm(&gCb->u.ulCb->cpjSap.pst, gCb->u.ulCb->cpjSap.suId, cfgCfmInfo);
1349 } /* pjUtlSndReEstCfgCfm */
1352 * @brief Handler to store the confirms while we wait for the init
1353 * confirms from the off-board.
1357 * This function is invoked during security config request,
1358 * reestablishment request and config request if the libraries
1359 * are off-boarded. This stores the entries in a confirm list
1360 * while waiting for the confirm from the offboard.
1369 PUBLIC S16 pjUtlUlSaveCfmInfo
1372 PjUlUeCb *ueCb, /* Pointer to UeCb */
1373 U8 cfmType, /* Confirm type */
1374 Bool startTmr, /* Start Timer */
1375 U8 entity, /* Confirm type */
1376 PTR cfmPtr, /* Pointer to the structure for confirm */
1377 PTR cfgPtr /* Pointer to the structure for request */
1380 PUBLIC S16 pjUtlUlSaveCfmInfo(ueCb, cfmType, startTmr, entity, cfmPtr, cfgPtr)
1382 PjUlUeCb *ueCb; /* Pointer to UeCb */
1383 U8 cfmType; /* Confirm type */
1384 Bool startTmr; /* Start Timer */
1385 U8 entity; /* Confirm type */
1386 PTR cfmPtr; /* Pointer to the structure for confirm */
1387 PTR cfgPtr; /* Pointer to the structure for request */
1390 S16 ret; /* Return value */
1391 CpjSecCfgCfmInfo *secCfm; /* Security confirm */
1392 CpjReEstCfmInfo *reEstCfm; /* Reestablishment confirm */
1393 CpjCfgCfmInfo *cfgCfm; /* Config confirm */
1394 U16 txId; /* Transaction Id */
1395 PjAsyncCfm *tAsyncCfm; /* Pointer to the async Cfm*/
1396 CpjCfgReqInfo *cfgReq; /* Pointer to the config request */
1397 U8 cfmIdx; /* index for loopoing */
1400 TRC3(pjUtlSaveCfmInfo)
1402 RLOG_ARG4(L_DEBUG,DBG_UEID, ueCb->key.ueId,
1403 "pjUtlSaveCfmInfo cellId(%d),cfmType(%d),startTmr(%d),entity(%d))",
1404 ueCb->key.cellId, cfmType, startTmr, entity);
1406 /* Initialisations */
1412 txId = ueCb->libInfo.nxtAvlbTxId;
1414 if(txId == PJ_MAX_ASYNC_CFM)
1416 /* The entire list is full, have to return negative confirms */
1420 /* is entry already present */
1421 if(ueCb->libInfo.asyncCfm[txId] != NULLP)
1426 /* Allocate the structure */
1427 PJ_ALLOC(gCb,ueCb->libInfo.asyncCfm[txId], sizeof(PjAsyncCfm));
1428 if(ueCb->libInfo.asyncCfm[txId]== NULLP)
1430 RLOG0(L_FATAL, "Memory Allocation failed.");
1434 /* Initialise the structure */
1435 tAsyncCfm = ueCb->libInfo.asyncCfm[txId];
1436 tAsyncCfm->libInitBitMask = ueCb->libInfo.tLibInitBitMask;
1437 tAsyncCfm->cmpInitBitMask = ueCb->libInfo.tCmpInitBitMask;
1438 tAsyncCfm->entity = entity;
1439 tAsyncCfm->startTmr = startTmr;
1441 ueCb->libInfo.tLibInitBitMask = 0;
1442 ueCb->libInfo.tCmpInitBitMask = 0;
1444 /* Assign the values */
1445 if(cfmType == PJ_SEC_ASYNC_CFM)
1447 secCfm = (CpjSecCfgCfmInfo *)cfmPtr;
1448 tAsyncCfm->cfmType = cfmType;
1449 tAsyncCfm->ueId = secCfm->ueId;
1450 tAsyncCfm->cellId = secCfm->cellId;
1451 tAsyncCfm->transId = secCfm->transId;
1453 else if(cfmType == PJ_REEST_ASYNC_CFM)
1455 reEstCfm = (CpjReEstCfmInfo *)cfmPtr;
1456 tAsyncCfm->cfmType = cfmType;
1457 tAsyncCfm->ueId = reEstCfm->ueId;
1458 tAsyncCfm->cellId = reEstCfm->cellId;
1459 tAsyncCfm->transId = reEstCfm->transId;
1461 else if((cfmType & PJ_CFG_ASYNC_CFM) ||
1462 (cfmType & PJ_CFG_REEST_ASYNC_CFM)||
1463 (cfmType & PJ_CFG_UEDEL_ASYNC_CFM))
1467 cfgCfm = (CpjCfgCfmInfo *)cfmPtr;
1468 cfgReq = (CpjCfgReqInfo *)cfgPtr;
1470 tAsyncCfm->cfmType = cfmType;
1471 tAsyncCfm->ueId = cfgCfm->ueId;
1472 tAsyncCfm->cellId = cfgCfm->cellId;
1473 tAsyncCfm->transId = cfgCfm->transId;
1474 tAsyncCfm->numEnt = cfgReq->numEnt;
1476 for ( cfmIdx = 0; cfmIdx < cfgReq->numEnt; cfmIdx++ )
1478 tAsyncCfm->cfmEnt[cfmIdx].status = cfgCfm->cfmEnt[cfmIdx].status;
1479 tAsyncCfm->cfmEnt[cfmIdx].reason = cfgCfm->cfmEnt[cfmIdx].reason;
1480 tAsyncCfm->cfmEnt[cfmIdx].rbId = cfgCfm->cfmEnt[cfmIdx].rbId;
1481 tAsyncCfm->cfmEnt[cfmIdx].rbType = cfgCfm->cfmEnt[cfmIdx].rbType;
1482 tAsyncCfm->cfmEnt[cfmIdx].cfgType = cfgReq->cfgEnt[cfmIdx].cfgType;
1485 else if(entity == ENTPJ)
1487 CpjCfgCfmInfo *pjCfgCfm; /* Configuraiton Confirm */
1488 pjCfgCfm = (CpjCfgCfmInfo *)cfmPtr;
1490 tAsyncCfm->cfmType = cfmType;
1491 tAsyncCfm->transId = pjCfgCfm->transId;
1492 tAsyncCfm->ueId = pjCfgCfm->ueId;
1493 tAsyncCfm->cellId = pjCfgCfm->cellId;
1494 tAsyncCfm->numEnt = pjCfgCfm->numEnt;
1496 for ( cfmIdx = 0; cfmIdx < pjCfgCfm->numEnt; cfmIdx++ )
1498 tAsyncCfm->cfmEnt[cfmIdx].status =
1499 pjCfgCfm->cfmEnt[cfmIdx].status;
1500 tAsyncCfm->cfmEnt[cfmIdx].reason =
1501 pjCfgCfm->cfmEnt[cfmIdx].reason;
1502 tAsyncCfm->cfmEnt[cfmIdx].rbId =
1503 pjCfgCfm->cfmEnt[cfmIdx].rbId;
1504 tAsyncCfm->cfmEnt[cfmIdx].rbType =
1505 pjCfgCfm->cfmEnt[cfmIdx].rbType;
1511 /* Timer should not be started when SEC is SYNC for ReEst Req
1512 * and for the subsequent config req for REEST. The config req
1513 * after reest req can still start the timer in the case comp being
1514 * async and sec being sync if it also adds a RB and a compInit has
1518 if(tAsyncCfm->startTmr == TRUE)
1520 if((pjChkTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR)) == FALSE)
1522 pjStartTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR);
1523 ueCb->libInfo.crntTmrTxId = ueCb->libInfo.nxtAvlbTxId;
1527 /* update nxtAvlbTxId to the next empty slot */
1528 for(cfmIdx = 0; cfmIdx < PJ_MAX_ASYNC_CFM; cfmIdx++)
1530 ueCb->libInfo.nxtAvlbTxId =
1531 (U16)((ueCb->libInfo.nxtAvlbTxId + 1) % PJ_MAX_ASYNC_CFM); /*KW_FIX*/
1533 if(ueCb->libInfo.asyncCfm[ueCb->libInfo.nxtAvlbTxId] == NULLP)
1539 /* Cant find an empty slot ? */
1540 if(cfmIdx == PJ_MAX_ASYNC_CFM)
1542 ueCb->libInfo.nxtAvlbTxId = PJ_MAX_ASYNC_CFM;
1546 }/* pjUtlSaveCfmInfo */
1550 * @brief Handler to store update the bitmaks and send confirms if necessary.
1554 * This function is invoked when receiving a InitCfm from Offboard.
1555 * It updates the bit masks and checks if it is necesary to send a
1565 PUBLIC S16 pjUtlUlHdlObdInitCfm
1568 PjUlUeCb *ueCb, /* Pointer to UeCb */
1569 U16 txIdx, /* Transaction Index for UeCb */
1570 U8 cfmType, /* Confirm type */
1571 U8 maskVal /* mask value */
1574 PUBLIC S16 pjUtlUlHdlObdInitCfm(ueCb, txIdx, cfmType, maskVal)
1576 PjUlUeCb *ueCb; /* Pointer to UeCb */
1577 U16 txIdx; /* Transaction Index for UeCb */
1578 U8 cfmType; /* Confirm type */
1579 U8 maskVal; /* mask value */
1582 CpjSecCfgCfmInfo *secCfgCfm; /* Security config confirm */
1583 CpjReEstCfmInfo *reEstCfm; /* Reest config confirm */
1584 PjAsyncCfm *asyncCfm;
1585 CpjCfgCfmInfo *cfgCfm;
1588 TRC3(pjUtlUlHdlObdInitCfm)
1590 RLOG_ARG4(L_DEBUG,DBG_UEID, ueCb->key.ueId,
1591 "pjUtlHdlUlObdInitCfm(ueCb(%d,%d),txIdx(%d),cfmType(%d),maskVal(%d))",
1592 ueCb->key.cellId, txIdx, cfmType, maskVal);
1594 /* Initialisations */
1601 if((txIdx == PJ_MAX_ASYNC_CFM) ||
1602 (ueCb->libInfo.asyncCfm[txIdx] == NULLP))
1607 asyncCfm = ueCb->libInfo.asyncCfm[txIdx];
1609 if(cfmType & PJ_SEC_INIT_CFM)
1611 /* Update bit mask and check if all confirms have been received */
1612 asyncCfm->libInitBitMask ^= (maskVal);
1613 ret = pjUtlUlHdlSecInitCfm(gCb,ueCb,txIdx,asyncCfm,secCfgCfm,reEstCfm);
1615 else if(cfmType & PJ_CMP_INIT_CFM)
1617 /* Check if all confirms have been received */
1618 asyncCfm->cmpInitBitMask &= ~(1 << (maskVal - 1));
1620 /* Update the status and reason for the received CmpInitCfm */
1621 for ( idx = 0; idx < asyncCfm->numEnt; idx++ )
1623 if ( asyncCfm->cfmEnt[idx].rbId == maskVal)
1625 asyncCfm->cfmEnt[idx].status = CPJ_CFG_CFM_OK;
1626 asyncCfm->cfmEnt[idx].reason = CPJ_CFG_REAS_NONE;
1631 ret = pjUtlUlHdlCmpInitCfm(gCb,ueCb,txIdx,asyncCfm,cfgCfm);
1635 }/* pjUtlHdlUlObdInitCfm */
1639 * @brief Handler for init off-board timer expiry.
1643 * This function is called when the off-board timer expires for
1644 * a Init Req of a channel (either for ciphering/integrity/compression).
1645 * This function sends a confirm with failure for SecCfgReq if the
1646 * state of the RB is normal. It sends a confirm with failure
1647 * for config request(only for RBs with Re-establishment Req, a failure
1648 * is stored in the confirm) if the state of the RB is re-establishment.
1650 * @param[in] ueCb UE control block.
1658 PUBLIC S16 pjUtlUlHdlInitObdTmrExp
1664 PUBLIC S16 pjUtlUlHdlInitObdTmrExp(ueCb)
1669 S16 ret; /* Return Value */
1670 CpjSecCfgCfmInfo *secCfgCfm; /* Security Cfg Confirm Info */
1671 CpjCfgCfmInfo *cfgCfm; /* Config Confirm Info */
1672 CpjReEstCfmInfo *reEstCfm; /* Reest config confirm */
1673 CpjCfgCfmInfo *pjCfgCfm;
1674 PjLibInfo *libInfo; /* Off-board Info */
1675 PjAsyncCfm *asyncCfm; /* Async Cfm Info */
1676 PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */
1677 U16 txIdx; /* Tx Idx */
1678 U16 idx; /* Index for looping */
1681 TRC3(pjUtlHdlInitObdTmrExp)
1683 RLOG2(L_DEBUG, "pjUtlHdlInitObdTmrExp(ueCb(%d,%d))",
1684 ueCb->key.ueId, ueCb->key.cellId);
1687 cpjSap = &(gCb->u.ulCb->cpjSap);
1689 libInfo = &ueCb->libInfo;
1690 txIdx = libInfo->crntTmrTxId;
1692 /* Restart the timer */
1693 PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx);
1695 /* Shouldnt happen, nevertheless, check */
1696 if( txIdx >= PJ_MAX_ASYNC_CFM || libInfo->asyncCfm[txIdx] == NULLP)
1701 asyncCfm = libInfo->asyncCfm[txIdx];
1703 /* Security confirm */
1704 if(asyncCfm->cfmType & PJ_SEC_ASYNC_CFM)
1706 PJ_ALLOC(gCb,secCfgCfm, sizeof(CpjSecCfgCfmInfo));
1707 #if (ERRCLASS & ERRCLS_ADD_RES)
1708 if (secCfgCfm == NULLP)
1710 RLOG0(L_FATAL, "Memory Allocation failed.");
1713 #endif /* ERRCLASS & ERRCLS_ADD_RES */
1714 PJ_FILL_SEC_CFM_INFO(secCfgCfm, asyncCfm);
1715 secCfgCfm->status = CPJ_CFG_CFM_NOK;
1716 secCfgCfm->reason = CPJ_CFG_REAS_OBD_TIMEOUT;
1718 PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
1720 PjUiCpjSecCfgCfm(&(cpjSap->pst), cpjSap->suId, secCfgCfm);
1723 /* Configuration confirms */
1724 else if ((asyncCfm->cfmType & PJ_CFG_ASYNC_CFM) ||
1725 (asyncCfm->cfmType & PJ_CFG_REEST_ASYNC_CFM))
1727 PJ_FILL_TIMEOUT_CFG_CFM_INFO(gCb,cfgCfm, asyncCfm);
1729 PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
1731 PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm);
1733 else if (asyncCfm->cfmType & PJ_REEST_ASYNC_CFM)
1736 PJ_ALLOC(gCb,reEstCfm, sizeof(CpjReEstCfmInfo));
1737 #if (ERRCLASS & ERRCLS_ADD_RES)
1738 if (reEstCfm == NULLP)
1740 RLOG0(L_FATAL, "Memory Allocation failed.");
1743 #endif /* ERRCLASS & ERRCLS_ADD_RES */
1744 PJ_FILL_REEST_CFM_INFO(reEstCfm, asyncCfm, LCM_PRIM_NOK);
1746 PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
1748 PjUiCpjReEstCfm(&gCb->u.ulCb->cpjSap.pst,
1749 gCb->u.ulCb->cpjSap.suId, reEstCfm);
1751 /* Send the config confirm also if any exists */
1752 cfgIdx = (U16)(txIdx + 1); /*KW_FIX*/
1754 for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++, cfgIdx++)
1756 cfgIdx %= PJ_MAX_ASYNC_CFM;
1757 if((libInfo->asyncCfm[cfgIdx] != NULLP) &&
1758 (libInfo->asyncCfm[cfgIdx]->cfmType & PJ_CFG_REEST_ASYNC_CFM))
1764 /* This scenario occurs when only SRB1 is configured */
1765 if(idx == PJ_MAX_ASYNC_CFM)
1770 PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, cfgIdx);
1771 asyncCfm = libInfo->asyncCfm[cfgIdx];
1773 PJ_FILL_TIMEOUT_CFG_CFM_INFO(gCb,cfgCfm, asyncCfm);
1775 PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
1777 PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm);
1779 else if(asyncCfm->cfmType & PJ_CFG_UEDEL_ASYNC_CFM)
1781 /* Delete ueCb entry from ueLstCp */
1782 pjStopTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR);
1783 ret = cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb);
1788 RLOG_ARG0(L_DEBUG,DBG_UEID,ueCb->key.ueId,
1789 "pjUtlHdlInitObdTmrExp: cmHashListDelete Failed for ueCb.");
1793 if ( asyncCfm->entity == ENTPJ )
1795 PJ_ALLOC(gCb,cfgCfm, sizeof(CpjCfgCfmInfo));
1796 #if (ERRCLASS & ERRCLS_ADD_RES)
1797 if (cfgCfm == NULLP)
1799 RLOG0(L_FATAL, "Memory Allocation failed.");
1802 #endif /* ERRCLASS & ERRCLS_ADD_RES */
1804 for ( idx = 0; idx < asyncCfm->numEnt; idx++)
1806 cfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status;
1807 cfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason;
1808 cfgCfm->cfmEnt[idx].rbId = asyncCfm->cfmEnt[idx].rbId;
1809 cfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType;
1811 cfgCfm->ueId = asyncCfm->ueId;
1812 cfgCfm->cellId = asyncCfm->cellId;
1813 cfgCfm->transId = asyncCfm->transId;
1814 cfgCfm->numEnt = asyncCfm->numEnt;
1816 /* delete all confirms present there */
1817 for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++)
1819 if(libInfo->asyncCfm[idx] != NULLP)
1821 PJ_FREE(gCb,ueCb->libInfo.asyncCfm[idx], sizeof(PjAsyncCfm));
1822 ueCb->libInfo.asyncCfm[idx] = NULLP;
1826 PJ_FREE(gCb,ueCb, sizeof(PjUlUeCb));
1827 PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm);
1829 else if ( asyncCfm->entity == ENTPJ )
1831 PJ_ALLOC(gCb,pjCfgCfm, sizeof(CpjCfgCfmInfo));
1832 #if (ERRCLASS & ERRCLS_ADD_RES)
1833 if (pjCfgCfm == NULLP)
1835 RLOG0(L_FATAL, "Memory Allocation failed.");
1838 #endif /* ERRCLASS & ERRCLS_ADD_RES */
1839 for ( idx = 0; idx < asyncCfm->numEnt; idx++)
1841 pjCfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status;
1842 pjCfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason;
1843 pjCfgCfm->cfmEnt[idx].rbId = asyncCfm->cfmEnt[idx].rbId;
1844 pjCfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType;
1846 pjCfgCfm->ueId = asyncCfm->ueId;
1847 pjCfgCfm->cellId = asyncCfm->cellId;
1848 pjCfgCfm->transId = asyncCfm->transId;
1849 pjCfgCfm->numEnt = asyncCfm->numEnt;
1851 /* delete all confirms present there */
1852 for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++)
1854 if(libInfo->asyncCfm[idx] != NULLP)
1856 PJ_FREE(gCb,ueCb->libInfo.asyncCfm[idx], sizeof(PjAsyncCfm));
1857 ueCb->libInfo.asyncCfm[idx] = NULLP;
1861 PJ_FREE(gCb,ueCb, sizeof(PjUlUeCb));
1862 PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, pjCfgCfm);
1867 } /* pjHdlUeDelWaitTmrExp */
1874 * Function to sent the REESTABLISHMENT COMPPLETE
1880 * 1. Sends a ReEstablishment Confirm for normal reestablishment.
1881 * 2. Sends a SDU status confirm for handover reestablishment.
1883 * @param[in] ueCb UE Control Block
1891 PUBLIC S16 pjUtlUlSndSduStaCfm
1894 PjUlUeCb *ueCb /* UE Control Block */
1897 PUBLIC S16 pjUtlUlSndSduStaCfm(gCb, ueCb)
1899 PjUlUeCb *ueCb; /* UE Control Block */
1903 CpjSduStaCfmInfo *cfmInfo;
1904 UdxSduStaCfmInfo *udxCfmInfo;
1905 UdxSduStaInfo tempDlStaInfo[PJ_MAX_DRB_PER_UE] = {{0}};
1908 PjUlHoCfmInfo *hoCfmInfo;
1909 CpjSduStaInfo *staInfo;
1912 PjUdxUlSapCb *udxSap;
1915 TRC2(pjUtlUlSndSduStaCfm);
1917 RLOG2(L_DEBUG, "pjUtlUlSndSduStaCfm(ueCb(%d,%d))",
1918 ueCb->key.ueId, ueCb->key.cellId);
1920 cpjSap = &(gCb->u.ulCb->cpjSap);
1921 if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfmInfo,
1922 sizeof (CpjSduStaCfmInfo)) != ROK)
1924 RLOG0(L_FATAL, "Memory Allocation failed.");
1928 cfmInfo->ueId = ueCb->key.ueId;
1929 cfmInfo->cellId = ueCb->key.cellId;
1930 cfmInfo->transId = ueCb->hoInfo->transId;
1931 cfmInfo->reason = CPJ_CFG_REAS_NONE;
1932 udxCfmInfo = ueCb->hoInfo->staCfm;
1934 for(rbCnt = 0; rbCnt < udxCfmInfo->numRb; rbCnt++)
1937 - Check for rbId and copy the info to index=(rbId)
1939 rbId = udxCfmInfo->sduStaInfo[rbCnt].rbId;
1940 if(udxCfmInfo->sduStaInfo[rbCnt].dlSduStaInfo.hoPres == TRUE)
1942 tempDlStaInfo[rbId].rbId = udxCfmInfo->sduStaInfo[rbCnt].rbId;
1943 tempDlStaInfo[rbId].dir = udxCfmInfo->sduStaInfo[rbCnt].dir;
1944 tempDlStaInfo[rbId].dlSduStaInfo.count = udxCfmInfo->sduStaInfo[rbCnt].dlSduStaInfo.count;
1945 tempDlStaInfo[rbId].dlSduStaInfo.hoPres = TRUE;
1950 ((rbCnt < PJ_MAX_DRB_PER_UE) && (numRb < CPJ_MAX_DRB)); rbCnt++)
1953 hoCfmInfo = &ueCb->hoInfo->hoCfmInfo[rbCnt];
1954 staInfo = &cfmInfo->sduStaInfo[numRb];
1955 memset((void *)staInfo,0,sizeof(CpjSduStaInfo));
1956 if(hoCfmInfo->pres == TRUE)
1959 staInfo->rbId = hoCfmInfo->rbId;
1960 staInfo->dir |= hoCfmInfo->dir;
1961 staInfo->snLen = ueCb->drbCb[hoCfmInfo->rbId]->snLen;
1962 staInfo->ulSduStaInfo.numBits = hoCfmInfo->numBits;
1963 if (hoCfmInfo->numBits > 0)
1965 /* numBits is always filled as multiple's of 8 */
1966 cpjSap = &(gCb->u.ulCb->cpjSap);
1967 if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,
1968 (Data **)&staInfo->ulSduStaInfo.ulBitMap,
1969 sizeof (U8) * (hoCfmInfo->numBits / 8)) != ROK)
1971 RLOG0(L_FATAL, "Memory Allocation failed.");
1974 PJ_MEM_CPY(staInfo->ulSduStaInfo.ulBitMap, hoCfmInfo->ulBitMap, (hoCfmInfo->numBits / 8));
1975 PJ_FREE(gCb, hoCfmInfo->ulBitMap, sizeof(U8) * (hoCfmInfo->numBits / 8));
1977 staInfo->ulSduStaInfo.count = hoCfmInfo->count;
1979 if(tempDlStaInfo[rbCnt].dlSduStaInfo.hoPres == TRUE)
1982 staInfo->rbId = tempDlStaInfo[rbCnt].rbId;
1983 staInfo->dir |= tempDlStaInfo[rbCnt].dir;
1984 staInfo->snLen = ueCb->drbCb[staInfo->rbId]->snLen;
1985 staInfo->dlSduStaInfo.count = tempDlStaInfo[rbCnt].dlSduStaInfo.count;
1997 cfmInfo->numRb = numRb;
1998 cfmInfo->status = ROK;
1999 cfmInfo->reason = CPJ_CFG_REAS_NONE;
2000 PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo,
2001 (PJ_MAX_DRB_PER_UE * sizeof(PjUlHoCfmInfo)));
2002 /* Memory leak fix ccpu00135359 */
2003 udxSap = PJ_GET_UL_UDX_SAP(gCb);
2004 PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool,ueCb->hoInfo->staCfm,
2005 sizeof (UdxSduStaCfmInfo));
2006 PJ_FREE(gCb,ueCb->hoInfo, sizeof(PjUlHoInfo));
2008 PjUiCpjSduStaCfm(&gCb->u.ulCb->cpjSap.pst,
2009 gCb->u.ulCb->cpjSap.suId, cfmInfo);
2012 } /* pjUtlSndSduStaCfm */
2016 * @brief Handler to clean up all the PDCP Control Blocks.
2020 * This function is invoked by LMM to shutdown the
2021 * layer. This cleans up recBuf and txBuf of all the
2022 * PDCP RBs in all the UEs.
2031 PUBLIC S16 pjUtlUlShutdown
2036 PUBLIC S16 pjUtlUlShutdown()
2040 S16 ret; /* Return Value */
2041 PjUlUeCb *ueCb; /* UE Control Block */
2042 PjUlUeCb *prevUeCb; /* Previos UE Control Block */
2043 PjUlRbCb *rbCb; /* RB Control Block */
2044 PjUlRbCb **rbCbLst; /* RB Control Block List */
2045 PjSec *secInfo; /* Security info of UE */
2046 U8 idx; /* Index for RBs */
2047 #ifdef LTE_L2_MEAS_COMMENT
2048 PjL2MeasEvtCb *measEvtCb = NULLP;
2052 RLOG0(L_DEBUG, "pjUtlShutdown()");
2061 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
2062 while (cmHashListGetNext(&(gCb->u.ulCb->ueLstCp), (PTR) prevUeCb, (PTR *)&ueCb) == ROK)
2064 if ( ueCb != NULLP )
2066 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
2067 if (ueCb->libInfo.obdTmr.tmrEvnt == PJ_EVT_OBD_TMR)
2069 pjStopTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_TMR);
2072 rbCbLst = ueCb->srbCb;
2073 for (idx = 0; idx < PJ_MAX_SRB_PER_UE; idx++)
2075 rbCb = rbCbLst[idx];
2078 /* Free the Buffers of RbCb */
2079 pjUtlUlFreeRb(gCb,rbCb);
2082 rbCbLst = ueCb->drbCb;
2083 for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++)
2085 rbCb = rbCbLst[idx];
2088 pjUtlUlFreeRb(gCb,rbCb);
2091 /* Close all the context info for offboarding */
2092 secInfo = &(ueCb->secInfo);
2094 pjUtlUlIntClose(gCb,ueCb->secInfo.cpIntSessCxtId);
2095 pjUtlUlCipherClose(gCb,ueCb->secInfo.cpCiphSessCxtId);
2096 pjUtlUlCipherClose(gCb,ueCb->secInfo.upCiphSessCxtId);
2098 pjUtlUlCipherClose(gCb,secInfo->cpCxtId);
2099 pjUtlUlCipherClose(gCb,secInfo->upCxtId);
2100 pjUtlUlIntClose(gCb,secInfo->intCxtId);
2102 /* Delete hoInfo if present */
2103 if (ueCb->hoInfo != NULLP)
2105 for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++)
2107 if (ueCb->hoInfo->hoCfmInfo[idx].pres == TRUE)
2109 PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo[idx].ulBitMap,
2110 (ueCb->hoInfo->hoCfmInfo[idx].numBits % 8)?
2111 ((ueCb->hoInfo->hoCfmInfo[idx].numBits / 8) + 1):
2112 (ueCb->hoInfo->hoCfmInfo[idx].numBits / 8 ));
2116 PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo, \
2117 (PJ_MAX_DRB_PER_UE * sizeof(PjUlHoCfmInfo)));
2118 PJ_FREE(gCb,ueCb->hoInfo, sizeof(PjUlHoInfo));
2123 #ifdef LTE_L2_MEAS_COMMENT
2124 for(idx = 0; idx < PJ_MAX_L2MEAS_EVT; idx++)
2126 if(pjCb.pjL2Cb.pjMeasEvtCb[idx] != NULLP)
2128 measEvtCb = pjCb.pjL2Cb.pjMeasEvtCb[idx];
2129 pjStopTmr(gCb,(PTR)measEvtCb, PJ_EVT_L2_TMR);
2130 gCb.pjL2Cb.pjNumMeas--;
2131 PJ_FREE(gCb,measEvtCb, sizeof(PjL2MeasEvtCb));
2132 pjCb.pjL2Cb.pjMeasEvtCb[idx] = NULLP;
2136 ret = pjDbmUlDeInit(gCb);
2137 #if (ERRCLASS & ERRCLS_DEBUG)
2140 RLOG0(L_FATAL, "PDCP UL DeInitialization Failed.\n");
2142 #endif /* ERRCLASS & ERRCLS_DEBUG */
2150 * Handler to free a PDCP Control Block.
2154 * This function frees the txBuf and rxBuf in a PDCP control block.
2155 * and closes the compression channel opened. It stops the timers
2156 * of this control block if they are running.
2158 * @param[in] pst Post structure
2159 * @param[in] secCxt Context for Integrity protection/verification
2160 * @param[in] ctxId Integrity Context Id
2169 PUBLIC Void pjUtlUlFreeRb
2175 PUBLIC Void pjUtlUlFreeRb(pjRbCb)
2182 RLOG0(L_DEBUG, "pjUtlFreeRb()");
2184 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
2185 if (pjRbCb->ulCb.obdTmr.tmrEvnt == PJ_EVT_UL_OBD_TMR)
2187 pjStopTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
2190 pjDbmRxDeInit(gCb,&(pjRbCb->ulCb.recBuf));
2192 pjUtlCmpClose(gCb,pjRbCb->cmpCxtId);
2193 /*pj004.201 Adding of Missing Trace in LTE RLC PDCP*/
2197 /* pj005.201 added function to send data forward indication message */
2202 * Handler to send Data Fwd Indication
2205 * This function sends Data Fwd Indication message to PDCP user
2207 * @param[in] pjRbCb PDCP RbCb
2208 * @param[in] datFwdInd Data forward indication
2217 PUBLIC S16 pjUtlUlSndDatFwdInd
2221 PjuDatFwdIndInfo *datFwdInd
2224 PUBLIC S16 pjUtlUlSndDatFwdInd(pjRbCb, datFwdInd)
2227 PjuDatFwdIndInfo *datFwdInd;
2230 CmLtePdcpId *pdcpId;
2232 CmLtePdcpId pdcpIdTmp;
2234 TRC3(pjUtlUlSndDatFwdInd)
2236 RLOG0(L_DEBUG, "pjUtlSndDatFwdInd()");
2238 pjuSap = &(gCb->u.ulCb->pjuSap[PJ_DRB_SAP]);
2239 pdcpId = &pdcpIdTmp;
2243 pdcpId->ueId = pjRbCb->ueCb->key.ueId;
2244 pdcpId->cellId = pjRbCb->ueCb->key.cellId;
2245 pdcpId->rbId = pjRbCb->rbId;
2246 pdcpId->rbType = pjRbCb->rbType;
2248 gCb->pjGenSts.numPktsFrwd += datFwdInd->numSdus;
2249 /* If trace flag is enabled send the trace indication */
2250 if(gCb->init.trc == TRUE)
2252 /* Populate the trace params */
2253 pjLmmSendTrc(gCb,EVTPJUDATFWDIND, NULLP);
2255 PjUiPjuDatFwdInd(&(pjuSap->pst), pjuSap->suId, pdcpId, datFwdInd);
2260 }/* end of pjUtlSndDatFwdInd */
2266 * Handler to send Data Fwd Indication
2269 * This function sends Data Fwd Indication message to PDCP user
2271 * @param[in] pjRbCb PDCP RbCb
2272 * @param[in] datFwdInd Data forward indication
2281 PUBLIC S16 pjUtlUlSndUlStaRep
2288 PUBLIC S16 pjUtlUlSndUlStaRep(pjRbCb, sta)
2294 PjUdxUlSapCb *udxSap;
2295 UdxUlStaRepInfo *staRep;
2296 S16 ret = ROK; /* Return Value */
2298 udxSap = PJ_GET_UL_UDX_SAP(gCb);
2300 TRC3(pjUtlUlSndUlStaRep)
2302 RLOG0(L_DEBUG, "pjUtlUlSndUlStaRep()");
2304 PJ_ALLOC_BUF_SHRABL(udxSap->pst, staRep,
2305 sizeof (UdxUlStaRepInfo), ret);
2314 staRep->pdcpId.ueId = pjRbCb->ueCb->key.ueId;
2315 staRep->pdcpId.cellId = pjRbCb->ueCb->key.cellId;
2316 staRep->pdcpId.rbId = pjRbCb->rbId;
2317 staRep->pdcpId.rbType = pjRbCb->rbType;
2320 PjUlUdxUlStaRep(&(udxSap->pst), udxSap->spId, staRep);
2328 }/* end of pjUtlSndDatFwdInd */
2335 * Handler to send Feedback packet to DL-PDCP
2338 * This function sends Feedback packet to DL-PDCP
2340 * @param[in] pjCb PDCP global control block
2341 * @param[in] pjRbCb PDCP RbCb
2342 * @param[in] fbPkt Feedback packet
2351 PUBLIC S16 pjUtlUlSndUlRohcFdbk
2358 PUBLIC S16 pjUtlUlSndUlRohcFdbk(gCb, pjRbCb, fbPkt)
2364 PjUdxUlSapCb *udxSap;
2365 UdxUlFdbkPktInfo *fdbkPktInfo;
2368 udxSap = PJ_GET_UL_UDX_SAP(gCb);
2370 TRC3(pjUtlUlSndUlRohcFdbk)
2372 RLOG0(L_DEBUG, "pjUtlUlSndUlRohcFdbk()");
2374 PJ_ALLOC_BUF_SHRABL(udxSap->pst, fdbkPktInfo,
2375 sizeof (UdxUlFdbkPktInfo), ret);
2381 if(fdbkPktInfo != NULLP)
2383 fdbkPktInfo->pdcpId.ueId = pjRbCb->ueCb->key.ueId;
2384 fdbkPktInfo->pdcpId.cellId = pjRbCb->ueCb->key.cellId;
2385 fdbkPktInfo->pdcpId.rbId = pjRbCb->rbId;
2386 fdbkPktInfo->pdcpId.rbType = pjRbCb->rbType;
2387 fdbkPktInfo->fbPkt = fbPkt;
2389 PjUlUdxUlFdbkPktInfo(&(udxSap->pst), udxSap->spId, fdbkPktInfo);
2397 }/* end of pjUtlUlSndUlRohcFdbk */
2399 /* pj005.201 added support for L2 Measurement */
2403 * @brief Function to initialise measurement
2407 * @param[in] gCb PDCP Instance Control Block
2412 S16 pjUtlL2MeasUlInit(PjCb *gCb)
2416 gCb->u.ulCb->pjL2Cb.pjNumMeas=0;
2417 for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++)
2419 cmMemset((U8 *)&(gCb->u.ulCb->pjL2Cb.pjL2EvtCb[cntr]), 0, sizeof(PjL2MeasEvtCb));
2421 gCb->u.ulCb->pjL2Cb.pjL2EvtCb[PJ_L2MEAS_UL_LOSS].measCb.measType = LPJ_L2MEAS_UL_LOSS;
2422 gCb->u.ulCb->pjL2Cb.pjL2EvtCb[PJ_L2CPU_PERCORE_STATS].measCb.measType = LPJ_L2CPU_PERCORE_STATS;
2423 gCb->u.ulCb->pjL2Cb.pjL2EvtCb[PJ_L2MEM_PERPOOL_STATS].measCb.measType = LPJ_L2MEM_PERPOOL_STATS;
2424 /* initialize the timer value for memory and CPU utilization */
2425 gCb->u.ulCb->pjL2Cb.measTmrCfg.enb = TRUE;
2426 gCb->u.ulCb->pjL2Cb.measTmrCfg.val = CM_MEM_CPU_UITL_INFO_TMR_VAL;
2427 cmInitTimers(&gCb->u.ulCb->pjL2Cb.measTmr,PJ_L2_MAX_TIMERS);
2433 * @brief Handler for resetting the DL measurement counters
2438 * @param[in] measCb Measurement Control Block.
2445 PUBLIC Void pjUtlResetUlL2MeasCntr
2452 PUBLIC Void pjUtlResetUlL2MeasCntr(tPjCb, measCb, measType)
2458 if (measCb->measType & LPJ_L2MEAS_UL_LOSS)
2461 for(qciIdx = 1; qciIdx < LPJ_MAX_QCI; qciIdx++)
2463 U8 qci = measCb->qci[qciIdx];
2465 measCb->measData[qci].ulLoss.val = 0;
2466 measCb->measData[qci].ulLoss.numPkts = 0;
2467 tPjCb->u.ulCb->pjL2Cb.measOn[qci] &= ~LPJ_L2MEAS_UL_LOSS;
2470 if (measCb->measType & LPJ_L2MEM_PERPOOL_STATS)
2472 tPjCb->u.ulCb->pjL2Cb.memUtilizationMask = 0;
2473 /* Clear Memory Statistics */
2474 cmClearMemUtilizationCounter(&(measCb->memInfo));
2476 if(measCb->measType & LPJ_L2CPU_PERCORE_STATS )
2478 tPjCb->u.ulCb->pjL2Cb.cpuUtilizationMask = 0;
2486 * @brief Handler for Sending Negative confirm .
2490 * This function is called when the l2 measurement cannot be started
2491 * This function sends negative confirm for all the requests
2493 * @param[in] measReqEvt Measurement Req Structure
2501 PUBLIC S16 pjUtlSndUlL2MeasNCfm
2504 PjL2MeasCfmEvt *measCfmEvt
2507 PUBLIC S16 pjUtlSndUlL2MeasNCfm(gCb, measCfmEvt)
2509 PjL2MeasCfmEvt *measCfmEvt;
2513 TRC3(pjUtlSndL2MeasNCfm)
2515 PjMiLpjL2MeasCfm(&gCb->pjGenCfg.lmPst, measCfmEvt);
2518 } /* pjUtlSndL2MeasNCfm */
2522 * @brief Handler for storing address of MeasData in rbCb at right index
2526 * Handler for storing address of MeasData in rbCb at right index.
2537 PUBLIC Void pjUtlPlcMeasDatInUlL2Sts
2540 PjL2MeasRbCb *rbL2Cb,
2544 PUBLIC Void pjUtlPlcMeasDatInUlL2Sts(measData, rbL2Cb, measType)
2546 PjL2MeasRbCb *rbL2Cb;
2550 TRC3(pjUtlPlcMeasDatInUlL2Sts)
2552 /* We should check the number of measType in the request. This can be done
2553 * by looking at each bit in the measType. Also store the measData in the
2554 * correct index of l2Sts in RbCb.
2557 if(measType & LPJ_L2MEAS_UL_LOSS)
2559 rbL2Cb->l2Sts[PJ_L2MEAS_UL_LOSS] = measData;
2562 }/* End of pjUtlPlcMeasDatInUlL2Sts */
2563 #endif /* LTE_L2_MEAS */
2568 This function processes Data Resume request received from the Application.
2569 * @param[in] gCb PDCP Instance Control block
2570 * @param[in] ueCb Uplink UeCb
2573 * -# Failure : RFAILED
2576 PUBLIC S16 pjUtlUlPrcsDatResume
2579 CpjDatResumeReqInfo *datResReq
2582 PUBLIC S16 pjUtlUlPrcsDatResume(gCb, datResReq)
2584 CpjDatResumeReqInfo *datResReq;
2588 PjUlRbCb *pjRbCb = NULLP;
2589 PjUlUeCb *ueCb= NULLP;
2591 pjDbmFetchUlUeCb(gCb, datResReq->ueId, datResReq->cellId, &ueCb);
2594 RLOG_ARG1(L_ERROR, DBG_CELLID, datResReq->cellId,"UeId[%u] not found",
2599 for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt ++)
2601 /* Check of rbCb available */
2602 if( (pjRbCb = ueCb->drbCb[rbCnt]) == NULLP)
2607 pjRbCb->ulCb.nxtSubSn = (pjRbCb->ulCb.rxNext % (1 << pjRbCb->snLen));
2610 /* Process the packets in dlPktQ */
2611 pjUlmProcessUlPktQ(gCb, pjRbCb);
2612 pjRbCb->state = PJ_STATE_NORMAL;
2614 ueCb->libInfo.state = PJ_STATE_NORMAL;
2618 PUBLIC Void pjUtlEmptyUlPktList(PjCb *gCb, PjUlRbCb *pjRbCb)
2621 CmLListCp *ulPktLst = &pjRbCb->ulCb.ulPktLst;
2622 while(ulPktLst->first)
2624 ulPkt = (PjUlPkt *)(ulPktLst->first->node);
2625 cmLListDelFrm(ulPktLst, ulPktLst->first);
2626 PJ_FREE_BUF(ulPkt->pdu);
2627 PJ_FREE(gCb, ulPkt, sizeof(PjUlPkt));
2632 void dumpPDCPUlRbInformation(PjUlRbCb* ulRbCb, U16 ueId)
2634 PjUlCb* ulCb = &ulRbCb->ulCb;
2637 RTLIN_DUMP_DEBUG("UE [%u] PDCP UL RB numEntries = %lu\n",ueId, ulCb->recBuf.numEntries);
2639 RTLIN_DUMP_DEBUG("UE [%u] PDCP UL RB numEntries = %u\n",ueId, ulCb->recBuf.numEntries);
2644 void DumpPDCPUlDebugInformation(void)
2646 PjCb* ulInst = pjCb[0]; /* TODO: check whether UL is 0 or 1 */
2648 PjUlgCb* ulgCb = ulInst->u.ulCb;
2650 PjUlUeCb *ueCb = NULLP;
2651 RTLIN_DUMP_DEBUG("PDCP UL Information\n");
2652 RTLIN_DUMP_DEBUG("===================\n");
2654 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
2655 while (ROK == cmHashListGetNext(&ulgCb->ueLstCp,
2660 for(i = 0; i < PJ_MAX_SRB_PER_UE; i++)
2662 PjUlRbCb* rbCb = ueCb->srbCb[i];
2665 dumpPDCPUlRbInformation(rbCb, ueCb->key.ueId);
2668 for(i = 0; i < PJ_MAX_DRB_PER_UE; i++)
2670 PjUlRbCb* rbCb = ueCb->drbCb[i];
2673 dumpPDCPUlRbInformation(rbCb, ueCb->key.ueId);
2679 #ifdef TENB_DPDK_BUF
2682 PUBLIC S16 pjUpdRxEntBuf
2687 PUBLIC S16 pjUpdRxEntBuf(rxEnt)
2694 #define PDCP_NW_OFFSET 8
2702 #endif /* TENB_DPDK_BUF */
2704 PRIVATE S16 pjUtlUlHdlSecInitCfm
2706 PjCb *gCb, /* Pointer to PJ DL Control Block */
2707 PjUlUeCb *ueCb, /* Pointer to UeCb */
2708 U16 txIdx, /* Transaction Index for UeCb */
2709 PjAsyncCfm *asyncCfm, /* Async Confirm */
2710 CpjSecCfgCfmInfo *secCfgCfm, /* Security config confirm */
2711 CpjReEstCfmInfo *reEstCfm /* Reest config confirm */
2714 PRIVATE S16 pjUtlUlHdlSecInitCfm(gCb,ueCb,txIdx, asyncCfm,secCfgCfm,reEstCfm)
2716 PjCb *gCb; /* Pointer to PJ DL Control Block */
2717 PjUlUeCb *ueCb; /* Pointer to UeCb */
2718 U16 txIdx; /* Transaction Index for UeCb */
2719 PjAsyncCfm *asyncCfm; /* Async Confirm */
2720 CpjSecCfgCfmInfo *secCfgCfm; /* Security config confirm */
2721 CpjReEstCfmInfo *reEstCfm; /* Reest config confirm */
2725 TRC3(pjUtlUlHdlSecInitCfm)
2727 if(asyncCfm->libInitBitMask == 0)
2729 PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx);
2730 if(ueCb->libInfo.state == PJ_STATE_NORMAL)
2732 /* Send security config confirm */
2733 PJ_ALLOC(gCb,secCfgCfm, sizeof(CpjSecCfgCfmInfo));
2734 #if (ERRCLASS & ERRCLS_DEBUG)
2735 if (secCfgCfm == NULLP)
2737 RLOG0(L_FATAL, "Memory Allocation failed.");
2740 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
2741 PJ_FILL_SEC_CFM_INFO(secCfgCfm, asyncCfm);
2743 PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
2745 PjUiCpjSecCfgCfm(&gCb->u.ulCb->cpjSap.pst, gCb->u.ulCb->cpjSap.suId, secCfgCfm);
2747 else if(ueCb->libInfo.state == PJ_STATE_REEST)
2750 PJ_ALLOC(gCb,reEstCfm, sizeof(CpjReEstCfmInfo));
2751 #if (ERRCLASS & ERRCLS_DEBUG)
2752 if (reEstCfm == NULLP)
2754 RLOG0(L_FATAL, "Memory Allocation failed.");
2757 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
2759 PJ_FILL_REEST_CFM_INFO(reEstCfm, asyncCfm, LCM_PRIM_OK);
2761 /* Some house keeping work */
2762 PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
2765 /*Change the state from REEST to NORMAL*/
2766 ueCb->libInfo.reEstCfmSent = TRUE;
2768 PjUiCpjReEstCfm(&gCb->u.ulCb->cpjSap.pst, gCb->u.ulCb->cpjSap.suId, reEstCfm);
2777 PRIVATE S16 pjUtlUlHdlCmpInitCfm
2779 PjCb *gCb, /* Pointer to PJ DL Control Block */
2780 PjUlUeCb *ueCb, /* Pointer to UeCb */
2781 U16 txIdx, /* Transaction Index for UeCb */
2782 PjAsyncCfm *asyncCfm, /* Async Confirm */
2783 CpjCfgCfmInfo *cfgCfm /* UDX Config Confirm */
2786 PRIVATE S16 pjUtlUlHdlCmpInitCfm(gCb,ueCb,txIdx,asyncCfm,cfgCfm)
2788 PjCb *gCb; /* Pointer to PJ DL Control Block */
2789 PjUlUeCb *ueCb; /* Pointer to UeCb */
2790 U16 txIdx; /* Transaction Index for UeCb */
2791 PjAsyncCfm *asyncCfm; /* Async Confirm */
2792 CpjCfgCfmInfo *cfgCfm; /* UDX Config Confirm */
2798 TRC3(pjUtlUlHdlCmpInitCfm)
2800 if(asyncCfm->cmpInitBitMask == 0)
2802 asyncCfm->libInitBitMask ^= (PJ_LIB_COMP_BIT_MASK);
2804 if((asyncCfm->libInitBitMask == 0) &&
2805 !(asyncCfm->cfmType & PJ_CFG_REEST_ASYNC_CFM))
2808 /* Send config confirm */
2809 PJ_ALLOC(gCb,cfgCfm, sizeof(CpjCfgCfmInfo));
2810 #if (ERRCLASS & ERRCLS_ADD_RES)
2811 if (cfgCfm == NULLP)
2813 RLOG0(L_FATAL, "Memory Allocation failed.");
2816 #endif /* ERRCLASS & ERRCLS_ADD_RES */
2817 cfgCfm->transId = asyncCfm->transId;
2818 cfgCfm->ueId = asyncCfm->ueId;
2819 cfgCfm->cellId = asyncCfm->cellId;
2820 cfgCfm->numEnt = asyncCfm->numEnt;
2821 for ( idx = 0; idx < asyncCfm->numEnt; idx++ )
2823 cfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status;
2824 cfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason;
2825 cfgCfm->cfmEnt[idx].rbId = asyncCfm->cfmEnt[idx].rbId;
2826 cfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType;
2829 /* Some house keeping work */
2830 PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx);
2831 PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
2833 /* Send confirmtion to the User */
2834 PjUiCpjCfgCfm(&(gCb->u.ulCb->cpjSap.pst), gCb->u.ulCb->cpjSap.suId, cfgCfm);
2841 #endif /* __cplusplus */
2842 /********************************************************************30**
2844 **********************************************************************/