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 - Configuration Manager file
25 Desc: It contains the following configuraiton primtives
38 *********************************************************************21*/
39 static const char* RLOG_MODULE_NAME="PDCP";
40 static int RLOG_MODULE_ID=1024;
41 static int RLOG_FILE_ID=213;
44 @brief LTE PDCP Configuration Module
48 /* header (.h) include files */
49 #include "envopt.h" /* environment options */
50 #include "envdep.h" /* environment dependent */
51 #include "envind.h" /* environment independent */
53 #include "gen.h" /* general */
54 #include "ssi.h" /* system services interface */
55 #include "cm5.h" /* Timer Functions */
56 #include "cm_lte.h" /* common LTE header file */
57 #include "cm_hash.h" /* common hash module file */
58 #include "cm_llist.h" /* common list header file */
59 #include "cpj.h" /* RRC layer */
60 #include "pju.h" /* PDCP service user */
61 #include "lpj.h" /* RRC layer */
62 #include "pj_env.h" /* RLC environment options */
63 #include "pj.h" /* RLC layer */
69 /* header/extern include files (.x) */
71 #include "gen.x" /* general */
72 #include "ssi.x" /* system services interface */
73 #include "cm_lib.x" /* common library */
74 #include "cm5.x" /* Timer Functions */
75 #include "cm_hash.x" /* common hash module */
76 #include "cm_lte.x" /* common LTE file */
77 #include "cm_llist.x" /* common list header file */
78 #include "cpj.x" /* RRC layer */
79 #include "pju.x" /* PDCP service user */
80 #include "lpj.x" /* LM Interface */
81 #include "pj.x" /* RLC layer */
86 /* Proto types declarations for local functions */
88 PRIVATE S16 pjCfgFillPjUlRbCb ARGS ((
97 PRIVATE S16 pjCfgUpdUlCompInfo ARGS ((
101 CpjHdrCompCfg *rohcCfg
105 PRIVATE S16 pjAddToUlL2Meas ARGS ((
113 /* Store the Profile ID into array index */
114 /* RRC is not sending the profile id directly. It will give
115 the for all the profiles with True/False. PDCP will derive the profile
116 based on this profile Id list */
118 PRIVATE U16 rohcProfId[CPJ_MAX_ROHC_PROF_LIST]= { 0x0001, 0x0002, 0x0003, 0x0004,
119 0x0006, 0x0101, 0x0102, 0x0103,
121 /** @addtogroup cfgdata */
126 * Hanlder to process the configuration recieved from the upper layer and update the pdcp
130 * 1. This function create a new PDCP RB Cb. @n
131 * 2. Newly created PDCP RB Cb will be placed in Data base with the configuration
132 * informtion received. @n
133 * 3. Return Success or Failure to the caller with reason and status
136 * @param [in] ueId - UE Identifier
137 * @param [in] cellId - CELL Identifier
138 * @param [in] entCfg - Entity Configuration to be done.
139 * @param [out] entCfm - Entity Confirmation.
144 PUBLIC S16 pjCfgAddUlRb
155 PUBLIC S16 pjCfgAddUlRb (gCb, ueId, cellId,isHo, entCfg, entCfm)
166 PjUlRbCb *rbCb; /* Rb Cb Pointer */
174 RLOG2(L_DEBUG, "pjCfgAddRb- Received with -- cellId(%d),ueId(%d)",
179 /* Ue Cb is not present, Create Ue Cb */
180 if ( pjDbmCreateUlUeCb(gCb, ueId, cellId, ueCb) != ROK)
182 /* Ue Cb allocation failed */
183 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
184 CPJ_CFG_REAS_UE_CREAT_FAIL);
186 RLOG_ARG1(L_ERROR,DBG_UEID,ueId, "Creating UE Cb Failed -- cellId(%d)",
192 (*ueCb)->inst = gCb->init.inst;
193 /* Rb Id is allowed range or not */
194 PJ_VALIDATE_RBID(ueId, entCfg->rbId, entCfg->rbType, ret);
197 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
198 CPJ_CFG_REAS_INVALID_RBID);
200 RLOG_ARG2(L_ERROR,DBG_UEID,ueId, "Invalid RB ID-- cellId(%d),RB Id(%d)",
201 cellId, entCfg->rbId);
206 /* Find Rb Cb already exist or not */
207 PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, (*ueCb), rbCb);
211 RLOG_ARG2(L_WARNING, DBG_UEID,ueId, "CellId [%u]:RbId[%d] already exists",
212 cellId,entCfg->rbId);
213 /* Rb Cb already exist for pdpcp */
214 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
215 CPJ_CFG_REAS_SAME_RBID);
218 else if (NULLP == rbCb)
220 /* Create Rb Cb and place in Ue Cb */
221 rbCb = pjDbmCreateUlRbCb(gCb, entCfg->rbId, entCfg->rbType, *ueCb, PJ_CFG_PDCP);
224 RLOG_ARG2(L_ERROR, DBG_UEID, ueId,"CellId [%u]:Creation of rbCb with id [%d] failed",
225 cellId, entCfg->rbId);
226 /* Create Rb Cb Failed*/
227 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
228 CPJ_CFG_REAS_ENT_CREAT_FAIL);
233 /* Copy the Recived information into RbCb */
234 ret = pjCfgFillPjUlRbCb(gCb, rbCb, *ueCb,isHo, entCfg , entCfm);
236 /* Fill the Cfm status and Reason */
237 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
246 * Hanlder to update the PJRB with the received infromation during
247 * configuration or re configuration.
250 * 1. update the data base with the new configuration informtion received. @n
251 * 2. update the data base with the new re-configuration informtion received. @n
252 * 3. If required Initiliaze the tx/rx Buffers and Timers. @n
253 * 4. Return Success or Failure to the caller with reason and status
256 * @param [out] rbCb - RB Control Block
257 * @param [out] entCfm - PDCP Entiry Confirmation
258 * @param [in] ueCb - UE Control Block
259 * @param [in] entCfg - PDCP Entity Configuration
264 PRIVATE S16 pjCfgFillPjUlRbCb
274 PRIVATE S16 pjCfgFillPjUlRbCb(gCb, pjRbCb, ueCb, isHo, cfgEnt, cfmEnt)
284 U8 *bitMap; /* Bitmap status report buffer */
285 U16 bMapLen; /* Bit Map length */
286 /* kw005.201 added support for L2 measurement */
288 TRC3(pjCfgFillPjUlRbCb);
294 RLOG_ARG3(L_DEBUG,DBG_UEID,ueCb->key.ueId,"Received Fill RB Req For "
295 "cellId(%d), rbId(%d), cfgType(%d)",
296 ueCb->key.cellId, cfgEnt->rbId, cfgEnt->cfgType);
298 switch (cfgEnt->cfgType)
300 /* Cfg Type received as ADD RB */
303 pjRbCb->state = PJ_STATE_NORMAL;
304 pjRbCb->rbId = cfgEnt->rbId;
305 pjRbCb->rbType = cfgEnt->rbType;
306 pjRbCb->mode = cfgEnt->m.addCfg.rlcInfo.mode;
307 pjRbCb->dir = cfgEnt->m.addCfg.rlcInfo.dir;
310 if(PJ_SRB == pjRbCb->rbType)
312 /* SN length is fixed for SRB */
313 pjRbCb->snLen = PJ_SRB_SN_LEN;
318 if (CM_LTE_MODE_UM == pjRbCb->mode)
319 { /* SN length can be 7 bit or 12 bit in UM mode */
320 pjRbCb->snLen = cfgEnt->m.addCfg.rlcInfo.m.rlcUm.pdcpSNSize;
321 #ifdef NR_PDCP_DRB_SN_18_BIT
322 pjRbCb->snLen = PJ_18_BIT_SN;
324 pjRbCb->snLen = PJ_12_BIT_SN;
329 /* SN length can be 12/15 bit for AM mode */
330 pjRbCb->snLen = cfgEnt->m.addCfg.rlcInfo.m.rlcAm.pdcpSNSize;
331 #ifdef NR_PDCP_DRB_SN_18_BIT
332 pjRbCb->snLen = PJ_18_BIT_SN;
334 pjRbCb->snLen = PJ_12_BIT_SN;
338 pjRbCb->state = PJ_STATE_HO;
343 /* Initialize all off board timers */
344 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
345 cmInitTimers(&pjRbCb->ulCb.obdTmr,PJ_RB_MAX_TIMERS);
348 RLOG_ARG2(L_DEBUG,DBG_UEID,ueCb->key.ueId,
349 "RB Add Req Received with - Dir(%d),mode(%d)",
350 pjRbCb->dir, pjRbCb->mode);
352 pjRbCb->ulCb.discReqd = cfgEnt->m.addCfg.discReqd;
353 pjRbCb->ulCb.staRepReqd = cfgEnt->m.addCfg.rlcInfo.m.rlcAm.statusRepReqd;
355 /*Initialization for Rx Buf */
356 gCb->pjGenCfg.nmbUlBins = PJ_MAX_HASH_BINS;
357 pjDbmBufInit(gCb, &pjRbCb->ulCb.recBuf,gCb->pjGenCfg.nmbUlBins);
358 cmLListInit(&pjRbCb->ulCb.ulPktLst);
359 //pjRbCb->ulCb.lastSubCnt = 0xffffffff;
362 /* Update the Compressor Informatio in Rb Cb */
363 if(cfgEnt->rbType == CM_LTE_DRB)
365 ret=pjCfgUpdUlCompInfo(gCb, pjRbCb, ueCb,&cfgEnt->m.addCfg.hdrCompCfg);
366 /* kw005.201 added support for L2 measurement */
368 pjRbCb->qci = cfgEnt->m.addCfg.qci;
369 pjAddToUlL2Meas(gCb,pjRbCb,
370 ueCb->key.cellId,ueCb->key.ueId);
373 /* TODO: once APP and RRC changes are done, we can enable the below line */
374 //pjRbCb->reOrdrTmrVal = cfgEnt->m.addCfg.reOrdrTmrVal;
375 pjRbCb->reOrdrTmrVal = 8000;
376 cmInitTimers(&(pjRbCb->ulCb.tReordTmr), 1);
380 /* Cfg Type received as Modify RB */
383 /* Store the received Information */
384 if(CPJ_RECFG_DISRQD & cfgEnt->m.modCfg.bitFlag)
385 pjRbCb->ulCb.discReqd = cfgEnt->m.modCfg.discReqd;
387 if(CPJ_RECFG_REORDTMR & cfgEnt->m.modCfg.bitFlag)
390 /* TODO: once APP and RRC changes are done, we can enable the below line */
391 //pjRbCb->reOrdrTmrVal = cfgEnt->m.modCfg.reOrdrTmrVal;
392 pjRbCb->reOrdrTmrVal = 8000;
393 Bool tmrRunning = pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR);
396 /* update RX_REORD to RX_NEXT; */
397 pjRbCb->ulCb.rxReord = pjRbCb->ulCb.rxNext;
399 /* stop and restart t-Reordering. */
400 pjStopTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR);
401 pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR);
405 /* Header Compression profile has been modified */
406 if(TRUE == cfgEnt->m.modCfg.hdrCompCfg.hdrCompUsed)
408 /* Close All the channels */
409 pjUtlUlCmpReset(gCb, pjRbCb);
410 pjCfgUpdUlCompInfo(gCb, pjRbCb, ueCb, &cfgEnt->m.modCfg.hdrCompCfg);
413 /* In case of Hand off scenario: At Target eNode-B,
414 Handoff information will send in re-cfg req */
416 if(TRUE & cfgEnt->m.modCfg.hoInfo.isHoPres)
418 /* Store the HO information and call for Status Report
421 /* Down Up Lin Information present */
422 if(CPJ_HO_UL & cfgEnt->m.modCfg.hoInfo.isHoPres)
424 RLOG_ARG2(L_DEBUG,DBG_UEID,ueCb->key.ueId,
425 "Received PDCP Update from Application for dir(%d), mode(%d)",
426 pjRbCb->dir, pjRbCb->mode);
428 pjRbCb->ulCb.rxDeliv = cfgEnt->m.modCfg.hoInfo.ulCount;
429 pjRbCb->ulCb.rxNext = cfgEnt->m.modCfg.hoInfo.ulCount;
430 if (pjRbCb->snLen != cfgEnt->m.modCfg.hoInfo.snLen)
432 pjRbCb->snLen = cfgEnt->m.modCfg.hoInfo.snLen;
434 /* Store the Count in ulCb, this is needed while sending PDCP Status Report */
435 bMapLen = cfgEnt->m.modCfg.hoInfo.numBits;
436 bitMap = cfgEnt->m.modCfg.hoInfo.ulBitMap;
438 /* Build and send the Status Report to RLC */
439 /* Send the FMS & bitmap retrieved now from App */
440 RLOG_ARG0(L_DEBUG,DBG_UEID,ueCb->key.ueId,
441 "Sending PDCP Status Report to UE ");
443 pjUlmBldStaRep(gCb, pjRbCb, pjRbCb->ulCb.rxDeliv, bitMap, bMapLen);
445 pjUlmProcessUlPktQ(gCb, pjRbCb);
447 pjRbCb->state = PJ_STATE_NORMAL;
451 PJ_FREE(gCb, bitMap, (bMapLen / 8) * sizeof(U8));
459 /* Un Expected cfg type */
462 RLOG1(L_ERROR, "Invalid cfgType [%d]", cfgEnt->cfgType);
466 } /* pjCfgFillPjRbCb */
473 * Hanlder to process the re-configuration for existing PJRB from the upper
477 * 1. This function fetch the PJRB from pdcp data base. @n
478 * 2. update the data base with the new configuration informtion received. @n
479 * 3. Return Success or Failure to the caller with reason and status
482 * @param [in] ueId - UE Identifier
483 * @param [in] cellId - CELL Identifier
484 * @param [in] entCfg - Entity Configuration to be done.
485 * @param [out] entCfm - Entity Confirmation.
491 PUBLIC S16 pjCfgReCfgUlRb
499 PUBLIC S16 pjCfgReCfgUlRb (gCb, ueCb, entCfg, entCfm)
507 PjUlRbCb *rbCb; /* Rb Cb */
509 TRC3(pjCfgReCfgUlRb);
515 RLOG2(L_DEBUG, "Re-Cfg UL RB Req Received for -- cellId(%d),ueId(%d)",
516 ueCb->key.cellId,ueCb->key.ueId);
519 PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
521 /* Rb Cb is not present or Rb Cb is not configured for PDCP */
524 RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId[%u]:RbId[%d] not found",
525 ueCb->key.cellId, entCfg->rbId);
526 /* Fill entCfm structure */
527 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
528 CPJ_CFG_REAS_PDCPID_UNKWN);
533 /* Copy the received infromation in to Rb Cb */
534 ret = pjCfgFillPjUlRbCb(gCb, rbCb, ueCb,FALSE, entCfg , entCfm);
536 /* Fill the Cfm status and Reason */
537 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
547 * This function deletes the existing RB(PDCP and RLC) from Ue Cb.
550 * 1. Stop the timers and deallocate tx/rx Buffs for PJRB CB. @n
551 * 2. Delete the existing RB Cb(PDCP and RLC) from Ue Cb. @n
553 * @param [in] ueId - UE Identifier
554 * @param [in] cellId - CELL Identifier
555 * @param [in] entCfg - Entity Configuration to be done.
556 * @param [out] entCfm - Entity Confirmation.
562 PUBLIC S16 pjCfgDelUlRb
570 PUBLIC S16 pjCfgDelUlRb (gCb, ueId, cellId, entCfg, entCfm)
578 PjUlRbCb *rbCb = NULLP;
585 RLOG2(L_DEBUG, "Del UL RB Req Received for -- cellId(%d),ueId(%d)",
586 ueCb->key.cellId, ueCb->key.ueId);
589 PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
591 /* RB Cb is not present or not configured for PDCP */
594 RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId[%u]:RbId[%d] not found",
595 ueCb->key.cellId, entCfg->rbId);
596 /* Fill entCfm structure with invalid pdcp Id */
597 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
598 CPJ_CFG_REAS_INVALID_PDCPID);
602 /* Delete PDCP Related infromation from RB CB */
603 ret= pjCfgDelPjUlRbCb(gCb, ueCb, rbCb);
607 /* Fill entCfm structure with invalid pdcp Id */
608 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
609 CPJ_CFG_REAS_INVALID_PDCPID);
611 RLOG_ARG2(L_ERROR, DBG_UEID, ueCb->key.ueId, "CellId[%u]:RbId[%d] not deleted",
612 ueCb->key.cellId, entCfg->rbId);
615 /* Fill the Cfm status and Reason */
616 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
629 * This primitive is used to re-establish Uplink SRB2 and/or DRB'S during RRC connection
630 * re-configuration procedure.
633 * 1. This function will trigger re-establishment for SRB2 and/or DRB's
635 * @param [in] gCB - Pdcp Instance Control block
636 * @param [in] ueId - UE Identifier
637 * @param [in] cellId - CELL Identifier
638 * @param [in] entCfg - Entity Configuration to be done.
639 * @param [out] entCfm - Entity Configuration cfm.
645 PUBLIC S16 pjCfgReEstUlRb
651 UdxCfmEnt *entDlCfgCfm
654 PUBLIC S16 pjCfgReEstUlRb (gCb, *ueCb, entCfg, entCfm, entDlCfgCfm)
659 UdxCfmEnt *entDlCfgCfm;
662 PjUlRbCb *rbCb = NULLP;
664 TRC3(pjCfgReEstUlRb);
666 RLOG2(L_DEBUG, "Config ReEst Req Received for UL RB -- cellId(%d),ueId(%d)",
667 ueCb->key.cellId, ueCb->key.ueId);
670 PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
672 /* Rb Cb is not present or Rb Cb is not configured for PDCP */
675 RLOG_ARG2(L_ERROR, DBG_UEID, ueCb->key.ueId, "CellId[%u]:RbId[%d] not found",
676 ueCb->key.cellId, entCfg->rbId);
677 /*This RB might be configured at PDCP-DL not at PDCP-UL (Rlc-UM RB with DL direction)*/
678 PJ_MEM_CPY(entCfm, entDlCfgCfm, sizeof(CpjCfmEnt)); /* KW_FIX */
682 /* A Cfm with failure is sent if the re-establishment comes when RBs are not in
684 if (ueCb->libInfo.state != PJ_STATE_REEST )
686 /* Fill entCfm structure with invalid PDCP Id*/
687 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
688 CPJ_CFG_REAS_INVALID_STATE);
689 RLOG_ARG2(L_ERROR, DBG_UEID, ueCb->key.ueId, "CellId[%u]:W/o REEST ,RbId[%d] not reestblshd",
690 ueCb->key.cellId, entCfg->rbId);
694 if(rbCb->rbType == PJ_SRB)
696 pjUlmReEstSrb(gCb,rbCb);
700 ueCb->libInfo.numReEstDrb++;
701 rbCb->state = PJ_STATE_REEST;
703 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
704 rbCb->ulCb.obdCnt = 0;
705 rbCb->ulCb.transCmp = FALSE;
706 if(rbCb->mode == PJ_DRB_AM)
708 rbCb->ulCb.firstReEstCnt = rbCb->ulCb.rxDeliv;
710 #endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */
711 }/* if(rbType == .... */
713 if (entDlCfgCfm->status != CPJ_CFG_CFM_OK)
715 PJ_MEM_CPY(entCfm, entDlCfgCfm,
716 sizeof(CpjCfmEnt)); /* KW_FIX */
726 * This primitive Delete Ue Cb from PDCP/RLC data base.
729 * 1. This primitive Delete the Ue Cb from PDCP/RLC Data base.
731 * @param [in] ueId - UE Identifier
732 * @param [in] cellId - CELL Identifier
733 * @param [in] entCfg - Entity Configuration to be done.
734 * @param [out] entCfm - Entity Confirmation.
740 PUBLIC S16 pjCfgDelUlUe
748 PUBLIC S16 pjCfgDelUlUe (gCb, ueId, cellId, entCfg, entCfm)
762 RLOG2(L_DEBUG, "pjCfgDelUe- Received for -- cellId(%d),ueId(%d)",
763 ueCb->key.cellId, ueCb->key.ueId);
767 ret=pjDbmDelUlUeCb(gCb, ueCb, FALSE);
770 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
780 * This primitive configure the security information of an Ue Cb.
783 * 1. This primitive configure the security information of an Ue Cb.
784 * 2. Initilize the Integrity/Ciphering Channels if required.
786 * @param [in] secCfg - Entity Configuration to be done.
787 * @param [out] secCfm - Entity Configuration Cfm done.
793 PUBLIC S16 pjCfgPrcSecUlCfg
796 CpjSecCfgReqInfo *secCfg,
797 CpjSecCfgCfmInfo *cfgCfm
800 PUBLIC S16 pjCfgPrcSecUlCfg (gCb,secCfg, cfgCfm)
802 CpjSecCfgReqInfo *secCfg;
803 CpjSecCfgCfmInfo *cfgCfm;
809 TRC3(pjCfgPrcSecUlCfg);
815 RLOG2(L_DEBUG, "pjCfgPrcSecCfg- Received for -- cellId(%d),ueId(%d)",
816 secCfg->cellId, secCfg->ueId);
819 ret = pjDbmFetchUlUeCb(gCb, secCfg->ueId, secCfg->cellId, &ueCb);
821 /* Ue Cb is not present */
822 if( ROK != ret || NULLP == ueCb)
824 RLOG_ARG1(L_ERROR, DBG_CELLID, secCfg->cellId,"UeId[%u] not found",
826 /* Fill entCfm structure */
827 PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
828 CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN);
832 ueCb->secInfo.selSecAct= secCfg->secCfg.selSecAct;
834 /* Store Integrity Information */
835 ueCb->secInfo.intInfo.algoType=secCfg->secCfg.integInfo.algoType;
836 cmMemcpy(&ueCb->secInfo.intInfo.intKey[0], &secCfg->secCfg.integInfo.intKey[0], CPJ_INTG_KEY_LEN);
838 /* Store Ciphering Informaiton */
839 ueCb->secInfo.cipherInfo.algoType=secCfg->secCfg.cipherInfo.algoType;
841 cmMemcpy(ueCb->secInfo.cipherInfo.cpKey,
842 &secCfg->secCfg.cipherInfo.ctrlplnKey[0],CPJ_CIPHER_KEY_LEN);
844 cmMemcpy(ueCb->secInfo.cipherInfo.upKey,
845 &secCfg->secCfg.cipherInfo.usrplnKey[0],CPJ_CIPHER_KEY_LEN);
847 /* Security Activation Done */
848 ueCb->secInfo.secAct = TRUE;
850 if(TRUE == secCfg->secCfg.isHo)
852 ueCb->secInfo.firstMsg = FALSE;
856 ueCb->secInfo.firstMsg = TRUE;
859 ueCb->secInfo.secCxt.cellId = secCfg->cellId;
860 ueCb->secInfo.secCxt.ueId = secCfg->ueId;
861 ueCb->secInfo.secCxt.dir = PJ_SEC_DIR_UL;
864 RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId,
865 "Security Paramters stored in UE CB are -- cellId(%d),"
866 " Integrity Algo(%ld), cipherAlgoType(%ld) ",
867 secCfg->cellId, ueCb->secInfo.intInfo.algoType,
868 ueCb->secInfo.cipherInfo.algoType);
870 RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId,
871 "Security Paramters stored in UE CB are -- cellId(%d),"
872 " Integrity Algo(%d), cipherAlgoType(%d) ",
873 secCfg->cellId, ueCb->secInfo.intInfo.algoType,
874 ueCb->secInfo.cipherInfo.algoType);
876 /* Open the Security Channels */
878 if(ueCb->secInfo.secAct)
882 ueCb->secInfo.secCxt.cfgTxId = ueCb->libInfo.nxtAvlbTxId;
885 ret = pjUtlUlIntInit(gCb,ueCb);
887 /* Integrity Init failed */
890 PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
891 CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_INTINIT_FAILED);
896 ret = pjUtlUlCpInit(gCb,ueCb);
897 /* Ciphering Control Plane Init failed */
900 PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
901 CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_CCIPHR_FAILED);
906 ret = pjUtlUlUpInit(gCb,ueCb);
908 /* Ciphering User Plane Init failed */
911 PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
912 CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UCIPHR_FAILED);
918 /* Fill Cfg Cfm with Status OK */
919 PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
920 CPJ_CFG_CFM_OK,CPJ_CFG_REAS_NONE);
923 } /* pjCfgPrcSecCfg */
928 * This primitive changes the ueId of existing Ue Cb.
932 * 1. This function delete the UeCb from hashList. @n
933 * 2. Update the Ue Cb with the new Keys. @n
934 * 3. Insert the UeCb in hash list with new Key. @n
936 * @param [in] ueInfo - Old UE Information
937 * @param [in] newUeInfo - New UE Information
938 * @param [out] status - Status
944 PUBLIC S16 pjCfgUlUeIdChng
948 CpjUeInfo *newUeInfo,
952 PUBLIC S16 pjCfgUlUeIdChng (gCb, ueInfo, newUeInfo, status)
955 CpjUeInfo *newUeInfo;
962 TRC3(pjCfgUlUeIdChng)
967 RLOG2(L_DEBUG, "pjCfgUeIdChng- Recived for -- cellId(%d),ueId(%d)",
968 ueInfo->cellId, ueInfo->ueId);
970 if ( (ueInfo->ueId == newUeInfo->ueId) &&
971 (ueInfo->cellId == newUeInfo->cellId))
973 status->reason = CPJ_CFG_REAS_SAME_UEID;
974 status->status = CPJ_CFG_CFM_NOK;
977 RLOG_ARG3(L_ERROR,DBG_UEID,ueInfo->ueId, "Changing UE Id -- Failed :"
978 "old and New UeId are Same - cellId(%d),newCellId(%d), newUeId(%d)",
979 ueInfo->cellId, newUeInfo->cellId, newUeInfo->ueId);
984 ret = pjDbmFetchUlUeCb(gCb, newUeInfo->ueId, newUeInfo->cellId, &ueCb);
989 RLOG_ARG1(L_ERROR,DBG_UEID,ueInfo->ueId,
990 "Changing Ue ID Failed :New UeId already Exists -- cellId(%d)",
993 status->reason = CPJ_CFG_REAS_SAME_UEID;
994 status->status = CPJ_CFG_CFM_NOK;
998 ret = pjDbmFetchUlUeCb(gCb, ueInfo->ueId, ueInfo->cellId, &ueCb);
1001 RLOG_ARG1(L_ERROR, DBG_CELLID, ueInfo->cellId,"UeId[%u] not found",ueInfo->ueId);
1002 status->reason = CPJ_CFG_REAS_UE_UNKWN;
1003 status->status = CPJ_CFG_CFM_NOK;
1007 ret = cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb);
1012 RLOG_ARG1(L_ERROR,DBG_UEID,ueInfo->ueId, "cmHashListDelete Failed -- cellId(%d)",
1015 status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL;
1016 status->status = CPJ_CFG_CFM_NOK;
1020 /* update the hash key with new values */
1021 ueCb->key.ueId = newUeInfo->ueId;
1022 ueCb->key.cellId = newUeInfo->cellId;
1024 ret = cmHashListInsert(&(gCb->u.ulCb->ueLstCp), (PTR)ueCb,
1025 (U8 *)&(ueCb->key), (U16) sizeof(PjUeKey));
1030 RLOG_ARG2(L_ERROR,DBG_UEID,ueInfo->ueId,
1031 "cmHashListInsert Failed -- cellId(%d),New ueId(%d)",
1032 newUeInfo->cellId, newUeInfo->ueId);
1034 status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL;
1035 status->status = CPJ_CFG_CFM_NOK;
1039 } /* pjCfgUeIdChng */
1044 * This primitive reports the Count informatin of all RBs of an Ue Cb.
1047 * 1. This function reports the count information of all the RBs of an UE.
1049 * @param [in] ueId - UE Identifier
1050 * @param [in] cellId - CELL Identifier
1051 * @param [out] countCfm - Count Information
1057 PUBLIC S16 pjCfgPrcUlCount
1060 CpjCountReqInfo *countReq,
1061 CpjCountCfmInfo *countCfm,
1062 UdxCountCfmInfo *cntCfm
1065 PUBLIC S16 pjCfgPrcUlCount (gCb, countReq, countCfm)
1067 CpjCountReqInfo *countReq;
1068 CpjCountCfmInfo *countCfm;
1069 UdxCountCfmInfo *cntCfm;
1079 TRC3(pjCfgPrcUlCount);
1081 /* Initialization */
1087 numdlRb = cntCfm->numRb;
1089 RLOG2(L_DEBUG, "pjCfgPrcCount - Count Request Received for - cellId(%d),ueId(%d)",
1090 countReq->cellId, countReq->ueId);
1093 ret = pjDbmFetchUlUeCb(gCb, countReq->ueId, countReq->cellId, &ueCb);
1094 countCfm->ueId = countReq->ueId;
1095 countCfm->cellId = countReq->cellId;
1096 countCfm->transId = countReq->transId;
1098 /* Ue Cb is not present */
1099 if( ROK != ret || NULLP == ueCb)
1101 RLOG_ARG1(L_ERROR, DBG_CELLID, countReq->cellId,"UeId[%u] not found",countReq->ueId);
1102 /* Fill entCfm structure */
1103 countCfm->numRb = cntCfm->numRb;
1104 countCfm->status = CPJ_CFG_CFM_NOK;
1105 countCfm->reason = CPJ_CFG_REAS_UE_UNKWN;
1109 /* Loop through all DRBs */
1110 for(idx=0; idx < PJ_MAX_DRB_PER_UE; idx++) /* KW_FIX */
1112 rbCb = ueCb->drbCb[idx];
1113 /* RB is present and configured for PDCP Layer */
1116 for(idx1=0; idx1 < numdlRb; idx1++)
1118 if(rbCb->rbId == countCfm->countInfo[idx1].rbId)
1120 countCfm->countInfo[idx1].ulCount= rbCb->ulCb.rxNext;
1125 countCfm->countInfo[countCfm->numRb].rbId= rbCb->rbId;
1126 countCfm->countInfo[countCfm->numRb].dir = rbCb->dir;
1127 countCfm->countInfo[countCfm->numRb].ulCount= rbCb->ulCb.rxNext;
1128 countCfm->countInfo[countCfm->numRb].dlCount= 0;
1134 countCfm->countInfo[countCfm->numRb].rbId= rbCb->rbId;
1135 countCfm->countInfo[countCfm->numRb].dir = rbCb->dir;
1136 countCfm->countInfo[countCfm->numRb].ulCount= rbCb->ulCb.rxNext;
1137 countCfm->countInfo[countCfm->numRb].dlCount= 0;
1146 /* Fill CountCfm with status and reason */
1149 countCfm->status =CPJ_CFG_CFM_OK;
1150 countCfm->reason =CPJ_CFG_REAS_NONE;
1154 countCfm->status =CPJ_CFG_CFM_NOK;
1155 countCfm->reason =CPJ_CFG_REAS_NO_DRBS;
1160 } /* pjCfgPrcCount */
1164 * This primitive reports SDU status information of all RBs of an Ue Cb.
1167 * 1. This primitive Trigger the Handoff Request procedure
1169 * @param [in] ueId - UE Identifier
1170 * @param [in] cellId - CELL Identifier
1171 * @param [out] sduStaCfm - SDU Status Information
1177 PUBLIC S16 pjCfgPrcUlSduSta
1180 CpjSduStaReqInfo *staReq,
1181 UdxSduStaCfmInfo *staCfm
1184 PUBLIC S16 pjCfgPrcUlSduSta (gCb, staReq, staCfm)
1186 CpjSduStaReqInfo *staReq;
1187 UdxSduStaCfmInfo *staCfm;
1192 CpjSduStaCfmInfo *cfmInfo;
1194 TRC3(pjCfgPrcUlSduSta);
1196 /* Initialization */
1200 RLOG2(L_DEBUG, "pjCfgPrcSduSta - Received for -- cellId(%d),ueId(%d)",
1201 staReq->cellId, staReq->ueId);
1205 ret = pjDbmFetchUlUeCb(gCb, staReq->ueId, staReq->cellId, &ueCb);
1207 /* UeCb is not present */
1208 if( ROK != ret || NULLP == ueCb)
1210 RLOG_ARG1(L_ERROR, DBG_CELLID, staReq->cellId,"UeId[%u] not found",staReq->ueId);
1211 /* Memory leak fix ccpu00135359 */
1213 cpjSap = &gCb->u.ulCb->cpjSap;
1214 if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfmInfo,
1215 sizeof (CpjSduStaCfmInfo)) != ROK)
1217 RLOG0(L_FATAL,"Memory allocation failed");
1221 cfmInfo->ueId = staReq->ueId;
1222 cfmInfo->cellId = staReq->cellId;
1223 cfmInfo->transId = staReq->transId;
1224 cfmInfo->status = CPJ_CFG_CFM_NOK;
1225 cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN;
1227 /* Caller should return cfm with failure */
1228 RLOG_ARG1(L_DEBUG,DBG_UEID,staReq->ueId, "UE Cb is not found -- cellId(%d)",
1231 /* Send Failure SduStaCfm */
1232 PjUiCpjSduStaCfm(&gCb->u.ulCb->cpjSap.pst,
1233 gCb->u.ulCb->cpjSap.suId, cfmInfo);
1239 /* Call Ho Start handler for this UE */
1240 pjUtlUlReEstHO(gCb, ueCb);
1242 ueCb->hoInfo->transId = staReq->transId;
1243 ueCb->hoInfo->staCfm = staCfm;
1245 if (ueCb->libInfo.numReEstCmp > 0)
1247 if (ueCb->libInfo.numReEstCmp > ueCb->libInfo.numReEstDrb)
1250 ueCb->libInfo.numReEstDrb = 0;
1251 ueCb->libInfo.numReEstCmp = 0;
1255 ueCb->libInfo.numReEstDrb -= ueCb->libInfo.numReEstCmp;
1256 ueCb->libInfo.numReEstCmp = 0;
1260 if (ueCb->libInfo.numReEstDrb == 0)
1262 pjUtlUlSndSduStaCfm(gCb,ueCb);
1266 } /* pjCfgPrcSduSta */
1272 * This primitive to update the ROHC Comp details in PJRB Cb.
1275 * 1. This primitive to update the ROHC comp detils in PJRB Cb.
1277 * @param [in] pjRbCb - RB Control Block
1278 * @param [in] ueCb - Ue Control Block
1279 * @param [in] hdrCompCfg- Comp Cfg Information
1285 PRIVATE S16 pjCfgUpdUlCompInfo
1290 CpjHdrCompCfg *rohcCfg
1293 PRIVATE S16 pjCfgUpdUlCompInfo(gCb, rbCb, ueCb, rohcCfg)
1297 CpjHdrCompCfg *rohcCfg;
1304 TRC3(pjCfgUpdUlCompInfo);
1306 /* Initialization */
1311 RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Received for -- cellId(%d),RbId(%d)",
1312 rbCb->rbId, ueCb->key.ueId);
1314 /* Header Compresion information present */
1315 if(rohcCfg->hdrCompUsed)
1317 /* Header Compression is enabled */
1318 rbCb->rohc.hdrCmpUsed = TRUE;
1320 /* User Can Configure multipel profiles. Maximum profile ID should be used */
1321 for(; idx<CPJ_MAX_ROHC_PROF_LIST; idx++)
1323 if((rohcCfg->rohcInfo.profLst[idx] )&&
1324 (profId < rohcProfId[idx]))
1325 profId = rohcProfId[idx];
1330 /* Header Compression is disabled */
1331 rbCb->rohc.hdrCmpUsed = FALSE;
1335 /* Store the profile Id and MaxCid */
1337 rbCb->rohc.profId = profId;
1338 rbCb->rohc.maxCid = rohcCfg->rohcInfo.maxCid;
1340 /* Store the ue Details in Compressor Context */
1341 rbCb->cmpCxt.ueId = ueCb->key.ueId;
1342 rbCb->cmpCxt.cellId = ueCb->key.cellId;
1343 rbCb->cmpCxt.rbId = rbCb->rbId;
1344 rbCb->cmpCxt.rbType = rbCb->rbType;
1346 RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Selected -- profId(%d),maxCid(%d)",
1347 rbCb->rohc.profId, rbCb->rohc.maxCid);
1351 if(rbCb->rohc.hdrCmpUsed)
1353 ret=pjUtlUlCmpInit(gCb, rbCb);
1357 } /* pjCfgUpdCompInfo */
1362 * This primitive to delete RB from Ue Cb.
1365 * 1. To delete the PJRB Cb from UeCb.
1367 * @param [in] ueCb - Ue Control Block
1368 * @param [in] rbCb - Rb Control Block
1374 PUBLIC S16 pjCfgDelPjUlRbCb
1381 PUBLIC S16 pjCfgDelPjUlRbCb(gCb,ueCb,rbCb)
1388 /* kw005.201 added support for L2 measurement */
1389 #ifdef LTE_L2_MEAS_COMMENT
1393 TRC3(pjCfgDelPjUlRbCb);
1395 /* Initialization */
1398 RLOG0(L_DEBUG,"pjCfgDelPjRBCb- Recieved -- rbId() CfgState() ");
1400 /* RbCb is present and Configured for PDCP */
1403 RLOG1(L_DEBUG, "pjCfgDelPjRBCb- Received for -- rbId (%d)",
1407 /* This should be done for every counter added for UL */
1408 if((rbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS] != NULLP) &&
1409 (rbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->totDrbsPerQci > 0))
1411 rbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->totDrbsPerQci--;
1414 Bool tmrRunning = pjChkTmr(gCb,(PTR)rbCb,PJ_EVT_UL_REORD_TMR);
1417 pjStopTmr(gCb,(PTR)rbCb, PJ_EVT_UL_REORD_TMR);
1423 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
1424 /* Stop off board timers */
1426 if(PJ_DIR_UL & rbCb->dir)
1427 if(rbCb->ulCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR)
1429 pjStopTmr(gCb, (PTR)&rbCb, PJ_EVT_UL_OBD_TMR);
1433 /* Deinit Rx Buffers */
1434 pjDbmRxDeInit(gCb,&rbCb->ulCb.recBuf);
1435 pjUtlEmptyUlPktList(gCb, rbCb);
1437 /* Close the Comp channels */
1438 if (PJ_SRB == rbCb->rbType)
1442 else if (PJ_DRB == rbCb->rbType)
1445 if (rbCb->rohc.hdrCmpUsed)
1447 pjUtlCmpClose(gCb,rbCb->cmpCxtId);
1451 pjDbmDelUlRbCb(gCb,rbCb->rbId, rbCb->rbType, &rbCb, PJ_CFG_PDCP, ueCb);
1455 } /* pjCfgDelPjRBCb */
1460 * Handler to process the re-establishment Request for SRB1 during
1461 * RRC Re-Establishment request.
1464 * 1. This primitive is used to re-establish SRB1 only during RRC Re-establishment
1465 * 2. New Security Algo will applied
1467 * @param [in] reEstReq - Entity Configuration to be done.
1468 * @param [out] reEstCfm - Entity Configuration cfm.
1474 PUBLIC S16 pjCfgUlReEstReq
1477 CpjReEstReqInfo *reEstReq,
1478 CpjReEstCfmInfo *reEstCfm
1481 PUBLIC S16 pjCfgUlReEstReq (gCb, reEstReq, reEstCfm)
1483 CpjReEstReqInfo *reEstReq;
1484 CpjReEstCfmInfo *reEstCfm;
1492 TRC3(pjCfgUlReEstReq);
1494 /* Initialization */
1496 rlcId.ueId = reEstReq->pdcpId.ueId;
1497 rlcId.cellId = reEstReq->pdcpId.cellId;
1498 rlcId.rbId = reEstReq->pdcpId.rbId;
1499 rlcId.rbType = reEstReq->pdcpId.rbType;
1501 RLOG2(L_DEBUG, "pjCfgReEstReq- Received for -- cellId(%d),ueId(%d)",
1502 rlcId.cellId, rlcId.ueId);
1504 ret = pjDbmFetchUlRbCb(gCb, rlcId,&rbCb);
1507 /* Ue Cb is not present */
1508 if( ROK != ret || NULLP == rbCb)
1510 RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:RbId[%d] not found",
1511 rlcId.cellId, rlcId.rbId);
1512 /* Fill entCfm structure */
1513 PJ_CFG_FILL_REESTREQ_CFM(reEstCfm, rlcId.ueId,rlcId.cellId,
1514 reEstReq->transId, LCM_PRIM_NOK);
1520 /* Copy Security Information */
1521 cmMemcpy(&ueCb->secInfo.intInfo.intKey[0], &reEstReq->intKey[0], PJ_INTG_KEY_LEN);
1522 cmMemcpy(&ueCb->secInfo.cipherInfo.cpKey[0], &reEstReq->ctrlplnKey[0], PJ_CIPHER_KEY_LEN);
1523 cmMemcpy(&ueCb->secInfo.cipherInfo.upKey[0], &reEstReq->usrplnKey[0], PJ_CIPHER_KEY_LEN);
1525 /* Mark Security Action Done */
1526 ueCb->secInfo.secAct = TRUE;
1528 reEstCfm->transId = reEstReq->transId;
1529 reEstCfm->ueId = reEstReq->pdcpId.ueId;
1530 reEstCfm->cellId = reEstReq->pdcpId.cellId;
1532 /* Save the information */
1534 pjUtlUlSaveCfmInfo(gCb,rbCb->ueCb, PJ_REEST_ASYNC_CFM, FALSE, ENTPJ,
1535 (PTR)reEstCfm, NULLP);
1536 PJ_FREE(gCb,reEstCfm, sizeof(CpjReEstCfmInfo));
1537 #endif /* PJ_SEC_ASYNC */
1539 /* Call ReEst for SRB1 */
1540 pjUtlUlReEstSrb1(gCb,rbCb);
1543 } /* pjCfgReEstReq */
1548 * Handler to add measCb to rbCb.
1551 * Handler to add measCb to rbCb.
1557 PRIVATE S16 pjAddToUlL2Meas(PjCb *tPjCb, PjUlRbCb *pjRbCb,U8 cellId, U16 ueId)
1561 RLOG1(L_DEBUG, "L2_MEAS_ADD Adding UE ueid %d ", ueId);
1563 for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++)
1565 PjL2MeasCb *measCb = &tPjCb->u.ulCb->pjL2Cb.pjL2EvtCb[cntr].measCb;
1567 if (measCb->measType & LPJ_L2MEAS_UL_LOSS)
1569 pjUtlPlcMeasDatInUlL2Sts(&measCb->measData[pjRbCb->qci],
1570 &pjRbCb->rbL2Cb, measCb->measType);
1571 measCb->qci[pjRbCb->qci] = pjRbCb->qci;
1572 measCb->measData[pjRbCb->qci].totDrbsPerQci++;
1577 }/*pjAddToDlL2Meas*/
1582 /********************************************************************30**
1585 **********************************************************************/