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: LTE-PDCP Layer - Upper Interface Functions
25 Desc: Source code for PDCP Upper Interface Module
26 This file contains following functions
44 **********************************************************************/
45 static const char* RLOG_MODULE_NAME="PDCP";
46 static int RLOG_MODULE_ID=1024;
47 static int RLOG_FILE_ID=227;
49 @brief PDCP Upper Interface Module
53 /* header (.h) include files */
54 #include "envopt.h" /* environment options */
55 #include "envdep.h" /* environment dependent */
56 #include "envind.h" /* environment independent */
58 #include "gen.h" /* general */
59 #include "ssi.h" /* system services */
60 #include "cm5.h" /* common timer defines */
61 #include "cm_tkns.h" /* common tokens defines */
62 #include "cm_mblk.h" /* common memory allocation library defines */
63 #include "cm_llist.h" /* common link list defines */
64 #include "cm_hash.h" /* common hash list defines */
65 #include "cm_lte.h" /* common LTE defines */
66 #include "lpj.h" /* LPJ define */
67 #include "cpj.h" /* RRC layer */
68 #include "pju.h" /* PDCP service user */
69 #include "pj_env.h" /* RLC environment options */
70 #include "pj.h" /* RLC defines */
74 #include "pj_udx.h" /* udx interface */
76 /* extern (.x) include files */
77 #include "gen.x" /* general */
78 #include "ssi.x" /* system services */
80 #include "cm5.x" /* common timer library */
81 #include "cm_tkns.x" /* common tokens */
82 #include "cm_mblk.x" /* common memory allocation */
83 #include "cm_llist.x" /* common link list */
84 #include "cm_hash.x" /* common hash list */
85 #include "cm_lte.x" /* common LTE includes */
86 #include "cm_lib.x" /* common memory allocation library */
87 #include "lpj.x" /* LM(PDCP) */
88 #include "cpj.x" /* RRC layer */
89 #include "pju.x" /* PDCP service user */
96 /* kw004.201 Assigned build issue in LTE RLC pj_uim.c */
100 #endif /* __cplusplus */
104 /*****************************************************************************
106 ****************************************************************************/
111 * Handler for binding the PDCP upper layer service user with
116 * 1. This function is used by PDCP user to request for binding to
118 * 2. This function is called by the CPJ interface to bind
119 * PDCP's SAP (identified by spId) with the service user's
120 * SAP (identified by suId). @n
122 * @param[in] pst Post structure
123 * @param[in] suId Service user SAP ID
124 * @param[in] spId Service provider ID
131 PUBLIC S16 PjUiCpjBndReq
138 PUBLIC S16 PjUiCpjBndReq (pst, suId, spId)
144 PjCpjSapCb *cpjSap; /* pointer to session SAP */
145 S16 ret; /* return value */
152 if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */
157 tPjCb = PJ_GET_PJCB(pst->dstInst);
159 RLOG2(L_DEBUG, "PjUiCpjBndReq(pst, spId(%d), suId(%d))", spId, suId);
163 cpjSap = &(tPjCb->u.ulCb->cpjSap);
165 /* Verify CPJ SAP State */
166 switch(cpjSap->state)
168 /* SAP is configured but not bound */
172 /* copy bind configuration parameters in SSAP sap */
174 cpjSap->pst.dstProcId = pst->srcProcId;
175 cpjSap->pst.dstEnt = pst->srcEnt;
176 cpjSap->pst.dstInst = pst->srcInst;
178 /* Update the State */
179 cpjSap->state = PJ_SAP_BND;
181 RLOG1(L_DEBUG, "PjUiCpjBndReq: state (%d)", cpjSap->state);
185 /* SAP is already bound */
189 * Sap is already bound check source, destination Entity and
192 if (cpjSap->pst.dstProcId != pst->srcProcId
193 || cpjSap->pst.dstEnt != pst->srcEnt
194 || cpjSap->pst.dstInst != pst->srcInst
195 || cpjSap->suId != suId)
197 PJ_SEND_SAPID_ALARM(tPjCb, spId, LPJ_EVENT_CPJ_BND_REQ, LCM_CAUSE_INV_PAR_VAL);
199 RLOG1(L_DEBUG, "PjUiCpjBndReq: SAP already bound -- state(%d)", cpjSap->state);
207 PJ_SEND_SAPID_ALARM(tPjCb,spId, LPJ_EVENT_CPJ_BND_REQ, LCM_CAUSE_INV_STATE);
208 RLOG0(L_ERROR, "Invalid CPJ SAP State in Bind Req");
216 PjUiCpjBndCfm(&(cpjSap->pst), cpjSap->suId, CM_BND_OK);
220 PjUiCpjBndCfm(&(cpjSap->pst), cpjSap->suId, CM_BND_NOK);
224 } /* PjUiCpjBndReq */
231 * Handler for unbinding the RLC upper layer service user CPJ with
236 * 1. This function is used by RLC user to request for unbinding
238 * 2. This function is called by the CPJ interface to
239 * unbind with RLC. @n
241 * @param[in] pst Post structure
242 * @param[in] spId Service provider SAP ID
243 * @param[in] reason Reason for Unbinding
250 PUBLIC S16 PjUiCpjUbndReq
257 PUBLIC S16 PjUiCpjUbndReq(pst, spId, reason)
263 PjCpjSapCb *cpjSap; /* CPJ SAP control block */
264 #if (ERRCLASS & ERRCLS_INT_PAR)
265 S16 ret; /* Return Value */
271 if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */
276 tPjCb = PJ_GET_PJCB(pst->dstInst);
277 RLOG2(L_DEBUG, "PjUiCpjUbndReq(pst, spId(%d), reason(%d))", spId, reason);
282 /* disable upper sap (CPJ) */
283 cpjSap = &(tPjCb->u.ulCb->cpjSap);
286 #if (ERRCLASS & ERRCLS_INT_PAR)
288 PJ_GET_AND_VALIDATE_CPJSAP(tPjCb,cpjSap, EPJXXX, "PjUiCPjUbndReq", ret);
293 #endif /* ERRCLASS & ERRCLS_INT_PAR */
295 cpjSap->state = PJ_SAP_CFG;
298 } /* CpUiCpjUbndReq */
305 * Handler for configuring PDCP entities.
309 * This function is used by RRC to configure(add/delete/modify/
310 * reestalish/delete all RB in a UE) one or more PDCP entities.
312 * - CPJ_CFG_ADD => pjCfgAddRb
313 * - CPJ_CFG_MODIFY => pjCfgReCfgRb
314 * - CPJ_CFG_DELETE => pjCfgDelRb
315 * - CPJ_CFG_REESTABLISH => pjCfgReEstRb
316 * - CPJ_CFG_DELETE_UE => pjCfgDelUe
318 * @param[in] pst - Post structure
319 * @param[in] spId - Serive Provider ID
320 * @param[in] cfg - Configuration information for one or more PDCP entities.
327 PUBLIC S16 PjUiCpjCfgReq
334 PUBLIC S16 PjUiCpjCfgReq(pst, spId, cfg)
340 PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */
341 PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */
342 S16 ret; /* Return Value */
344 PjCfgInfo *cfgInfo; /* added here n below */
345 UdxCfgReqInfo *udxCfgReqInfo;
352 if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */
356 tPjCb = PJ_GET_PJCB(pst->dstInst);
358 RLOG2(L_DEBUG, "PjUiPjuCfgReq(pst, spId(%d), TransId(%ld))", spId, cfg->transId);
360 RLOG2(L_DEBUG, "PjUiPjuCfgReq(pst, spId(%d), TransId(%d))", spId, cfg->transId);
364 cpjSap = &(tPjCb->u.ulCb->cpjSap);
366 /* Validate SAP ID under ERRORCLS */
367 PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret);
370 /* pj002.201 Freeing from proper region */
371 PJ_PST_FREE(pst->region, pst->pool, cfg, sizeof(CpjCfgReqInfo));
375 udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
376 PJ_ALLOC_BUF_SHRABL(udxSap->pst,udxCfgReqInfo,sizeof (UdxCfgReqInfo),ret);
379 RLOG0(L_FATAL, "Memory Allocation failed.");
380 PJ_PST_FREE(pst->region, pst->pool, cfg, sizeof(CpjCfgReqInfo));
385 PJ_MEM_CPY(udxCfgReqInfo,cfg,sizeof(UdxCfgReqInfo));
386 PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
388 if (cfgInfo == NULLP)
390 RLOG0(L_FATAL, "Memory Allocation failed.");
391 PJ_PST_FREE(pst->region, pst->pool, cfg, sizeof(CpjCfgReqInfo));
392 PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, udxCfgReqInfo, sizeof(UdxCfgReqInfo));
396 cfgInfo->uprLyrTransId = cfg->transId;
397 cfgInfo->transId = ++tPjCb->u.ulCb->transId;
398 udxCfgReqInfo->transId = cfgInfo->transId;
399 cfgInfo->cfgInfo = cfg;
401 ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo);
404 RLOG0(L_ERROR, "Addition to UL transId List Failed.");
405 PJ_PST_FREE(pst->region, pst->pool, cfg, sizeof(CpjCfgReqInfo));
406 PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, udxCfgReqInfo, sizeof(UdxCfgReqInfo));
407 PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
412 udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
414 PjUlUdxCfgReq(&(udxSap->pst), udxSap->spId,udxCfgReqInfo);
417 } /* PjUiPjuCfgReq */
420 *@details This primitive is used by RRC to change the UeId for the existing UE
423 * @param pst - Point to the pst structure
424 * @param spId - The ID of the service provider SAP in the PDCP layer
425 * @param transId - Transaction ID. This field uniquily identifies
426 * transaction between RRC and PDCP.
427 * @param ueInfo - Old UE Id Info for which the change request has come
428 * @param newUeInfo - New UE Id Info for existing UE context
432 PUBLIC S16 PjUiCpjUeIdChgReq
441 PUBLIC S16 PjUiCpjUeIdChgReq(pst,spId,transId,ueInfo,newUeInfo)
446 CpjUeInfo *newUeInfo;
449 S16 ret; /* Return Value */
450 PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */
451 PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */
454 UdxUeInfo *udxUeInfo;
455 UdxUeInfo *udxNewUeInfo;
458 TRC3(PjUiCpjUeIdChgReq)
460 tPjCb = PJ_GET_PJCB(pst->dstInst);
463 RLOG2(L_DEBUG, "PjUiCpjUeIdChgReq(pst, spId(%d), transId(%ld))", spId, transId);
465 RLOG2(L_DEBUG, "PjUiCpjUeIdChgReq(pst, spId(%d), transId(%d))", spId, transId);
469 cpjSap = &(tPjCb->u.ulCb->cpjSap);
471 /* Validate SAP ID under ERRORCLS */
472 PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret);
475 /* kw002.201 Freeing from proper region */
476 PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo));
477 PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo));
481 /* Allocate memory for CkwUeInfo */
482 udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
483 PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxUeInfo,
484 sizeof (UdxUeInfo), ret);
487 RLOG0(L_FATAL, "Memory Allocation failed.");
488 /* Free memory for CkwUeInfo */
489 /* Freeing from proper region */
490 PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo));
491 PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo));
494 PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxNewUeInfo,
495 sizeof (UdxUeInfo), ret);
498 RLOG0(L_FATAL, "Memory Allocation failed.");
499 /* Free memory for CkwUeInfo */
500 /* Freeing from proper region */
501 PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxUeInfo, sizeof(UdxUeInfo));
502 PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo));
503 PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo));
507 PJ_MEM_CPY(udxUeInfo,ueInfo, sizeof(UdxUeInfo));
508 PJ_MEM_CPY(udxNewUeInfo,newUeInfo, sizeof (UdxUeInfo));
510 PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
511 if (cfgInfo == NULLP)
513 RLOG0(L_FATAL, "Memory Allocation failed.");
514 PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxUeInfo, sizeof(UdxUeInfo));
515 PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxNewUeInfo, sizeof(UdxUeInfo));
516 PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo));
517 PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo));
521 cfgInfo->uprLyrTransId = transId;
522 cfgInfo->transId = ++tPjCb->u.ulCb->transId;
523 cfgInfo->ueInfo = ueInfo;
524 cfgInfo->newUeInfo = newUeInfo;
526 if((ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo)) != ROK)
528 RLOG0(L_ERROR, "Addition to UL transId List Failed.");
529 PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxUeInfo, sizeof(UdxUeInfo));
530 PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxNewUeInfo, sizeof(UdxUeInfo));
531 PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo));
532 PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo));
537 PjUlUdxUeIdChgReq(&(udxSap->pst),udxSap->spId,cfgInfo->transId,
538 udxUeInfo,udxNewUeInfo);
541 } /* PjUiCpjUeIdChgReq */
546 * 1. RRC uses this primitive to configure PDCP security parameters.
547 * Integrity protection and/or Ciphering are configured by RRC based on the
549 * 2. Integirty Protection/Ciphering are configured per UE and applicable
550 * to all pdcp entities in that UE. Both Integrity protection and ciphering are
551 * re-configured during re-establishment. @n
553 * @param pst - Point to the pst structure
554 * @param spId - The ID of the service provider SAP in the PDCP layer
555 * @param secCfg - Security Configuration Info per UE.
562 PUBLIC S16 PjUiCpjSecCfgReq
566 CpjSecCfgReqInfo *secCfg
569 PUBLIC S16 PjUiCpjSecCfgReq(pst,spId,secCfg)
572 CpjSecCfgReqInfo *secCfg;
575 S16 ret; /* Return Value */
576 PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */
579 UdxSecCfgReqInfo *udxSecCfgReqInfo;
581 TRC2(PjUiCpjSecCfgReq)
583 if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */
587 tPjCb = PJ_GET_PJCB(pst->dstInst);
590 RLOG2(L_DEBUG, "PjUiCpjSecCfgReq(pst, spId(%d), TransId(%ld))", spId,
593 RLOG2(L_DEBUG, "PjUiCpjSecCfgReq(pst, spId(%d), TransId(%d))", spId,
599 udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
600 PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxSecCfgReqInfo,sizeof (UdxSecCfgReqInfo), ret);
603 RLOG0(L_FATAL, "Memory Allocation failed.");
607 PJ_MEM_CPY(udxSecCfgReqInfo,secCfg,sizeof(UdxSecCfgReqInfo));
608 PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
610 if (cfgInfo == NULLP)
612 RLOG0(L_FATAL, "Memory Allocation failed.");
616 cfgInfo->uprLyrTransId = secCfg->transId;
617 cfgInfo->transId = ++tPjCb->u.ulCb->transId;
618 udxSecCfgReqInfo->transId = cfgInfo->transId;
619 cfgInfo->secCfgInfo = secCfg;
621 ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo);
624 RLOG0(L_ERROR, "Addition to UL transId List Failed.");
628 PjUlUdxSecCfgReq(&(udxSap->pst), udxSap->spId,udxSecCfgReqInfo);
635 * 1. RRC uses this primitive to re-establish the PDCP entity. @n
636 * 2. This primitive is initiation of re-establishment procedure. @n
637 * 3. This prmitive and corresponding confirmation shall be followed by
638 * PjUiCpjCfgReq procedure for entire re-establishment procedure to complete.
640 * @param[in] pst - Pointer to post structure.
641 * @param[in] spId - Service provider ID. This is the reference number used by
642 * PDCP to identify its SAP.
643 * @param[in] reEstReq - PDCP re-establishment request structure.
647 PUBLIC S16 PjUiCpjReEstReq
651 CpjReEstReqInfo *reEstReq
654 PUBLIC S16 PjUiCpjReEstReq(pst,spId,reEstReq)
657 CpjReEstReqInfo *reEstReq;
660 S16 ret; /* Return Value */
661 PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */
662 PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */
665 UdxReEstReqInfo *udxReEstReqInfo;
667 TRC2(PjUiCpjReEstReq);
669 if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */
671 PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo));
674 tPjCb = PJ_GET_PJCB(pst->dstInst);
675 RLOG1(L_DEBUG, "PjUiCpjReEstReq(pst, spId(%d))", spId);
678 cpjSap = &(tPjCb->u.ulCb->cpjSap);
680 /* Validate SAP ID under ERRORCLS */
681 PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret);
684 /* pj002.201 Freeing from proper region */
685 PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo));
689 udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
690 PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxReEstReqInfo,
691 sizeof (UdxReEstReqInfo), ret);
694 RLOG0(L_FATAL, "Memory Allocation failed.");
695 PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo));
699 PJ_MEM_CPY(udxReEstReqInfo,reEstReq,sizeof(UdxReEstReqInfo));
701 PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
702 if (cfgInfo == NULLP)
704 RLOG0(L_FATAL, "Memory Allocation failed.");
705 PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo));
709 cfgInfo->uprLyrTransId = reEstReq->transId;
710 cfgInfo->transId = ++tPjCb->u.ulCb->transId;
711 udxReEstReqInfo->transId = cfgInfo->transId;
712 cfgInfo->reEstReq = reEstReq;
714 ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo);
717 RLOG0(L_ERROR, "Addition to UL transId List Failed.");
718 PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo));
719 PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
723 udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
724 PjUlUdxReEstReq(&(udxSap->pst), udxSap->spId,udxReEstReqInfo);
732 * 1. RRC uses this primitive to request count value for all DRBs in a UE. @n
733 * 2. PDCP sends the UL and DL count values in the confirmation of this request.
735 * @param[in] pst - Pointer to post structure.
736 * @param[in] spId - Service provider ID. This is the reference number used
737 * by PDCP to identify its SAP.
738 * @param[in] countReq - PDCP Count Request Information.
743 PUBLIC S16 PjUiCpjCountReq
747 CpjCountReqInfo *countReq
750 PUBLIC S16 PjUiCpjCountReq(pst,spId,countReq)
753 CpjCountReqInfo *countReq;
756 S16 ret; /* Return Value */
757 PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */
760 UdxCountReqInfo *udxCountReqInfo;
762 TRC2(PjUiCpjCountReq);
764 if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */
766 PJ_PST_FREE(pst->region, pst->pool, countReq, sizeof(CpjCountReqInfo));
771 tPjCb = PJ_GET_PJCB(pst->dstInst);
772 RLOG1(L_DEBUG, "PjUiCpjCountReq(pst, spId(%d))", spId);
776 udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
777 PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxCountReqInfo, sizeof (UdxCountReqInfo), ret);
780 RLOG0(L_FATAL, "Memory Allocation failed.");
784 PJ_MEM_CPY(udxCountReqInfo,countReq,sizeof(UdxCountReqInfo));
785 PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
787 if (cfgInfo == NULLP)
789 RLOG0(L_FATAL, "Memory Allocation failed.");
790 PJ_PST_FREE(pst->region, pst->pool, countReq, sizeof(CpjCountReqInfo));
794 cfgInfo->uprLyrTransId = countReq->transId;
795 cfgInfo->transId = ++tPjCb->u.ulCb->transId;
796 udxCountReqInfo->transId = cfgInfo->transId;
797 cfgInfo->cntReq = countReq;
799 ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo);
802 RLOG0(L_ERROR, "Addition to UL transId List Failed.");
803 PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, udxCountReqInfo, sizeof(UdxCountReqInfo));
804 PJ_PST_FREE(pst->region, pst->pool, countReq, sizeof(CpjCountReqInfo));
805 PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
810 PjUlUdxCountReq(&(udxSap->pst), udxSap->spId,udxCountReqInfo);
818 * 1. RRC uses this primitive to request the status of the SDUs for DRBs in an UE. @n
819 * 2. Its used as a reestablishment request during handover. @n
820 * 3. This primitive is used to forward the handover control Information to the target
823 * @param[in] pst - Pointer to post structure.
824 * @param[in] spId - Service provider ID. This is the reference number used
825 * by PDCP to identify its SAP.
826 * @param[in] sduStaReq - PDCP SDU Status Request Information.
831 PUBLIC S16 PjUiCpjSduStaReq
835 CpjSduStaReqInfo *staReq
838 PUBLIC S16 PjUiCpjSduStaReq(pst,spId,staReq)
841 CpjSduStaReqInfo *staReq;
845 S16 ret; /* Return Value */
846 PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */
848 PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */
850 PjCfgInfo *cfgInfo; /* added here n below */
851 UdxSduStaReqInfo *udxSduStaReq;
853 TRC2(PjUiCpjSduStaReq);
855 if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */
857 PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));
861 tPjCb = PJ_GET_PJCB(pst->dstInst);
863 RLOG1(L_DEBUG, "PjUiCpjSduStaReq(pst, spId(%d))", spId);
868 cpjSap = &(tPjCb->u.ulCb->cpjSap);
870 /* Validate SAP ID under ERRORCLS */
871 PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret);
874 /* kw002.201 Freeing from proper region */
875 PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));
879 ret = pjDbmFetchUlUeCb(tPjCb, staReq->ueId, staReq->cellId, &ueCb);
880 /* UeCb is not present */
881 if( ROK != ret || NULLP == ueCb)
883 RLOG_ARG1(L_ERROR, DBG_CELLID, staReq->cellId,"UL UeId[%u] not found",
885 CpjSduStaCfmInfo *cfmInfo;
886 /* Memory leak fix ccpu00135359 */
887 cpjSap = &tPjCb->u.ulCb->cpjSap;
888 if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfmInfo,
889 sizeof (CpjSduStaCfmInfo)) != ROK)
891 RLOG0(L_FATAL, "Memory Allocation failed.");
892 PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));
895 cfmInfo->ueId = staReq->ueId;
896 cfmInfo->cellId = staReq->cellId;
897 cfmInfo->transId = staReq->transId;
898 cfmInfo->status = CPJ_CFG_CFM_NOK;
899 cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN;
901 /* Caller should return cfm with failure */
902 RLOG_ARG1(L_DEBUG,DBG_UEID,staReq->ueId, "Prc Sdu Sta Req - UE Cb is not"
903 " found in cellId(%d)", staReq->cellId);
905 /* Send Failure SduStaCfm */
906 PjUiCpjSduStaCfm(&tPjCb->u.ulCb->cpjSap.pst,
907 tPjCb->u.ulCb->cpjSap.suId, cfmInfo);
909 PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));
914 /* Updating UE state to REEST during HO */
915 ueCb->libInfo.numReEstDrb = 0;
916 ueCb->libInfo.state = PJ_STATE_REEST_HO;
918 udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
920 PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxSduStaReq,
921 sizeof (UdxSduStaReqInfo), ret);
924 RLOG0(L_FATAL, "Memory Allocation failed.");
925 PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));
929 PJ_MEM_CPY(udxSduStaReq,staReq,sizeof(UdxSduStaReqInfo));
931 PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
932 if (cfgInfo == NULLP)
934 RLOG0(L_FATAL, "Memory Allocation failed.");
935 PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));
936 PJ_PST_FREE(pst->region, pst->pool, udxSduStaReq, sizeof(UdxSduStaReqInfo));
940 cfgInfo->uprLyrTransId = staReq->transId;
941 cfgInfo->transId = ++tPjCb->u.ulCb->transId;
942 udxSduStaReq->transId = cfgInfo->transId;
943 cfgInfo->staReq = staReq;
945 ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo);
948 RLOG0(L_ERROR, "Addition to UL transId List Failed.");
949 PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo));
950 PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, udxSduStaReq, sizeof(UdxSduStaReqInfo));
951 PJ_FREE(tPjCb, cfgInfo, sizeof(PjCfgInfo));
957 PjUlUdxSduStaReq(&(udxSap->pst), udxSap->spId,udxSduStaReq);
966 * 1. RRC uses this primitive to resume data during Re-establishment and
969 * @param[in] pst - Pointer to post structure.
970 * @param[in] spId - Service provider ID. This is the reference number used
971 * by PDCP to identify its SAP.
972 * @param[in] sduStaReq - PDCP SDU Status Request Information.
977 PUBLIC S16 PjUiCpjDatResumeReq
981 CpjDatResumeReqInfo *datResReq
984 PUBLIC S16 PjUiCpjDatResumeReq(pst,spId, *dataResReq)
987 CpjDatResumeReqInfo *datResReq;
991 S16 ret; /* Return Value */
992 PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */
993 PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */
997 UdxDatResumeInfo *udxDatResumeInfo;
998 TRC2(PjUiCpjDatResumeReq);
1000 tPjCb = PJ_GET_PJCB(pst->dstInst);
1002 RLOG1(L_DEBUG, "PjUiCpjDatResumeReq(pst, spId(%d))", spId);
1007 cpjSap = &(tPjCb->u.ulCb->cpjSap);
1009 /* Validate SAP ID under ERRORCLS */
1010 PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret);
1015 ret = pjDbmFetchUlUeCb(tPjCb, datResReq->ueId,
1016 datResReq->cellId, &ueCb);
1019 RLOG_ARG1(L_ERROR, DBG_CELLID, datResReq->cellId,"UL UeId[%u] not found",
1021 PJ_PST_FREE(pst->region, pst->pool, datResReq, sizeof(CpjDatResumeReqInfo));
1025 /* Memory leak fix ccpu00135359 */
1026 udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
1028 PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxDatResumeInfo,
1029 sizeof (UdxDatResumeInfo), ret);
1032 RLOG0(L_FATAL, "Memory Allocation failed.");
1033 PJ_PST_FREE(pst->region, pst->pool, datResReq, sizeof(CpjDatResumeReqInfo));
1037 PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo));
1038 if (cfgInfo == NULLP)
1040 RLOG0(L_FATAL, "Memory Allocation failed.");
1041 PJ_PST_FREE(pst->region, pst->pool, datResReq, sizeof(CpjDatResumeReqInfo));
1042 PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, udxDatResumeInfo, sizeof(UdxDatResumeInfo));
1046 cfgInfo->uprLyrTransId = datResReq->transId;
1047 cfgInfo->transId = ++tPjCb->u.ulCb->transId;
1048 udxDatResumeInfo->transId = cfgInfo->transId;
1049 cfgInfo->datResReq = datResReq;
1050 udxDatResumeInfo->ueId = datResReq->ueId;
1051 udxDatResumeInfo->cellId = datResReq->cellId;
1053 ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo);
1056 RLOG0(L_ERROR, "Addition to UL transId List Failed.");
1057 PJ_PST_FREE(pst->region, pst->pool, datResReq, sizeof(CpjDatResumeReqInfo));
1058 PJ_FREE(tPjCb, cfgInfo, sizeof(PjCfgInfo));
1059 PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, udxDatResumeInfo, sizeof(UdxDatResumeInfo));
1064 PjUlUdxDatResumeReq(&(udxSap->pst), udxDatResumeInfo);
1072 * 1. RRC uses this primitive to start data forwarding during
1075 * @param[in] pst - Pointer to post structure.
1076 * @param[in] spId - Service provider ID. This is the reference number used
1077 * by PDCP to identify its SAP.
1078 * @param[in] sduStaReq - PDCP SDU Status Request Information.
1083 PUBLIC S16 PjUiCpjDatForwardReq
1087 CpjDataFwdReqInfo *dataFwdReq
1090 PUBLIC S16 PjUiCpjDatForwardReq(pst,spId, *dataFwdReq)
1093 CpjDataFwdReqInfo *dataFwdReq;
1097 S16 ret; /* Return Value */
1098 PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */
1099 PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */
1101 CmLteRnti ueId; /*!< UE ID */
1102 CmLteCellId cellId; /*!< Cell ID */
1103 UdxDatForwardInfo *udxDatForwardInfo;
1106 TRC2(PjUiCpjDatForwardReq);
1108 tPjCb = PJ_GET_PJCB(pst->dstInst);
1110 RLOG1(L_DEBUG, "PjUiCpjDatForwardReq(pst, spId(%d))", spId);
1115 ueId = dataFwdReq->ueId;
1116 cellId = dataFwdReq->cellId;
1117 cpjSap = &(tPjCb->u.ulCb->cpjSap);
1119 /* Validate SAP ID under ERRORCLS */
1120 PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret);
1123 PJ_PST_FREE(pst->region, pst->pool, dataFwdReq, sizeof(CpjDataFwdReqInfo));
1127 ret = pjDbmFetchUlUeCb(tPjCb, ueId, cellId, &ueCb);
1130 RLOG_ARG1(L_ERROR, DBG_CELLID, cellId,"UL UeId[%u] not found",ueId);
1131 PJ_PST_FREE(pst->region, pst->pool, dataFwdReq, sizeof(CpjDataFwdReqInfo));
1134 /* Store the UL Data Forwarding Req or not in ueCb */
1135 ueCb->isUlDatFwdReqd = dataFwdReq->isUlDatFwdReq;
1138 /* Memory leak fix ccpu00135359 */
1139 udxSap = PJ_GET_UL_UDX_SAP(tPjCb);
1140 PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxDatForwardInfo,
1141 sizeof (UdxDatForwardInfo), ret);
1144 RLOG0(L_FATAL, "Memory Allocation failed.");
1145 PJ_PST_FREE(pst->region, pst->pool, dataFwdReq, sizeof(CpjDataFwdReqInfo));
1149 /* TODO :- Need to add code for handling request */
1151 /* Forwarding request to DL over UDX interface */
1152 udxDatForwardInfo->ueId = ueId;
1153 udxDatForwardInfo->cellId = cellId;
1154 udxDatForwardInfo->transId = dataFwdReq->transId;
1156 PJ_PST_FREE(pst->region, pst->pool, dataFwdReq, sizeof(CpjDataFwdReqInfo));
1157 if(ueCb->isUlDatFwdReqd == TRUE)
1159 /* Snd ULFwd - TRUE to DL
1160 * So that DL will not send isLastDatInd Flag to DAM */
1161 udxDatForwardInfo->ulFwding = TRUE;
1163 PjUlUdxDatForwardReq(&(udxSap->pst), udxDatForwardInfo);
1169 /*****************************************************************************
1171 ****************************************************************************/
1176 * Handler for binding the PDCP upper layer service user with
1181 * 1. This function is used by PDCP user to request for binding to
1183 * 2. This function is called by the PJU interface to bind
1184 * PDCP's SAP (identified by spId) with the service user's
1185 * SAP (identified by suId).
1187 * @param[in] pst Post structure
1188 * @param[in] suId Service user SAP ID
1189 * @param[in] spId Service provider ID
1196 PUBLIC S16 PjUiPjuBndReq
1203 PUBLIC S16 PjUiPjuBndReq (pst, suId, spId)
1209 S16 ret; /* Return Value */
1210 PjPjuSapCb *pjuSap; /* SAP Config Block */
1215 if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */
1220 tPjCb = PJ_GET_PJCB(pst->dstInst);
1221 RLOG2(L_DEBUG, "PjUiPjuBndReq(pst, spId(%d), suId(%d))", spId, suId);
1226 /* Validation of input parameters */
1227 #if (ERRCLASS & ERRCLS_INT_PAR)
1228 if(!((spId < (S16) tPjCb->pjGenCfg.maxPjuSaps) && (spId >=0)))
1232 RLOG0(L_ERROR, "Invalid PJU SAP State in Bind Req");
1233 PJ_SEND_SAPID_ALARM(tPjCb,spId, LPJ_EVENT_PJU_BND_REQ, LCM_CAUSE_INV_SAP);
1239 /* Get Sap control block */
1240 if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
1242 pjuSap = (PjPjuSapCb*)(tPjCb->u.ulCb->pjuSap + spId);
1246 pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId);
1249 /* Verify PJU SAP State */
1250 switch(pjuSap->state)
1252 /* SAP is configured but not bound */
1256 /* copy bind configuration parameters in SSAP sap */
1257 pjuSap->suId = suId;
1258 pjuSap->pst.dstProcId = pst->srcProcId;
1259 pjuSap->pst.dstEnt = pst->srcEnt;
1260 pjuSap->pst.dstInst = pst->srcInst;
1262 /* Update the State */
1263 pjuSap->state = PJ_SAP_BND;
1266 RLOG1(L_DEBUG, "PjUiPjuBndReq: state (%d)", pjuSap->state);
1270 /* SAP is already bound */
1274 * Sap is already bound check source, destination Entity and
1277 if (pjuSap->pst.dstProcId != pst->srcProcId
1278 || pjuSap->pst.dstEnt != pst->srcEnt
1279 || pjuSap->pst.dstInst != pst->srcInst
1280 || pjuSap->suId != suId)
1282 RLOG4(L_DEBUG, "Ui Pju Bnd Req suId(%d)<>suId(%d),"
1283 "pst->srcProcId(%d)<>pjuSap->pst.dstProcId(%d)",
1284 suId, pjuSap->suId, pst->srcProcId, pjuSap->pst.dstProcId);
1286 RLOG4(L_DEBUG,"Ui Pju Bnd Req pst->srcEnt(%d)<>pjuSap->pst.dstEnt"
1287 "(%d),pst->srcInst(%d)<>pjuSap->pst.dstInst(%d))",
1288 pst->srcEnt,pjuSap->pst.dstEnt,pst->srcInst,pjuSap->pst.dstInst);
1290 PJ_SEND_SAPID_ALARM(tPjCb, spId, LPJ_EVENT_PJU_BND_REQ, LCM_CAUSE_INV_PAR_VAL);
1299 RLOG0(L_ERROR, "Invalid PJU SAP State in Bind Req");
1300 PJ_SEND_SAPID_ALARM(tPjCb,spId, LPJ_EVENT_PJU_BND_REQ, LCM_CAUSE_INV_STATE);
1308 PjUiPjuBndCfm(&(pjuSap->pst), pjuSap->suId, CM_BND_OK);
1312 PjUiPjuBndCfm(&(pjuSap->pst), pjuSap->suId, CM_BND_NOK);
1317 } /* PjUiPjuBndReq */
1324 * Handler for unbinding the PDCP upper layer service user with
1329 * 1. This function is used by PDCP user to request for unbinding
1331 * 2. This function is called by the PJU interface to
1334 * @param[in] pst Post structure
1335 * @param[in] suId Service user SAP ID
1336 * @param[in] reason Reason for Unbinding
1344 PUBLIC S16 PjUiPjuUbndReq
1351 PUBLIC S16 PjUiPjuUbndReq(pst, spId, reason)
1357 PjPjuSapCb *pjuSap; /* PJU SAP control block */
1358 #if (ERRCLASS & ERRCLS_INT_PAR)
1363 TRC3(PjUiPjuUbndReq)
1365 if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */
1370 tPjCb = PJ_GET_PJCB(pst->dstInst);
1372 RLOG2(L_DEBUG, "PjUiPjuUbndReq(pst, spId(%d), reason(%d))", spId, reason);
1379 /* Get Sap control block */
1380 if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
1382 pjuSap = (PjPjuSapCb*)(tPjCb->u.ulCb->pjuSap + spId);
1386 pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId);
1390 #if (ERRCLASS & ERRCLS_INT_PAR)
1391 PJ_GET_AND_VALIDATE_PJUSAP(tPjCb, pjuSap, EPJXXX, "PjUiPjuUbndReq", ret);
1396 #endif /* ERRCLASS & ERRCLS_INT_PAR */
1398 pjuSap->state = PJ_SAP_CFG;
1401 } /* PjUiPjuUbndReq */
1405 * This primitive is used by the PDCP service user to request PDCP
1406 * for data transfer.
1408 * @param[in] pst - Pointer to Pst structure.
1409 * @param[in] spId - Service provider ID. This is the reference number
1410 * used by PDCP service user (Relay) to identify its SAP. This reference number
1411 * will be provided by PDCP in any further primitives sent by PDCP
1412 * to the service user.
1413 * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP id is used to
1414 * uniquely identify an PDCP entity.
1415 * @param[in] sduId - SDU ID.
1416 * @param[in] mBuf - Pointer to data buffer.
1421 PUBLIC S16 PjUiPjuDatReq
1425 CmLtePdcpId *pdcpId,
1430 PUBLIC S16 PjUiPjuDatReq(pst, spId, pdcpId, sduId, mBuf)
1433 CmLtePdcpId *pdcpId;
1439 S16 ret; /* Return Value */
1441 PjDlRbCb *pjRbCb; /* RB Control Block */
1442 PjDlUeCb *ueCb; /* UE Control Block */
1444 MsgLen len; /* Size of the SDU */
1447 PjPjuSapCb *pjuSap; /* SAP Config Block */
1450 U32 count; /* count for the PDU */
1452 PjuDatCfmInfo *datCfm;
1453 CmLtePdcpId *tPdcpId;
1454 PjPjuSapCb *tPjuSap;
1455 #endif /*CCPU_OPT */
1458 #ifdef CA_PHY_BRDCM_61765
1459 EXTERN U32 dlrate_pju1;
1461 SFndLenMsg(mBuf, (MsgLen *) &len);
1465 if ((pst->dstInst >= PJ_MAX_PDCP_INSTANCES) || (mBuf == NULLP)) /* KW_FIX */
1467 PJ_PST_FREE(pst->region, pst->pool, pdcpId, sizeof(CmLtePdcpId));
1472 tPjCb = PJ_GET_PJCB(pst->dstInst);
1480 pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId);
1481 /* Validate SAP ID under ERRORCLS */
1482 PJ_VALDATE_SAP(tPjCb, spId, pjuSap, ret);
1489 /* Fetch the RbCb */
1490 if (pjDbmFetchDlUeCb(tPjCb, pdcpId->ueId, pdcpId->cellId, &ueCb) != ROK)
1492 RLOG_ARG1(L_ERROR, DBG_CELLID, pdcpId->cellId,"DL UeId[%u] not found",
1497 /* Fetch the RbCb */
1499 PJ_DBM_FETCH_DL_RBCB(pdcpId->rbId, pdcpId->rbType, ueCb,pjRbCb);
1500 if (pjRbCb == NULLP)
1502 RLOG_ARG2(L_ERROR, DBG_UEID,pdcpId->ueId, "CellId[%u]: DL RbId[%d] not found",
1503 pdcpId->cellId, pdcpId->rbId);
1508 /* Update the total packets received for L2 Measurements */
1509 PJ_UPD_L2_DLDISC_PKT_STS(tPjCb,pjRbCb);
1512 /* kw003.201 Control for packet administration */
1513 if (pjLibPktAdmCtrl(pjRbCb, mBuf) != ROK)
1515 RLOG_ARG2(L_DEBUG,DBG_UEID,pdcpId->ueId, "Pju Dat Req: PDCP pkt dropped for"
1516 " cellId(%d),rbId(%d)", pdcpId->cellId, pdcpId->rbId);
1518 gPdcpStats.numPdcpSdusDiscarded++;
1519 PJ_UPD_L2_DLDISC_STS(tPjCb, pjRbCb);
1521 #ifdef CA_PHY_BRDCM_61765
1522 EXTERN U32 gDbgPdcpDropCnt;
1530 SFndLenMsg(mBuf, &len);
1531 if ( len > PJ_MAX_SDU_SIZE )
1533 #if (ERRCLASS & ERRCLS_INT_PAR)
1534 RLOG_ARG2(L_ERROR, DBG_RBID, pjRbCb->rbId , "Processing DL Sdu failed, PDU size [%lu] > MAX_LEN [%lu]",
1535 len, PJ_MAX_SDU_SIZE);
1536 #endif /* ERRCLASS & ERRCLS_INT_PAR */
1538 if ( pjRbCb->dlCb.cfmReqd)
1540 if (pjRbCb->rbType == PJ_SRB)
1541 tPjuSap = (PjPjuSapCb*)(tPjCb->pjuSap + PJ_SRB_SAP);
1543 tPjuSap = (PjPjuSapCb*)(tPjCb->pjuSap + PJ_DRB_SAP);
1545 datCfm = &datCfmTmp;
1546 tpdcpId = &tpdcpIdTmp;
1548 datCfm->cfmSta[datCfm->numSdus].sduId = sduId;
1549 datCfm->cfmSta[datCfm->numSdus].status = PJU_MAX_SDU_SIZ_EXCEED;
1551 tPdcpId->rbId = pjRbCb->rbId;
1552 tPdcpId->rbType = pjRbCb->rbType;
1553 tPdcpId->ueId = pjRbCb->ueCb->key.ueId;
1554 tPdcpId->cellId = pjRbCb->ueCb->key.cellId;
1555 PjUiPjuDatCfm(&(tPjuSap->pst), tPjuSap->suId, tPdcpId, datCfm);
1558 tPjCb->pjGenSts.numCmpFails++;
1565 if((pjRbCb->state != PJ_STATE_NORMAL) && (pjRbCb->rbType != PJ_SRB))
1567 #ifdef PRE_DEF_UE_CTX_HO
1568 pjRbCb->state = PJ_STATE_NORMAL;
1570 if(pjRbCb->dlCb.dlPktQ.count < 500)
1572 /* MSPD_DBG(" Queuing the Packets in Reestablish/Ho state ");*/
1573 pjDlmEnqueueDlPkt(tPjCb, pjRbCb, PJ_DATA_NRM_PKT, NULL, sduId, mBuf);
1579 gPdcpStats.numPdcpSdusDiscarded++;
1580 PJ_UPD_L2_DLDISC_STS(tPjCb, pjRbCb);
1584 PJ_DLM_UPD_VAR(pjRbCb,count);
1585 pjDlmProcessSdus(tPjCb, pjRbCb, mBuf, sduId,count);
1587 /* kw005.201 ccpu00117318, updated statistics */
1589 } /* PjUiPjuDatReq */
1592 #ifdef FLAT_BUFFER_OPT
1595 * This primitive is used by the PDCP service user to request PDCP
1596 * for data transfer.
1598 * @param[in] pst - Pointer to Pst structure.
1599 * @param[in] spId - Service provider ID. This is the reference number
1600 * used by PDCP service user (Relay) to identify its SAP. This reference number
1601 * will be provided by PDCP in any further primitives sent by PDCP
1602 * to the service user.
1603 * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP id is used to
1604 * uniquely identify an PDCP entity.
1605 * @param[in] sduId - SDU ID.
1606 * @param[in] mBuf - Pointer to Flat buffer.
1612 PUBLIC S16 PjUiPjuDatReqFB
1616 CmLtePdcpId *pdcpId,
1621 PUBLIC S16 PjUiPjuDatReqFB(pst, spId, pdcpId, sduId, mBuf)
1624 CmLtePdcpId *pdcpId;
1629 PjDlRbCb *pjRbCb; /* RB Control Block */
1630 PjDlUeCb *ueCb; /* UE Control Block */
1632 MsgLen len; /* Size of the SDU */
1635 PjPjuSapCb *pjuSap; /* SAP Config Block */
1637 PjCb *tPjCb = NULLP;/* KW_FIX */
1638 PjTxEnt *txEnt=NULLP;
1640 S16 ret; /* Return Value */
1644 #ifdef L2_PDCP_OPTMZ
1645 U8 hashKey; /* Computed HashKey */
1648 TRC3(PjUiPjuDatReqFB)
1650 if ((pst->dstInst >= PJ_MAX_PDCP_INSTANCES) || (mBuf == NULLP)) /* KW_FIX */
1652 /* PJ_FREE_FLAT_BUF(tPjCb, mBuf); */
1656 tPjCb = PJ_GET_PJCB(pst->dstInst);
1665 RLOG1(L_DEBUG, "PjUiPjuDatReq(pst, spId(%d))", spId);
1669 pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId);
1670 /* Validate SAP ID under ERRORCLS */
1671 PJ_VALDATE_SAP(tPjCb, spId, pjuSap, ret);
1674 PJ_FREE_FLAT_BUF(tPjCb, mBuf);
1678 /* Fetch the UeCb */
1679 if (pjDbmFetchDlUeCb(tPjCb, pdcpId->ueId, pdcpId->cellId, &ueCb) != ROK)
1681 RLOG_ARG1(L_ERROR, DBG_CELLID, pdcpId->cellId,"DL UeId[%u] not found",
1683 PJ_FREE_FLAT_BUF(tPjCb, mBuf);
1686 /* Fetch the RbCb */
1687 PJ_DBM_FETCH_DL_RBCB(pdcpId->rbId, pdcpId->rbType, ueCb,pjRbCb);
1689 if (pjRbCb == NULLP)
1691 RLOG_ARG2(L_ERROR, DBG_UEID,pdcpId->ueId, "CellId[%u]: DL RbId[%d] not found",
1692 pdcpId->cellId, pdcpId->rbId);
1693 PJ_FREE_FLAT_BUF(tPjCb, mBuf);
1697 /* Update the total packets received for L2 Measurements */
1698 PJ_UPD_L2_DLDISC_PKT_STS(tPjCb,pjRbCb);
1701 /* kw003.201 Control for packet administration */
1703 if (pjLibPktAdmCtrl(pjRbCb, NULL) != ROK)
1705 RLOG_ARG2(L_DEBUG,DBG_UEID,pdcpId->ueId,"PDCP pkt Q is Full & pkt dropped"
1706 " for cellId(%d), rbId(%d)", pdcpId->cellId, pdcpId->rbId);
1707 PJ_FREE_FLAT_BUF(tPjCb, mBuf);
1708 gPdcpStats.numPdcpSdusDiscarded++;
1709 PJ_UPD_L2_DLDISC_STS(tPjCb, pjRbCb);
1714 if((ueCb->libInfo.state != PJ_STATE_NORMAL) && (pjRbCb->rbType != PJ_SRB))
1716 if(pjRbCb->dlCb.dlPktQ.count < 500)
1718 pjDlmEnqueueDlPktFB(tPjCb, pjRbCb, PJ_DATA_NRM_PKT, NULL, sduId, mBuf);
1723 PJ_FREE_FLAT_BUF(tPjCb, mBuf);
1724 gPdcpStats.numPdcpSdusDiscarded++;
1725 PJ_UPD_L2_DLDISC_STS(tPjCb, pjRbCb);
1730 PJ_ALLOC(tPjCb, txEnt, sizeof(PjTxEnt));
1731 #if (ERRCLASS & ERRCLS_ADD_RES)
1734 RLOG0(L_FATAL, "Memory Allocation failed.");
1735 PJ_FREE_FLAT_BUF(gCb,sdu);
1738 #endif /* ERRCLASS & ERRCLS_RES */
1739 PJ_DLM_UPD_VAR(pjRbCb,txEnt->count);
1740 PJ_DLM_GET_SN(pjRbCb,txEnt->count,txEnt->sn);
1741 pjRbCb->dlCb.count = txEnt->count;
1742 txEnt->state = PJ_SDU_RECEIVED;
1743 txEnt->sduId = sduId;
1747 /* Insert TxEnt into the transmission buffer */
1748 #ifndef L2_PDCP_OPTMZ
1749 pjDbmInsTxEnt(tPjCb, &(pjRbCb->dlCb.txBuf), txEnt);
1750 /* kw005.201 added support for L2 Measurement */
1752 if (pjRbCb->ueCb->secInfo.secAct && pjRbCb->ueCb->secInfo.cipherInfo.algoType != 0) /* If its not NULL Ciphering and Security is enabled */
1754 txEnt->datCfmEnt.node = NULLP;
1755 txEnt->reEstPktEnt.node = NULLP;
1756 txEnt->sduSubmitEnt.node = (PTR)NULLP;
1758 buf=&(pjRbCb->dlCb.txBuf);
1759 hashKey = (U8)PJ_HASH_FN(buf, txEnt->count); /*KW_FIX*/
1761 txEnt->lstEnt.node = (PTR)txEnt;
1762 cmLListAdd2Tail(&buf->datQ[hashKey], &txEnt->lstEnt);
1764 /* No Need to add TxEnt in DataCfm Quee as no Cfm from RLC */
1765 if (pjRbCb->mode == PJ_DRB_AM)
1767 txEnt->datCfmEnt.node = (PTR)txEnt;
1768 cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.datCfmQ, &txEnt->datCfmEnt);
1770 txEnt->state = PJ_PDU_SUBMITTED;
1774 pjDbmInsTxEnt(tPjCb, &(pjRbCb->dlCb.txBuf), txEnt);
1778 #ifndef RGL_SPECIFIC_CHANGES
1781 extern U32 dlrate_pju;
1782 dlrate_pju += mBuf->len;
1786 pjDlmHdlCmp(tPjCb, pjRbCb, txEnt);
1787 /*pjDlmProcessSdusFB(tPjCb, pjRbCb, mBuf, sduId, sn, txHfn);*/
1789 /* kw005.201 ccpu00117318, updated statistics */
1791 } /* PjUiPjuDatReqFB */
1797 * This primitive is used by PDCP user to forward the SDUs along with its SN
1798 * as part of handover (SDUs forwarded from PDCP on source eNB via X2-U
1799 * Interface to the PDCP on target eNB)
1801 * @param[in] pst - Pointer to Pst structure.
1802 * @param[in] spId - Service provider ID. This is the reference number
1803 * used by PDCP service user (Relay) to identify its SAP. This reference number
1804 * will be provided by PDCP in any further primitives sent by PDCP
1805 * to the service user.
1806 * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP id is used to
1807 * uniquely identify a PDCP entity.
1808 * @param[in] datFwdReq - Pointer to data forward information structure.
1813 PUBLIC S16 PjUiPjuDatFwdReq
1817 CmLtePdcpId *pdcpId,
1818 PjuDatFwdReqInfo *datFwdReq
1821 PUBLIC S16 PjUiPjuDatFwdReq(pst,spId,pdcpId,datFwdReq)
1824 CmLtePdcpId *pdcpId;
1825 PjuDatFwdReqInfo *datFwdReq;
1829 S16 ret; /* Return Value */
1830 PjPjuSapCb *pjuSap; /* SAP Config Block */
1833 TRC3(PjUiPjuDatFwdReq)
1834 /* ccpu00137221 : KW Fix */
1835 if ( NULLP == datFwdReq )
1838 #if (ERRCLASS & ERRCLS_INT_PAR)
1839 if (pst->dstInst < PJ_MAX_PDCP_INSTANCES)
1841 tPjCb = PJ_GET_PJCB(pst->dstInst);
1844 RLOG0(L_ERROR, "Hndl DatFwdReq failed ,tPjCb is NULLP");
1847 #endif /* ERRCLASS & ERRCLS_INT_PAR */
1850 if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
1852 PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo,
1853 (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
1854 PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
1857 tPjCb = PJ_GET_PJCB(pst->dstInst);
1862 RLOG1(L_DEBUG, "PjUiPjuDatFwdReq(pst, spId(%d))", spId);
1864 if (( datFwdReq->dir == PJ_DIR_DL ) &&
1865 (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_DL))
1868 PjDlUeCb *dlUeCb; /* UE Control Block */
1869 PjDlRbCb *dlRbCb; /* RB Control Block */
1870 pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId);
1871 /* Validate SAP ID under ERRORCLS */
1872 PJ_VALDATE_SAP(tPjCb, spId, pjuSap, ret);
1875 /* Freeing from proper region */
1876 PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo,
1877 (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
1878 PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
1882 if (pjDbmFetchDlUeCb(tPjCb, pdcpId->ueId, pdcpId->cellId, &dlUeCb) != ROK)
1884 RLOG_ARG1(L_ERROR, DBG_CELLID, pdcpId->cellId,"DL UeId[%u] not found",
1886 /* Freeing from proper region */
1887 PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo,
1888 (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
1889 PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
1892 /* Fetch the RbCb */
1893 PJ_DBM_FETCH_DL_RBCB(pdcpId->rbId, pdcpId->rbType, dlUeCb,dlRbCb);
1894 if (dlRbCb == NULLP)
1896 RLOG_ARG2(L_ERROR, DBG_UEID,pdcpId->ueId, "CellId[%u]: DL RbId[%d] not found",
1897 pdcpId->cellId, pdcpId->rbId);
1898 /* Freeing from proper region */
1899 PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo,
1900 (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
1901 PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
1906 if (dlRbCb->state == PJ_STATE_HO)
1908 pjDlmEnqueueDlPkt(tPjCb,dlRbCb, PJ_DATA_FWD_PKT, datFwdReq, 0, NULLP);
1912 ret = pjDlmHndlDatFwdReq(tPjCb, dlRbCb, datFwdReq);
1915 PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo,
1916 (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
1917 PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
1920 else if (( datFwdReq->dir == PJ_DIR_UL ) &&
1921 (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL))
1923 PjUlRbCb *ulRbCb; /* RB Control Block */
1925 pjuSap = (PjPjuSapCb*)(tPjCb->u.ulCb->pjuSap + spId);
1926 /* Validate SAP ID under ERRORCLS */
1927 pjuSap->state = PJ_SAP_BND;
1928 PJ_VALDATE_SAP(tPjCb, spId, pjuSap, ret);
1931 /* Freeing from proper region */
1932 PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo,
1933 (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
1934 PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
1938 if (pjDbmFetchUlUeCb(tPjCb, pdcpId->ueId, pdcpId->cellId, &ulUeCb) != ROK)
1940 RLOG_ARG1(L_ERROR, DBG_CELLID, pdcpId->cellId,"UL UeId[%u] not found",
1942 /* Freeing from proper region */
1943 PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo,
1944 (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
1945 PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
1948 /* Fetch the RbCb */
1949 PJ_DBM_FETCH_UL_RBCB(pdcpId->rbId, pdcpId->rbType, ulUeCb,ulRbCb);
1950 if (ulRbCb == NULLP)
1952 RLOG_ARG2(L_ERROR, DBG_UEID,pdcpId->ueId, "CellId[%u]: UL RbId[%d] not found",
1953 pdcpId->cellId, pdcpId->rbId);
1954 /* Freeing from proper region */
1955 PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo,
1956 (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
1957 PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
1962 ret = pjUlmHdlDatFwdReq(tPjCb, ulRbCb, datFwdReq);
1963 PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo,
1964 (datFwdReq->numSdus * sizeof(PjuDatFwdInfo)));
1965 PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo));
1968 /* Freeing from proper region */
1973 #if (ERRCLASS & ERRCLS_INT_PAR)
1974 RLOG0(L_ERROR, "pjDlm/pjUlm HndlDatFwdReq failed");
1975 #endif /* ERRCLASS & ERRCLS_INT_PAR */
1983 * @brief Handler for Bind request from RRM towards CL.
1987 * Function : YsUiCpjKdfReq
1989 * This function handles the bind request from RRM.
1992 * @param[in] Pst *pst
1993 * @param[in] SuId suId
1994 * @param[in] SpId spId
2000 PUBLIC S16 PjUiCpjKdfReq
2004 CpjCfgTransId transId,
2005 CpjKdfReqInfo *kdfReqInfo
2008 PUBLIC S16 PjUiCpjKdfReq(pst, suId, spId)
2015 CpjKdfCfmInfo *kdfCfmInf;
2025 if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */
2029 tPjCb = PJ_GET_PJCB(pst->dstInst);
2031 /* Memory leak fix ccpu00135359 */
2032 cpjSap = &(tPjCb->u.ulCb->cpjSap);
2033 if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&kdfCfmInf,
2034 sizeof (CpjKdfCfmInfo)) != ROK)
2036 RLOG0(L_FATAL, "Memory Allocation failed.");
2040 cfmPst.dstInst = pst->srcInst;
2041 cfmPst.dstEnt = pst->srcEnt;
2042 cfmPst.dstProcId = pst->srcProcId;
2043 cfmPst.srcInst = pst->dstInst;
2044 cfmPst.srcEnt = pst->dstEnt;
2045 cfmPst.srcProcId = pst->dstProcId;
2046 cfmPst.selector = 0;
2047 cfmPst.region = tPjCb->init.region;
2048 cfmPst.pool = tPjCb->init.pool;
2049 cfmPst.prior = PRIOR0;
2050 cfmPst.route = RTESPEC;
2052 RLOG1(L_DEBUG, "Key derivation request for Key type %d",
2053 kdfReqInfo->keyDerType);
2055 switch(kdfReqInfo->keyDerType)
2058 kdfCfmInf->keyDerType = CPJ_KDF_TYPE1;
2059 ret = pjLibObdPrcKenbCfg(tPjCb, &(kdfReqInfo->u.kEnbInf),
2060 &(kdfCfmInf->u.kEnbInf));
2064 kdfCfmInf->keyDerType = CPJ_KDF_TYPE2;
2065 ret = pjLibObdPrcKenbStarCfg(tPjCb, &(kdfReqInfo->u.kEnbStarInf),
2066 &(kdfCfmInf->u.kEnbStarInf));
2074 /* Send Cfg confirm */
2077 PjUiCpjKdfCfm(&cfmPst, PJ_KDF_SAP,
2078 transId, kdfCfmInf, CPJ_CFG_CFM_NOK);
2079 }// Sudhanshu WR Change
2082 PjUiCpjKdfCfm(&cfmPst, PJ_KDF_SAP,
2083 transId, kdfCfmInf, CPJ_CFG_CFM_OK);
2087 SPutSBuf (pst->region, pst->pool, (Data *)kdfReqInfo,
2088 sizeof(CpjKdfReqInfo));
2093 } /* PjUiCpjKdfReq */
2098 #endif /* __cplusplus */
2099 /********************************************************************30**
2101 **********************************************************************/