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 /********************************************************************20**
21 Name: RLC service user (PDCP) lower interface
25 Desc: This file Contains the RLC service user lower interface
26 primitive implementain
30 *********************************************************************21*/
32 /* header (.h) include files */
33 #include "envopt.h" /* environment options */
34 #include "envdep.h" /* environment dependent */
35 #include "envind.h" /* environment independent */
37 #include "gen.h" /* general */
38 #include "ssi.h" /* system services */
39 #include "cm5.h" /* common timer defines */
40 #include "cm_tkns.h" /* common tokens defines */
41 #include "cm_mblk.h" /* common memory allocation library defines */
42 #include "cm_llist.h" /* common link list defines */
43 #include "cm_hash.h" /* common hash list defines */
44 #include "cm_lte.h" /* common LTE defines */
45 #include "kwu.h" /* KWU defines */
46 #include "pju.h" /* PJU defines */
47 /*#include "rgu.h"*/ /* RGU defines */
48 #include "cpj.h" /* CPJ defines */
49 #include "lpj.h" /* LPJ defines */
50 #include "pju.h" /* PJU defines */
51 #include "pj_env.h" /* RLC environment options */
52 #include "pj.h" /* RLC defines */
55 #ifdef INTEL_NATIVE_SPACC
56 #include "elpspaccusr.h"
59 /* extern (.x) include files */
60 #include "gen.x" /* general */
61 #include "ssi.x" /* system services */
63 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
66 #include "kwu.h" /* PJU */
71 #include "ss_timer.x" /* System services */
72 #include "ss_msg.h" /* System services */
73 #include "ss_msg.x" /* System services */
74 #include "ss_mem.h" /* System services */
75 #include "ss_mem.x" /* System services */
81 #include "cm5.x" /* common timer library */
82 #include "cm_tkns.x" /* common tokens */
83 #include "cm_mblk.x" /* common memory allocation */
84 #include "cm_llist.x" /* common link list */
85 #include "cm_hash.x" /* common hash list */
86 #include "cm_lte.x" /* common LTE includes */
87 #include "cm_lib.x" /* common memory allocation library */
88 #ifdef TENB_AS_SECURITY
89 #include "mt_plat_t33.h"
90 #include "mt_plat_t33.x"
92 #include "kwu.x" /* KWU */
93 #include "pju.x" /* PJU */
94 /*#include "rgu.x" */ /* RGU */
95 #include "cpj.x" /* CPJ */
96 #include "lpj.x" /* LPJ */
97 #include "pju.x" /* PJU */
99 #include "pj_udx.h" /* LIB */
100 #include "pj_udx.x" /* LIB */
103 #include "pj_ptsec.x"
104 #include "pj_lib.x" /* LIB */
106 #ifdef TENB_AS_SECURITY
107 static const char* RLOG_MODULE_NAME="PDCP";
108 static int RLOG_FILE_ID=293;
109 static int RLOG_MODULE_ID=1024;
112 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
113 extern U32 isMemThreshReached(Region region);
115 #ifdef TENB_AS_SECURITY
116 PUBLIC U32 pjMsSpaccHdlOpenReq(PTR *fd);
117 PUBLIC U32 pjMsSpaccHdlCloseReq(PTR *fd);
118 PUBLIC U32 pjMsSpaccCipherPkt(PjMsSecInfo *pSec, Buffer *mBuf);
119 PUBLIC U32 pjMsSpaccIntegProtPkt(PjLibTrans *libTrans, Buffer **mBuf);
121 PRIVATE S16 pjExtractTxEntRbCbUsingSpaccMappingInfo ARGS ((
122 PjMsSPACCOutputMapInfo *spaccInfo,
130 PRIVATE Void pjMsSpaccProcessDlBatchOutput ARGS ((Void));
131 PRIVATE Void pjMsSpaccProcessUlBatchOutput ARGS((Void));
132 PUBLIC U32 pjMsCheckSpaccQueue(Bool isUl);
133 PUBLIC Void pjSpaccDeInitCiphQ(Void);
134 PUBLIC Void pjSpaccDeInitDeCipherQ(Void);
139 /************************************************************************
140 PJU Interface Matrices
141 ************************************************************************/
143 /****************************************************************************
144 * PJU Interface Mt functions
145 ***************************************************************************/
148 PUBLIC S16 PjLibObdCmpInitReq
155 PUBLIC S16 PjLibObdCmpInitReq(pst, cmpCxt, rohc)
162 TRC3(PjLibObdCmpInitReq)
168 PUBLIC S16 PjLibObdCmpReq
176 PUBLIC S16 PjLibObdCmpReq(pst, cmpCxtId, libTrans, mBuf)
191 PUBLIC S16 PjLibObdDecmpReq
199 PUBLIC S16 PjLibObdDecmpReq(pst, cmpCxtId, libTrans, mBuf)
207 TRC3(PjLibObdDecmpReq)
214 PUBLIC S16 PjLibObdCmpCloseReq
220 PUBLIC S16 PjLibObdCmpCloseReq(pst, cmpCxtId)
226 TRC3(PjLibObdCmpCloseReq)
233 PUBLIC S16 PjLibObdCmpResetReq
239 PUBLIC S16 PjLibObdCmpResetReq(pst, cmpCxtId)
245 TRC3(PjLibObdCmpResetReq)
252 PUBLIC S16 PjLibObdCmpFbReq
260 PUBLIC S16 PjLibObdCmpFbReq(pst, cmpCxtId, libTrans, feedback)
268 TRC3(PjLibObdCmpFbReq)
276 PUBLIC S16 PjLibObdCipherCloseReq
281 PUBLIC S16 PjLibObdCipherCloseReq(cpCxtId)
285 TRC3(PjLibObdCipherCloseReq)
287 #ifdef INTEL_SPACC_IV_OPTIMIZATION
288 pjNSpaccReturnStreamIdToPool(cpCxtId);
295 PUBLIC S16 pjLibCmpInitReq
297 PjCmpCxt cmpCxt, /* Context for ROHC */
298 PjRohc rohc, /* ROHC Config Info */
299 PTR *cmpCxtId /* Compression Context ID */
302 PUBLIC S16 pjLibCmpInitReq(cmpCxt, rohc, cmpCxtId)
303 PjCmpCxt cmpCxt; /* Context for ROHC */
304 PjRohc rohc; /* ROHC Config Info */
305 PTR *cmpCxtId; /* Compression Context ID */
308 TRC3(pjLibCmpInitReq)
312 } /* end of pjLibCmpInitReq */
315 PUBLIC S16 pjLibCmpReq
317 PTR cmpCxtId, /* Context Id for compression */
318 Buffer *mBuf, /* SDU to be compressed */
319 Buffer **opSdu /* Compressed SDU */
322 PUBLIC S16 pjLibCmpReq(cmpCxtId, mBuf, opSdu)
323 PTR cmpCxtId; /* Context Id for compression */
324 Buffer *mBuf; /* SDU to be compressed */
325 Buffer **opSdu; /* Compressed SDU */
332 } /* end of pjLibCmpReq */
335 PUBLIC S16 pjLibDecmpReq
337 PTR cmpCxtId, /* Context Id for compression */
338 Buffer *mBuf, /* SDU to be decompressed */
339 Buffer **feedback, /* Decompressed SDU */
340 Buffer **opSdu /* ROHC feedback buffer */
343 PUBLIC S16 pjLibDecmpReq(cmpCxtId, mBuf, feedback, opSdu)
344 PTR cmpCxtId; /* Context Id for compression */
345 Buffer *mBuf; /* SDU to be decompressed */
346 Buffer **feedback; /* Decompressed SDU */
347 Buffer **opSdu; /* ROHC feedback buffer */
354 } /* end of pjLibDecmpReq */
357 PUBLIC S16 pjLibCmpCloseReq
359 PTR cmpCxtId /* ROHC Context to be closed */
362 PUBLIC S16 pjLibCmpCloseReq(cmpCxtId)
363 PTR cmpCxtId; /* ROHC Context to be closed */
366 TRC3(pjLibCmpCloseReq)
370 } /* end of pjLibCmpCloseReq */
373 PUBLIC S16 pjLibCmpResetReq
375 PTR cmpCxtId /* ROHC Context to be closed */
378 PUBLIC S16 pjLibCmpResetReq(cmpCxtId)
379 PTR cmpCxtId; /* ROHC Context to be closed */
382 TRC3(pjLibCmpResetReq)
386 } /* end of pjLibCmpResetReq */
389 PUBLIC S16 pjLibCmpFbReq
391 PTR cmpCxtId, /* ROHC Context to be closed */
392 Buffer *feedback /* Feed back */
395 PUBLIC S16 pjLibCmpFbReq(cmpCxtId, feedback)
396 PTR cmpCxtId; /* ROHC Context to be closed */
397 Buffer *feedback; /* Feed back */
404 } /* end of pjLibCmpFbReq */
406 #endif /* PJ_CMP_ASYNC */
409 PUBLIC S16 pjLibIntInitReq
411 PjSecCxt secCxt, /* Context for Intg protection/verification */
412 PjIntInfo intInfo, /* Integrity Cfg Info */
413 Void **cxtId /* FD */
416 PUBLIC S16 pjLibIntInitReq(secCxt, intInfo, cxtId)
417 PjSecCxt secCxt; /* Context for Intg protection/verification */
418 PjIntInfo intInfo; /* Integrity Cfg Info */
419 Void **cxtId; /* FD */
424 TRC3(pjLibIntInitReq)
428 } /* end of pjLibIntInitReq */
431 PUBLIC S16 pjLibCpInitReq
433 PjSecCxt secCxt, /* Context for Intg protection/verificatino */
434 U8 algoType, /* Type of the algorithm */
435 U8 *cpKey, /* Control plane ciphering key */
436 Void **cxtId /* FD */
439 PUBLIC S16 pjLibCpInitReq(secCxt, algoType, cpKey, cxtId)
440 PjSecCxt secCxt; /* Context for Intg protection/verificatino */
441 U8 algoType; /* Type of the algorithm */
442 U8 *cpKey; /* Control plane ciphering key */
443 Void **cxtId; /* FD */
452 } /* end of pjLibCpInitReq */
455 PUBLIC S16 pjLibUpInitReq
457 PjSecCxt secCxt, /* Context for Intg protection/verificatino */
458 U8 algoType, /* Type of the algorithm */
459 U8 *upKey, /* User plane ciphering key */
460 Void **cxtId /* FD */
463 PUBLIC S16 pjLibUpInitReq(secCxt, algoType, upKey, cxtId)
464 PjSecCxt secCxt; /* Context for Intg protection/verificatino */
465 U8 algoType; /* Type of the algorithm */
466 U8 *upKey; /* User plane ciphering key */
467 Void **cxtId; /* FD */
472 #ifdef INTEL_SPACC_IV_OPTIMIZATION
473 if(PJ_SEC_DIR_DL == secCxt.dir)
475 pjMsNSpaccIVPrepStreamIdForDl(cxtId);
479 pjMsNSpaccIVPrepStreamIdForUl(cxtId);
484 } /* end of pjLibUpInitReq */
489 PUBLIC S16 PjLibObdCpInitReq
494 PUBLIC S16 PjLibObdCpInitReq(*secInp)
498 TRC3(PjLibObdCpInitReq)
503 PUBLIC S16 PjLibObdUpInitReq
508 PUBLIC S16 PjLibObdUpInitReq(*secInp)
512 TRC3(PjLibObdUpInitReq)
516 #ifdef TENB_AS_SECURITY
520 * @brief Extracting gCb, rbCb, txEnt from SPAcc Mapping Information.
523 * @b Description: This function extracts gCb, rbCb, txEnt from SPAcc mapping
524 * info which is passed as one of the input params.
527 * @param[in] spaccInfo : Information required to map o/p PDU from SPACc to
529 * @param[in] gCb : PDCP Control Block
530 * @param[in] pjRbCb : PDCP rbCb
531 * @param[in] txEnt : PDCP TxEnt
538 PRIVATE S16 pjExtractTxEntRbCbUsingSpaccMappingInfo
540 PjMsSPACCOutputMapInfo *spaccInfo,
546 PRIVATE S16 pjExtractTxEntRbCbUsingSpaccMappingInfo(spaccInfo, gCb, pjRbCb, txEnt)
547 PjMsSPACCOutputMapInfo *spaccInfo;
553 PjDlUeCb *ueCb = NULLP;
555 *gCb = PJ_GET_PJCB(spaccInfo->pdcpInstance);
557 pjDbmFetchDlUeCb(*gCb, spaccInfo->pdcpId.ueId,spaccInfo->pdcpId.cellId, &ueCb);
561 RLOG_ARG0(L_ERROR,DBG_UEID,spaccInfo->pdcpId.ueId,"UECB not found !!!! ");
566 pjDbmFetchPjDlRbCb(ueCb, spaccInfo->pdcpId.rbId, spaccInfo->pdcpId.rbType, pjRbCb);
569 RLOG_ARG2(L_ERROR, DBG_UEID,spaccInfo->pdcpId.ueId,
570 "CellId[%u]:RbId[%d] not found",
571 spaccInfo->pdcpId.cellId, spaccInfo->pdcpId.rbId);
575 *txEnt = (PjTxEnt *)pjDbmGetTxEnt(*gCb, &((*pjRbCb)->dlCb.txBuf),
580 RLOG_ARG0(L_ERROR,DBG_UEID,spaccInfo->pdcpId.ueId,"!!!!rxEnt is NULL!!!!");
590 * @brief Handler for Processing Ciphered PDU's from SPAcc.
593 * @b Description: This function processes and extracts the required control
594 * blocks for the ciphered PDU and calls the function for to be processed
597 * @param[in] spaccOpInfo : Information required to process PDU
598 * @param[in] opSdu : Ciphered buffer
606 PUBLIC S16 pjProcCiphPdu
609 PjMsSPACCOutputMapInfo *spaccOpInfo
612 PUBLIC S16 pjProcCiphPdu(opSdu, spaccOpInfo)
614 PjMsSPACCOutputMapInfo *spaccOpInfo;
619 PjDlRbCb *pjRbCb = NULLP;
620 PjTxEnt *txEnt = NULLP;
622 /* Extract gCb, rbCb and txEnt for further processing */
623 ret = pjExtractTxEntRbCbUsingSpaccMappingInfo(spaccOpInfo, &gCb, &pjRbCb, &txEnt);
627 RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,
628 "pjExtractTxEntRbCbUsingSpaccMappingInfo: returned failure ");
634 if(pjRbCb->rbType == PJ_SRB)
636 if(txEnt->pdu != NULLP)
638 PJ_FREE_BUF(txEnt->pdu);
641 /* In case of Reestablish/HO , dropping the ciphered packets. These packets
642 * are processed again when events EVTCPJDATRESUMEREQ/EVTPJUDATFWDREQ are
643 * received from upper layer */
644 if((pjRbCb->ueCb->libInfo.state != PJ_STATE_NORMAL) && (pjRbCb->rbType != PJ_SRB))
646 RLOG_ARG0(L_INFO,DBG_UEID,spaccOpInfo->pdcpId.ueId,
647 "Dropping the packet in reestablish state ");
653 /* Call to deliver PDU to RLC */
654 ret = pjDlmDeliverPdu(gCb, pjRbCb, txEnt);
658 RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,
659 "pjProcCiphPdu: pjDlmDeliverPdu failed !!!!");
669 * @brief Handler for Ciphering failure
672 * @b Description: This function handles the steps to be taken on failure of
676 * @param[in] procInfo : Information required to process PDU
683 PUBLIC S16 pjHndlCiphFail
685 PjMsSPACCOutputMapInfo *spaccInfo
688 PUBLIC S16 pjHndlCiphFail(spaccInfo)
689 PjMsSPACCOutputMapInfo *spaccInfo;
693 PjDlRbCb *pjRbCb = NULLP;
694 PjTxEnt *txEnt = NULLP;
696 /* Extract gCb, rbCb and txEnt for further processing */
697 if((pjExtractTxEntRbCbUsingSpaccMappingInfo(spaccInfo, &gCb, &pjRbCb, &txEnt)) != ROK)
703 PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count);
704 if ( pjRbCb->dlCb.cfmReqd)
706 PJ_SND_CFM(gCb,pjRbCb, txEnt,
711 pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count);
713 gCb->pjGenSts.numCiphFails++;
718 #ifdef SPACC_THREADED
719 PRIVATE U32 globPollCount = 50;
723 * @brief Handler for SPACC Reset
726 * @b Description: This is triggeres when the processing of batch at SPACC
736 PRIVATE Void pjMsSpaccReset(Void)
738 PRIVATE Void pjMsSpaccReset()
744 PjMsSPACCOutputMapInfo spaccInfo;
746 RLOG0(L_DEBUG,"Restarting SPACC");
747 // PjLibObdDlCloseReq();
749 RLOG0(L_DEBUG,"SPACC Restarted");
753 ret = pjMsSpaccFetchDlPduInfo(&spaccInfo, &opSdu, jobNum, RFAILED);
756 RLOG1(L_ERROR, "NUM DL jobs at failure:%ld",jobNum);
759 pjHndlCiphFail(&spaccInfo);
769 ret = pjMsSpaccFetchUlPduInfo(&spaccInfo, &opSdu, jobNum, RFAILED);
772 RLOG1(L_ERROR,"NUM UL jobs at failure:%ld",jobNum);
775 pjHdlDecipherFailure(&spaccInfo);
781 //RLOG0(L_DEBUG, "pjMsSetQFreeUl done");
782 //RLOG0(L_DEBUG, "Reopening SPACC DL");
783 //pjMsSpaccHdlDlfdOpenReq();
784 // RLOG0(L_DEBUG, "Reopened SPACC DL");
791 * @brief Handler for NRT TTI Indication to PDCP for DL batch processing
794 * @b Description: Triggers batch processing to SPAcc. Fetches the ciphered PDUs
795 * from SPAcc and triggers sending the PDU's RLC.
804 PUBLIC Void PjDlSpaccTrigger(Void)
806 PUBLIC Void PjDlSpaccTrigger()
813 PjMsSPACCOutputMapInfo spaccInfo;
815 #ifdef SPACC_NONBLOCKING
816 static U32 dlPollCount = 0;
819 pollop = pjMsSpaccPollDlQueue();
820 if(PJ_MS_POLL_NOT_REQUIRED == pollop)
822 ret = pjMsSpaccBatchAndCipherPackets();
823 // pjMsSpaccSetResetDlQueueFree(0); /* Set to FALSE */
827 if(PJ_MS_POLL_COMPLETE == pollop)
830 /* Process the o/p from SPAcc */
831 pjMsSpaccProcessDlBatchOutput();
832 // pjMsSpaccSetResetDlQueueFree(1); /* Set to TRUE */
834 /* Send next set of data to SPAcc after processing */
835 ret = pjMsSpaccBatchAndCipherPackets();
836 // pjMsSpaccSetResetDlQueueFree(0); /* Set to FALSE */
840 #ifdef SPACC_THREADED
841 /*Workaround for the SPACC issue of "unexpected job"*/
843 if(dlPollCount >= globPollCount)
845 U32 numUnexpJobs = 0;
847 numUnexpJobs = pjMsCheckUnExpJobs();
848 if(numUnexpJobs != 0)
854 /* Do nothing as SPAcc is not done with processing */
858 /* This condition is executed when SPAcc returns failure for whatever
859 * reason.So once failure is returned, we fetch all the PDU's we had sent
860 * for ciphering and process them as failure */
863 RLOG0(L_ERROR,"Error leg in DL Spacc trigger hit ");
866 ret = pjMsSpaccFetchDlPduInfo(&spaccInfo, &opSdu, jobNum, ret);
871 pjHndlCiphFail(&spaccInfo);
878 ret = pjMsSpaccBatchAndCipherPackets();
880 /* This condition is executed when SPAcc returns failure for whatever
881 * reason.So once failure is returned, we fetch all the PDU's we had sent
882 * for ciphering and process them as failure */
887 ret = pjMsSpaccFetchDlPduInfo(&spaccInfo, &opSdu, jobNum, ret);
892 pjHndlCiphFail(&spaccInfo);
897 pjMsSpaccProcessDlBatchOutput();
906 * @brief Handler for processing of Decipher Failure
909 * @b Description: This function handles decipher failures by deleting the
910 * RxEnt, send STA_IND to upper layer and updation of general statistics.
913 * @param[in] spaccOpInfo : Information required to process PDU
920 PUBLIC S16 pjHdlDecipherFailure
922 PjMsSPACCOutputMapInfo *spaccOpInfo
925 PUBLIC S16 pjHdlDecipherFailure()
926 PjMsSPACCOutputMapInfo *spaccOpInfo;
930 PjUlUeCb *ueCb = NULLP;
931 PjUlRbCb *pjRbCb = NULLP;
932 PjRxEnt *rxEnt = NULLP;
934 gCb = PJ_GET_PJCB(spaccOpInfo->pdcpInstance);
936 pjDbmFetchUlUeCb(gCb,
937 spaccOpInfo->pdcpId.ueId,
938 spaccOpInfo->pdcpId.cellId,
943 RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"UECB not found !!!! ");
947 /* RLOG_ARG4(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,
948 * "At PDCP: : RBTYPE:%d, CELLID:%d, RBID:%d,
949 COUNT:%d", spaccOpInfo->pdcpId.rbType, spaccOpInfo->pdcpId.cellId,
950 spaccOpInfo->pdcpId.rbId, spaccOpInfo->count);*/
951 /* RLOG_ARG2(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,
952 "SNLEN:%d, numjobs %d "spaccOpInfo->pdcpId.ueId, \
953 spaccOpInfo->snLen, numJobs); */
955 pjDbmFetchPjUlRbCb(ueCb, spaccOpInfo->pdcpId.rbId, spaccOpInfo->pdcpId.rbType, &pjRbCb);
958 RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"RBCB not found !!!!");
962 rxEnt = (PjRxEnt *)pjDbmGetRxEnt(gCb,
963 &(pjRbCb->ulCb.recBuf),
968 RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"!!!!rxEnt is NULL!!!!");
972 PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt);
973 pjDbmDelRxEnt(gCb, &(pjRbCb->ulCb.recBuf), rxEnt->count);
974 PJ_STS_INC_GEN_CNT(gCb,numDeciphFails);
981 * @brief Handler for processing deciphered PDU
984 * @b Description: This function processes and sends the ciphered PDU to RLC
987 * @param[in] spaccOpInfo : Information required to process PDU
988 * @param[in] opSdu : Deciphered buffer
997 PUBLIC S16 pjProcDeCipherPdu
999 PjMsSPACCOutputMapInfo *spaccOpInfo,
1003 PUBLIC S16 pjProcDeCipherPdu()
1004 PjMsSPACCOutputMapInfo *spaccOpInfo;
1010 PjUlUeCb *ueCb = NULLP;
1011 PjUlRbCb *pjRbCb = NULLP;
1012 PjRxEnt *rxEnt = NULLP;
1014 gCb = PJ_GET_PJCB(spaccOpInfo->pdcpInstance);
1016 pjDbmFetchUlUeCb(gCb,
1017 spaccOpInfo->pdcpId.ueId,
1018 spaccOpInfo->pdcpId.cellId,
1023 RLOG_ARG0(L_WARNING,DBG_UEID,spaccOpInfo->pdcpId.ueId,"UECB not found !!!! ");
1027 /* RLOG_ARG4(L_ERROR, DBG_UEID,spaccOpInfo->pdcpId.ueId,
1028 "UDAY: At PDCP: : RBTYPE:%d, CELLID:%d, RBID:%d, COUNT:%d",
1029 spaccOpInfo->pdcpId.rbType, spaccOpInfo->pdcpId.cellId,
1030 spaccOpInfo->pdcpId.rbId, spaccOpInfo->count,);*/
1031 /* RLOG_ARG2(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,
1032 " SNLEN:%d, numjobs %d ",spaccOpInfo->snLen, numJobs); */
1034 pjDbmFetchPjUlRbCb(ueCb, spaccOpInfo->pdcpId.rbId, spaccOpInfo->pdcpId.rbType, &pjRbCb);
1037 RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"RBCB not found !!!! ");
1041 rxEnt = (PjRxEnt *)pjDbmGetRxEnt(gCb, &(pjRbCb->ulCb.recBuf),
1042 spaccOpInfo->count);
1044 /* To be used for debugging. Will be removed once verified */
1048 RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"!!!!rxEnt is NULL!!!!");
1052 /*Free the source buffer here*/
1055 PJ_FREE_BUF(rxEnt->mBuf);
1058 rxEnt->mBuf = opSdu;
1061 if(pjRbCb->rbType == PJ_DRB)
1063 rxEnt->state = PJ_RDY_TO_DCOMP;
1064 ret = pjUlmHdlDeCmp(gCb, pjRbCb, rxEnt);
1068 rxEnt->state = PJ_RDY_TO_INTVER;
1069 ret = pjUlmHdlIntVer(gCb, pjRbCb, rxEnt);
1072 if(rxEnt->dupEntry == TRUE)
1074 RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId," 3. Deleting RxEnt");
1075 /* duplicate entry */
1076 PJ_FREE_BUF(rxEnt->mBuf);
1077 PJ_FREE(gCb,rxEnt, sizeof(PjRxEnt));
1079 else if(rxEnt->discFlag == TRUE)
1081 RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"4. Deleting RxEnt");
1082 /* duplicate entry */
1083 pjDbmDelRxEnt(gCb, &pjRbCb->ulCb.recBuf, rxEnt->count);
1091 * @brief Handler for NRT TTI Indication to PDCP for UL batch processing
1094 * @b Description: Triggers batch processing of packets lined up for
1095 * deciphering. Fetches the ciphered PDUs
1096 * and triggers further processing at PDCP.
1105 PUBLIC Void PjUlSpaccTrigger(Void)
1107 PUBLIC Void PjUlSpaccTrigger(Void)
1113 Buffer *opSdu=NULLP;
1114 PjMsSPACCOutputMapInfo spaccInfo;
1116 #ifdef SPACC_NONBLOCKING
1117 static U32 ulPollCount = 0;
1120 pollop = pjMsSpaccPollUlQueue();
1121 if(PJ_MS_POLL_NOT_REQUIRED == pollop)
1123 ret = pjMsSpaccBatchAndDeCipherPackets();
1127 if(PJ_MS_POLL_COMPLETE == pollop)
1130 /* Process the o/p from SPAcc */
1131 pjMsSpaccProcessUlBatchOutput();
1132 pjMsSpaccSetResetUlQueueFree(1); /* Set to TRUE */
1134 /* Send next set of data to SPAcc after processing */
1135 ret = pjMsSpaccBatchAndDeCipherPackets();
1139 #ifdef SPACC_THREADED
1140 /*SPACC Workaround when SPACC is not able to complete BATCH*/
1142 if(ulPollCount >= globPollCount)
1144 U32 numUnexpJobs = 0;
1146 numUnexpJobs = pjMsCheckUnExpJobs();
1147 if(numUnexpJobs != 0)
1156 /* This condition is executed when SPAcc returns failure for whatever
1157 * reason.So once failure is returned, we fetch all the PDU's we had sent
1158 * for Deciphering and process them as failure */
1161 RLOG0(L_ERROR, "Error leg in uL Spacc trigger hit ");
1164 ret = pjMsSpaccFetchUlPduInfo(&spaccInfo, &opSdu, jobNum, ret);
1169 pjHdlDecipherFailure(&spaccInfo);
1176 ret = pjMsSpaccBatchAndDeCipherPackets();
1178 /* This condition is executed when SPAcc returns failure for whatever
1179 * reason.So once failure is returned, we fetch all the PDU's we had sent
1180 * for Deciphering and process them as failure */
1185 ret = pjMsSpaccFetchUlPduInfo(&spaccInfo, &opSdu, jobNum, ret);
1190 pjHdlDecipherFailure(&spaccInfo);
1196 pjMsSpaccProcessUlBatchOutput();
1208 * This function calls the function which interfaces with SPAcc
1209 * for opening of the fd. Also, it initializes the SPAcc DL Queues.
1211 *@inparam[in] gCb PDCP Instance Control Block
1216 PUBLIC S16 PjLibObdDlInitReq
1221 PUBLIC S16 PjLibObdDlInitReq(gCb)
1225 TRC3(PjLibObdDlInitReq)
1227 #ifdef INTEL_NATIVE_SPACC
1229 ret = pjMsSpaccRegIccDlHndl();
1232 printf("Registration of ICC DL handle has failed\n");
1235 printf("Registration of ICC DL handle has succeeded\n");
1236 ret = pjMsSpaccThreadActivation(appContext.hUAII_Dl);
1239 printf("Spacc thread activation has failed\n");
1242 printf("Spacc thread activation is done again\n");
1243 /* Init Mem region and Pool */
1244 pjMsSPAccInitDlMemRegionPool(gCb->init.region, gCb->init.pool);
1245 #ifdef INTEL_SPACC_IV_OPTIMIZATION
1246 pjMsNSpaccDlInitForSpaccIV(gCb);
1249 /*Call to open file descriptors for interfacing with SPACC*/
1250 if(pjMsSpaccHdlDlfdOpenReq() != ROK)
1255 /*Call to initialise the DL/UL SPAcc queues*/
1256 pjMsSPAccInitDlQue();
1258 /* Init Mem region and Pool */
1259 pjMsSPAccInitDlMemRegionPool(gCb->init.region, gCb->init.pool);
1266 * This function calls the function which interfaces with SPAcc
1267 * for opening of the fd. Also, it initializes the SPAcc UL Queues.
1269 *@inparam[in] gCb PDCP Instance Control Block
1275 PUBLIC S16 PjLibObdUlInitReq
1280 PUBLIC S16 PjLibObdUlInitReq(gCb)
1284 TRC3(PjLibObdUlInitReq)
1286 #ifdef INTEL_NATIVE_SPACC
1288 ret = pjMsSpaccRegIccUlHndl();
1291 printf("Registration of ICC UL handle has failed\n");
1294 printf("Registration of ICC UL handle has succeeded\n");
1295 ret = pjMsSpaccThreadActivation(appContext.hUAII_Ul);
1298 printf("Spacc thread activation has failed\n");
1301 printf("Spacc thread activation is done\n");
1302 /* Init Mem region and Pool */
1303 pjMsSPAccInitUlMemRegionPool(gCb->init.region, gCb->init.pool);
1304 #ifdef INTEL_SPACC_IV_OPTIMIZATION
1305 pjMsNSpaccUlInitForSpaccIV(gCb);
1308 /*Call to open file descriptors for interfacing with SPACC*/
1309 if(pjMsSpaccHdlUlfdOpenReq() != ROK)
1314 /*Call to initialise the UL SPAcc queues*/
1315 pjMsSPAccInitUlQue();
1317 /* Init Mem region and Pool */
1318 pjMsSPAccInitUlMemRegionPool(gCb->init.region, gCb->init.pool);
1326 * @brief Handler for invoking key derivation function for KeNB*. This is used
1327 * for Handover cases.
1330 * @Description: When the eNB decides to perform an intra-eNB handover it
1331 * shall derive KeNB* using target PCI, its frequency EARFCN-DL, and
1332 * either NH or the current KeNB.
1334 * @input: gCb - Control Block
1335 * kenbInf - Input structure for KeNB* derivation.
1336 * kdfCfm - Output filled into this structure after derivation.
1341 PUBLIC S16 pjLibObdPrcKenbStarCfg
1344 CpjKenbStarInfo* kenbInf,
1345 CpjKenbStarCfmInfo *kdfCfm
1348 PUBLIC S16 pjLibObdPrcKenbStarCfg(gCb, kenbInf, kdfCfm)
1350 CpjKenbStarInfo* kenbInf;
1351 CpjKenbStarCfmInfo *kdfCfm;
1354 PjMsSecInfo *pSecInfo;
1357 TRC2(pjLibObdPrcKenbStarCfg)
1359 PJ_ALLOC(gCb, pSecInfo , sizeof(PjMsSecInfo));
1360 if(pSecInfo == NULLP)
1362 RLOG1(L_ERROR, "YsMsUlmPrcKenbStarCfg failed line %d ", __LINE__);
1367 cmMemcpy(pSecInfo->hash_key, kenbInf->secKey, CPJ_SEC_KEY_LEN);
1369 /* Building the String S = FC || P0 || L0 || P1 || L1 */
1371 /*Values are initialized as per section A7 33.401*/
1372 pSecInfo->strS[0] = 0x13;
1373 pSecInfo->strS[3] = 0x00;
1374 pSecInfo->strS[4] = 0x02;
1375 pSecInfo->strS[7] = 0x00;
1376 pSecInfo->strS[8] = 0x02;
1379 RLOG2(L_DEBUG,"Value of Cellid, dl Freq is %d %d ",
1380 kenbInf->physCellId, kenbInf->dlCarrFreq);
1381 /*******************************************
1382 *************kENB* from kENB*************
1383 *******************************************/
1386 pSecInfo->strS[1] = kenbInf->physCellId >> 8;
1387 pSecInfo->strS[2] = (U8)kenbInf->physCellId;
1390 pSecInfo->strS[5] = kenbInf->dlCarrFreq >> 8;
1391 pSecInfo->strS[6] = (U8)kenbInf->dlCarrFreq;
1393 pSecInfo->strSlen = 9;
1395 if((pjSendToKeyDeriveFunc(pSecInfo, kdfCfm->secKey)) != ROK)
1397 RLOG0(L_ERROR, "In pjLibObdPrcKenbStarCfg: pjMsKDF failed");
1399 }/*End of if(ret!=ROK)*/
1401 PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo));
1404 }/*End of function*/
1408 * @brief Handler for invoking key derivation function for KeNB. KeNB is Key
1409 * derivation funtion. This is normal Ciphering/Integrity Key derivation at
1413 * @Description: For Security to be enabled, Integrity and Ciphering keys need
1414 * to be derived. These are applied on SRB/DRB data and the Ciphered/Integrity
1415 * protected PDU are sent to UE.
1417 * @input: gCb - Control Block
1418 * kenbInf - Input structure for KeNB* derivation.
1419 * kdfCfm - Output filled into this structure after derivation.
1424 PUBLIC S16 pjLibObdPrcKenbCfg
1427 CpjAsKeyInfo* kenbInf,
1428 CpjAskeyCfmInfo *kdfCfm
1431 PUBLIC S16 pjLibObdPrcKenbCfg(kenbInf)
1433 CpjAsKeyInfo* kenbInf;
1434 CpjAskeyCfmInfo *kdfCfm;
1439 PjMsSecInfo *pSecInfo;
1442 TRC2(pjLibObdPrcKenbCfg)
1445 PJ_ALLOC(gCb, pSecInfo, sizeof(PjMsSecInfo));
1446 if(pSecInfo == NULLP)
1448 RLOG1(L_ERROR, "YsMsUlmPrcKenbCfg failed line %d ", __LINE__);
1453 cmMemcpy(pSecInfo->hash_key, kenbInf->secKey, CPJ_SEC_KEY_LEN);
1455 /* Building the String S = FC || P0 || L0 || P1 || L1 */
1457 /*Values are initialized as per section A7 33.401*/
1458 pSecInfo->strS[0] = 0x15;
1459 pSecInfo->strS[2] = 0x00;
1460 pSecInfo->strS[3] = 0x01;
1461 pSecInfo->strS[5] = 0x00;
1462 pSecInfo->strS[6] = 0x01;
1464 pSecInfo->strSlen = 7;
1466 /*******************************************
1467 *************CP Ciphering key*************
1468 *******************************************/
1469 pSecInfo->strS[1] = 0x3;
1470 pSecInfo->strS[4] = kenbInf->ciphAlgoType;
1472 ret = pjSendToKeyDeriveFunc(pSecInfo, kdfCfm->cpCiphKey);
1475 RLOG0(L_ERROR, "Control Plane Cipher Key derivation failed");
1476 PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo));
1478 }/*End of if(ret!=ROK)*/
1481 /*******************************************
1482 *************UP Ciphering key*************
1483 *******************************************/
1484 pSecInfo->strS[1] = 0x5;
1485 pSecInfo->strS[4] = kenbInf->ciphAlgoType;
1487 ret = pjSendToKeyDeriveFunc(pSecInfo, kdfCfm->upCiphKey);
1490 RLOG0(L_ERROR, "User Plane Cipher Key derivation failed");
1491 PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo));
1493 }/*End of if(ret!=ROK)*/
1495 RLOG0(L_DEBUG, "Ciphering Key (UP) Derived");
1497 /*******************************************
1498 ************RRC Integrity key*************
1499 *******************************************/
1500 pSecInfo->strS[1] = 0x4;
1501 pSecInfo->strS[4] = kenbInf->intgAlgoType;
1503 ret = pjSendToKeyDeriveFunc(pSecInfo, kdfCfm->intKey);
1506 RLOG0(L_ERROR, "Integrity Key derivation failed");
1507 PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo));
1509 }/*End of if(ret!=ROK)*/
1511 RLOG0(L_DEBUG, "Integrity Key Derived");
1513 PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo));
1517 }/*End of function*/
1524 * Provides input params like Keys, RbId, direction which would be used
1525 * as input for creation of SPAcc i/p structure..
1529 * This function sends Intergrity protection request with elevant input parameters.
1531 * @param[in] pjRbCb PDCP RbCb
1532 * @param[in] intCxtId Input parameters for integrity
1533 * @param[in] mBuf SDU to be compressed
1534 * @param[out] libTrans Input to integrity algo (RbId, Count, Direction)
1542 PUBLIC S16 PjLibObdIntProtReq
1544 PjLibTrans *libTrans,
1548 PUBLIC S16 PjLibObdIntProtReq(libTrans, mBuf)
1549 PjLibTrans *libTrans;
1556 TRC3(PjLibObdIntProtReq)
1558 if(libTrans->intAlgoType == PJ_SPACC_EIA1)
1560 ret = pjMsSpaccIntegProtPkt(libTrans, mBuf);
1562 else if (libTrans->intAlgoType == PJ_SPACC_EIA2)
1564 ret = pjMsSpaccAesIntegProtPkt(libTrans, mBuf);
1566 else if (libTrans->intAlgoType == PJ_SPACC_EIA3)
1568 ret = pjMsSpaccIntegProtPkt(libTrans, mBuf);
1572 /* NULL Algorithm */
1573 PJ_PACK_MACI(*mBuf, dummyMacI);
1583 * Handler for redirecing Integration request to SPAcc module.
1587 * This function sends Intergrity verification request along with relevant input parameters.
1589 * @param[in] PjCb PDCP Cb
1590 * @param[in] PTR Handle for Integrity verification (handle opened during spacc_dev_open)
1591 * @param[in] PjLibTrans Input parameters for integrity
1592 * @param[in] mBuf SDU to be compressed
1593 * @param[out] macI MAC-I
1600 PUBLIC S16 PjLibObdIntVerReq
1602 PjLibTrans *libTrans,
1607 PUBLIC S16 PjLibObdIntVerReq(libTrans, mBuf, macI)
1608 PjLibTrans *libTrans;
1614 TRC3(PjLibObdIntVerReq)
1616 if(libTrans->intAlgoType != 0)
1618 ret = pjMsSpaccIntegVerifyPkt(libTrans, &mBuf, macI);
1622 RLOG_ARG0(L_ERROR,DBG_UEID,libTrans->ueId,"Integrity protection Algo type is == 0 ");
1631 * This function calls the function which interfaces with SPAcc
1632 * for closing the DL fd.
1639 PUBLIC S16 PjLibObdDlCloseReq(Void)
1641 PUBLIC S16 PjLibObdDlCloseReq(Void)
1645 TRC3(PjLibObdDlCloseReq)
1646 pjSpaccDeInitCiphQ();
1647 pjMsSPAccDlfdCloseReq();
1654 * This function calls the function which interfaces with SPAcc
1655 * for closing the UL fd.
1662 PUBLIC S16 PjLibObdUlCloseReq(Void)
1664 PUBLIC S16 PjLibObdUlCloseReq(Void)
1668 TRC3(PjLibObdUlCloseReq)
1669 pjSpaccDeInitDeCipherQ();
1670 pjMsSPAccUlfdCloseReq();
1680 * Handler for redirecing ciphering request to SPAcc Module.
1684 * This function sends ciphering protection request along with relevant input parameters.
1686 * @param[in] PjCb PDCP Cb
1687 * @param[in] PjLibTrans libTrans( Input parameters for deciphering )
1688 * @param[in] mBuf Data to be deciphered
1689 * @param[in] opSdu Deciphered SDU
1690 * @param[in] cxtId Handle for ciphering either for User/Control plane.
1698 PUBLIC S16 PjLibObdCipherReq
1700 PjLibTrans *libTrans,
1705 PUBLIC S16 PjLibObdCipherReq(libTrans, mBuf, opSdu)
1706 PjLibTrans *libTrans;
1713 TRC3(PjLibObdCipherReq)
1715 ret = pjSendToCipher(libTrans, mBuf);
1721 #ifdef FLAT_BUFFER_OPT
1726 * Handler for redirecing ciphering request to SPAcc Module.
1730 * This function sends ciphering protection request along with relevant input parameters.
1732 * @param[in] PjCb PDCP Cb
1733 * @param[in] PjLibTrans libTrans( Input parameters for deciphering )
1734 * @param[in] mBuf Flat Buffer to be deciphered
1735 * @param[in] opSdu Deciphered SDU
1736 * @param[in] cxtId Handle for ciphering either for User/Control plane.
1744 PUBLIC S16 PjLibObdCipherReqFB
1746 PjLibTrans *libTrans,
1751 PUBLIC S16 PjLibObdCipherReqFB(libTrans, mBuf, opSdu)
1752 PjLibTrans *libTrans;
1760 TRC3(PjLibObdCipherReqFB)
1762 ret = pjSendToCipherFB(libTrans, mBuf);
1773 * Handler for redirecing deciphering request to SPAcc module.
1777 * This function sends deciphering request along with relevant input parameters.
1779 * @param[in] PjCb PDCP Cb
1780 * @param[in] PTR Handle for Deciphering (stored during spacc_dev_open)
1781 * @param[in] PjLibTrans Input parameters for deciphering
1782 * @param[in] mBuf Data to be deciphered
1783 * @param[in] opSdu Deciphered SDU
1790 PUBLIC S16 PjLibObdDecipherReq
1792 PjLibTrans *libTrans,
1797 PUBLIC S16 PjLibObdDecipherReq(libTrans, mBuf, opSdu)
1798 PjLibTrans *libTrans;
1805 TRC3(PjLibObdDecipherReq)
1807 ret = pjSendToDeCipher(libTrans, mBuf);
1815 PUBLIC S16 pjLibObdPrcKenbCfg
1818 CpjAsKeyInfo* kenbInf,
1819 CpjAskeyCfmInfo *kdfCfm
1822 PUBLIC S16 pjLibObdPrcKenbCfg(gCb, kenbInf, kdfCfm)
1824 CpjAsKeyInfo* kenbInf;
1825 CpjAskeyCfmInfo *kdfCfm;
1828 TRC2(pjLibObdPrcKenbCfg);
1833 PUBLIC S16 pjLibObdPrcKenbStarCfg
1836 CpjKenbStarInfo* kenbInf,
1837 CpjKenbStarCfmInfo *kdfCfm
1840 PUBLIC S16 pjLibObdPrcKenbStarCfg(gCb, kenbInf, kdfCfm)
1842 CpjKenbStarInfo* kenbInf;
1843 CpjKenbStarCfmInfo *kdfCfm;
1847 TRC2(pjLibObdPrcKenbStarCfg);
1854 PUBLIC S16 pjLibDecipherReq
1856 PTR intCxtId, /* Context Id for compression */
1857 PjSecInp secInp, /* Input for Deciphering */
1858 Buffer *mBuf, /* SDU to be deciphered */
1859 Buffer **opSdu /* deciphered SDU */
1862 PUBLIC S16 pjLibDecipherReq(intCxtId, secInp, mBuf, opSdu)
1863 PTR intCxtId; /* Context Id for Deciphering */
1864 PjSecInp secInp; /* Input for Deciphering */
1865 Buffer *mBuf; /* SDU to be Deciphering */
1866 Buffer **opSdu; /* Deciphering SDU */
1869 TRC3(pjLibDecipherReq)
1875 } /* end of pjLibDecipherReq */
1879 PUBLIC S16 pjLibIntVerReq
1881 PTR intCxtId, /* Context Id for compression */
1882 PjSecInp secInp, /* Input for Integrity protection */
1883 Buffer *mBuf, /* SDU to be compressed */
1884 U32 macI, /* Message authentication code for the SDU */
1885 Status *status /* Status of the Integrity verification */
1888 PUBLIC S16 pjLibIntVerReq(intCxtId, secInp, mBuf, macI, status)
1889 PTR intCxtId; /* Context Id for compression */
1890 PjSecInp secInp; /* Input for Integrity protection */
1891 Buffer *mBuf; /* SDU to be compressed */
1892 U32 macI; /* Message authentication code for the SDU */
1893 Status *status; /* Status of the Integrity verification */
1896 TRC3(pjLibIntVerReq)
1899 } /* end of pjLibIntVerReq */
1902 PUBLIC S16 PjLibObdIntProtReq
1904 PjLibTrans *libTrans,
1908 PUBLIC S16 PjLibObdIntProtReq(libTrans, mBuf)
1909 PjLibTrans *libTrans;
1916 TRC3(PjLibObdIntProtReq);
1918 SAddMsgRef(*mBuf, 0,0, &mBuf1);
1927 PUBLIC S16 PjLibObdCipherReq
1929 PjLibTrans *libTrans,
1934 PUBLIC S16 PjLibObdCipherReq(libTrans, mBuf, opSdu)
1935 PjLibTrans *libTrans;
1941 TRC3(PjLibObdCipherReq);
1943 SAddMsgRef(mBuf, 0,0, opSdu);
1951 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
1952 #define PJ_MAX_SDUS_TO_WAIT_FOR_ACK 1200
1953 PRIVATE U32 gMemoryAlarm;
1954 /* 384MB => 768M total
1955 cat /sys/devices/virtual/icc/iccserv/mm
1957 Partition_7f1c7890 - type: LOCAL PART
1958 Split logic is currently disabled
1959 Part start address_9a200000, end address_ca1fffff
1960 Size ...................... 786432 KiB
1961 nBlocks ................... 304085
1962 Number of pools ........... 4
1963 GAP (between sectors) ..... 128 Bytes
1965 Pool_0: BlkSize_(useful_384, total_512), BlkCnt_104856, FreeBlkCnt_97177
1966 Pool_1: BlkSize_(useful_1920, total_2048), BlkCnt_157285, FreeBlkCnt_130668
1967 Pool_2: BlkSize_(useful_3968, total_4096), BlkCnt_20970, FreeBlkCnt_11245
1968 Pool_3: BlkSize_(useful_16256, total_16384), BlkCnt_20970, FreeBlkCnt_12122
1972 PUBLIC U32 dbgSpaccThreshHoldDropCnt = 0;
1973 PUBLIC U32 dbgPdcpQSizeThreshHoldDropCnt = 0;
1974 PUBLIC U32 dbgPdcpMemCount = 0;
1975 PUBLIC U32 pdcpDropMemTh = 0;
1976 PUBLIC U32 dbgICCMemThreshHoldDropCnt = 0;
1977 PUBLIC U32 dbgSSIMemThreshHoldDropCnt = 0;
1978 PUBLIC U32 dbgICCMemAlarm;
1979 PUBLIC U32 dbgPdcpQMsSpaccQFull = 0;
1980 PUBLIC U32 dbgPdcpRbOverload = 0;
1981 /* kw003.201 This function is for admission control at packet level */
1983 PUBLIC S16 pjLibPktAdmCtrl
1989 PUBLIC S16 pjLibPktAdmCtrl(pjRbCb, pkt)
1994 TRC3(pjLibPktAdmCtrl)
1995 /* Patch kw004.201 */
1997 if(pjRbCb->dlCb.txBuf.numEntries > 450)
2003 if(pjRbCb->dlCb.txBuf.numEntries > 1200)
2008 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
2009 if(pjRbCb->dlCb.txBuf.numEntries > PJ_MAX_SDUS_TO_WAIT_FOR_ACK)
2011 dbgPdcpQSizeThreshHoldDropCnt++;
2012 /*This is for AM bearers only. FC for UDP on AM will also
2013 be taken care here. */
2015 if (pjRbCb->ueCb->tenbStats)
2017 pjRbCb->ueCb->tenbStats->stats.nonPersistent.pdcp.dlPdcpAckWaitDropCnt++;
2023 /* Check the SPAcc queue too as we need to start dropping the PDUs in case
2024 * if SPAcc queue is waiting more number of PDUs
2026 if(FALSE == (pjMsCheckSpaccQueue(FALSE)))
2028 dbgSpaccThreshHoldDropCnt++;
2029 dbgPdcpQMsSpaccQFull++;
2032 /* Memory threshold is reached then drop the packet */
2033 if(isMemThreshReached(pjCb[1]->init.region) != ROK)
2036 extern U32 pdcpdrop;
2038 //MSPD_LOG("at PDCPdrop %d new %d\n",pdcpdrop);
2043 dbgICCMemAlarm=gMemoryAlarm;
2045 if (pjRbCb->dropOnlyOne)
2048 /*FC for AM bearers*/
2049 if (pjRbCb->ueCb->tenbStats)
2051 pjRbCb->ueCb->tenbStats->stats.nonPersistent.pdcp.dlPdcpDropCnt++;
2057 pjRbCb->dropOnlyOne = 0;
2060 if ((pjRbCb->pktAdmitCnt) && (pjRbCb->pktCnt > pjRbCb->pktAdmitCnt))
2062 /* FC for UM bearers */
2064 /*FC for AM bearers*/
2065 if (pjRbCb->ueCb->tenbStats)
2067 pjRbCb->ueCb->tenbStats->stats.nonPersistent.pdcp.dlPdcpDropCnt++;
2072 /* Pkt admitted. Counting it in.*/
2076 } /* end of pjLibPktAdmCtrl */
2078 #ifdef TENB_AS_SECURITY
2080 * @brief This function is used to Process the o/p from SPAcc.
2082 * @details This function is used to Process ciphered PDU's from SPAcc. We
2083 * check if SPAcc has ciphered all PDU's successfully or not. If success we
2084 * pass it to lower layers. If Failure, we initimate failure.
2092 PUBLIC Void pjMsSpaccProcessDlBatchOutput(Void)
2094 PUBLIC Void pjMsSpaccProcessDlBatchOutput(Void)
2099 Buffer *opSdu=NULLP;
2100 PjMsSPACCOutputMapInfo spaccInfo;
2105 /* Fetch Ciphered PDU's one by one from SPAcc */
2106 ret = pjMsSpaccFetchDlPduInfo(&spaccInfo, &opSdu, jobNum, ROK);
2108 /*No further packets for processing so break from here*/
2116 /* Handling of failure of any of the Deciphered PDU's */
2117 if((pjHndlCiphFail(&spaccInfo)) != ROK)
2119 /* We get to this scenario when ueCb/RbCb/TxEnt is deleted already
2120 due to either re-establishment or any other scenario. So we just
2121 drop the packets for these */
2127 /*Send the packet to RLC*/
2128 pjProcCiphPdu(opSdu, &spaccInfo);
2133 /* Num PDU's sent to SPAcc cant be greater than the below condition.
2135 if(jobNum > (PJ_MS_MAX_JOBS_IN_QUEUE + 2))
2137 RLOG1(L_ERROR, "Num Jobs in pjMsSpaccProcessDlBatchOutput "
2138 "exceeds %ld, hence exiting!!!!", jobNum);
2145 * @brief This function is used to Process the o/p from SPAcc.
2147 * @details This function is used to Process Deciphered PDU's from SPAcc. We
2148 * check if SPAcc has deciphered all PDU's successfully or not. If success we
2149 * pass it to lower layers. If Failure, we initimate failure.
2157 PUBLIC Void pjMsSpaccProcessUlBatchOutput(Void)
2159 PUBLIC Void pjMsSpaccProcessUlBatchOutput(Void)
2165 Buffer *opSdu=NULLP;
2166 PjMsSPACCOutputMapInfo spaccInfo;
2170 ret = pjMsSpaccFetchUlPduInfo(&spaccInfo, &opSdu, jobNum, ROK);
2178 /* If one of the packets sent to SPAcc returns a failure, trigger
2179 * handling of this failure scenario */
2180 retval = pjHdlDecipherFailure(&spaccInfo);
2185 retval = pjProcDeCipherPdu(&spaccInfo, opSdu);
2190 /* Drop o/p pdu's as either ueCb/RbCb/RxEnt is already deleted
2191 due to reestablishment or other scenario */
2197 if(jobNum > (PJ_MS_MAX_JOBS_IN_QUEUE + 2))
2199 RLOG1(L_ERROR, "Num Jobs in PjUlSpaccTrigger exceeds %ld,"
2200 " hence aborting!!!!", jobNum);
2208 * @brief This function is used to deInit the CipherQ
2218 PUBLIC Void pjSpaccDeInitCiphQ(Void)
2220 PUBLIC Void pjSpaccDeInitCiphQ(Void)
2223 #ifdef INTEL_NATIVE_SPACC
2224 pjMsNativeSpaccDeInitCiphQ();
2226 pjMsSpaccDeInitCiphQ();
2232 * @brief This function is used to deInit the DeCipherQ
2242 PUBLIC Void pjSpaccDeInitDeCipherQ(Void)
2244 PUBLIC Void pjSpaccDeInitDeCipherQ(Void)
2247 #ifdef INTEL_NATIVE_SPACC
2248 pjMsNativeSpaccDeInitDeCiphQ();
2250 /*pjMsSpaccDeInitCiphQ();*/
2251 pjMsSpaccDeInitDeCipherQ();
2262 * pjUlBatchProcSplit- Process rbuf messages
2267 #if defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF)
2269 PUBLIC S16 pjUlBatchProcSplit
2274 PUBLIC S16 pjUlBatchProcSplit()
2279 /* Read from Ring Buffer and process PDCP packets */
2280 Void *elmIndx = NULLP;
2281 RxmBufReq *datInd = NULLP;
2282 elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_ULPDCP);
2283 while(NULLP != elmIndx)
2285 datInd = (RxmBufReq *)elmIndx;
2286 if(datInd->mBuf != NULLP)
2288 ret1 = cmUnpkKwuDatInd(PjLiKwuDatInd, &datInd->pst, datInd->mBuf);
2291 #if (ERRCLASS & ERRCLS_DEBUG)
2292 SLogError(ENTPJ, 0, SFndProcId(),
2293 __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
2294 (ErrVal)EPJXXX, (ErrVal)ERRZERO, "UNPACK ERROR\n");
2295 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
2300 #if (ERRCLASS & ERRCLS_DEBUG)
2301 SLogError(ENTPJ, 0, SFndProcId(),
2302 __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
2303 (ErrVal)EPJXXX, (ErrVal)ERRZERO, "pjUlBatchProcSplit: mBuf NULL\n");
2304 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
2306 cmUnpkKwuDatInd(PjLiKwuDatInd, &datInd->pst, datInd->mBuf);
2309 SsRngInfoTbl[SS_RNG_BUF_RX_TO_ULPDCP].nPktProc++;;//Number of pkt processed in tti
2310 datInd->mBuf = NULLP;
2311 SRngIncrRIndx(SS_RNG_BUF_RX_TO_ULPDCP);
2313 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_ULPDCP)) == NULLP)
2321 #endif /* PTPJLIB */
2325 PUBLIC S16 PjLibObdIntCloseReq
2330 PUBLIC S16 PjLibObdIntCloseReq(*intCxtId)
2334 TRC3(PjLibObdIntCloseReq)
2341 /********************************************************************30**
2343 **********************************************************************/