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
36 *********************************************************************21*/
37 static const char* RLOG_MODULE_NAME="PDCP";
38 static int RLOG_MODULE_ID=1024;
39 static int RLOG_FILE_ID=212;
41 @brief LTE PDCP Configuration Module
45 /* header (.h) include files */
46 #include "envopt.h" /* environment options */
47 #include "envdep.h" /* environment dependent */
48 #include "envind.h" /* environment independent */
50 #include "gen.h" /* general */
51 #include "ssi.h" /* system services interface */
52 #include "cm5.h" /* Timer Functions */
53 #include "cm_lte.h" /* common LTE header file */
54 #include "cm_hash.h" /* common hash module file */
55 #include "cm_llist.h" /* common list header file */
56 #include "cpj.h" /* RRC layer */
57 #include "pju.h" /* PDCP service user */
58 #include "lpj.h" /* RRC layer */
59 #include "pj_env.h" /* RLC environment options */
60 #include "pj.h" /* RLC layer */
67 /* header/extern include files (.x) */
69 #include "gen.x" /* general */
70 #include "ssi.x" /* system services interface */
71 #include "cm_lib.x" /* common library */
72 #include "cm5.x" /* Timer Functions */
73 #include "cm_hash.x" /* common hash module */
74 #include "cm_lte.x" /* common LTE file */
75 #include "cm_llist.x" /* common list header file */
76 #include "cpj.x" /* RRC layer */
77 #include "pju.x" /* PDCP service user */
78 #include "lpj.x" /* LM Interface */
79 #include "pj.x" /* RLC layer */
83 /* Proto types declarations for local functions */
85 PRIVATE S16 pjCfgFillPjDlRbCb ARGS ((
94 PRIVATE S16 pjCfgUpdDlCompInfo ARGS ((
98 UdxHdrCompCfg *rohcCfg
102 PRIVATE S16 pjAddToDlL2Meas ARGS ((
109 /* Store the Profile ID into array index */
110 /* RRC is not sending the profile id directly. It will give
111 the for all the profiles with True/False. PDCP will derive the profile
112 based on this profile Id list */
114 PRIVATE U16 rohcProfId[CPJ_MAX_ROHC_PROF_LIST]= { 0x0001, 0x0002, 0x0003, 0x0004,
115 0x0006, 0x0101, 0x0102, 0x0103,
117 /** @addtogroup cfgdata */
122 * Hanlder to process the configuration recieved from the upper layer and update the pdcp
126 * 1. This function create a new PDCP RB Cb. @n
127 * 2. Newly created PDCP RB Cb will be placed in Data base with the configuration
128 * informtion received. @n
129 * 3. Return Success or Failure to the caller with reason and status
132 * @param [in] ueId - UE Identifier
133 * @param [in] cellId - CELL Identifier
134 * @param [in] entCfg - Entity Configuration to be done.
135 * @param [out] entCfm - Entity Confirmation.
140 PUBLIC S16 pjCfgAddDlRb
151 PUBLIC S16 pjCfgAddDlRb (gCb, ueId, cellId,isHo, entCfg, ueCb, entCfm)
162 PjDlRbCb *rbCb; /* Rb Cb Pointer */
169 RLOG2(L_DEBUG, "pjCfgAddRb- Received with -- cellId(%d),ueId(%d)",
174 /* Ue Cb is not present, Create Ue Cb */
175 if ( pjDbmCreateDlUeCb(gCb, ueId, cellId, ueCb) != ROK)
177 /* Ue Cb allocation failed */
178 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
179 CPJ_CFG_REAS_UE_CREAT_FAIL);
181 RLOG_ARG1(L_ERROR,DBG_UEID,ueId, "CellId[%d] Creating DL UeCb Failed",
187 (*ueCb)->inst = gCb->init.inst;
189 /* Rb Id is allowed range or not */
190 PJ_VALIDATE_RBID(ueId, entCfg->rbId, entCfg->rbType, ret);
193 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
194 CPJ_CFG_REAS_INVALID_RBID);
196 RLOG_ARG2(L_ERROR,DBG_UEID,ueId, "CellId[%u]:RbId[%d] - "
197 "Invalid RB ID,RbCb Creation Failed ", cellId, entCfg->rbId);
201 /* Find Rb Cb already exist or not */
202 PJ_DBM_FETCH_DL_RBCB(entCfg->rbId, entCfg->rbType, (*ueCb), rbCb);
205 RLOG_ARG2(L_WARNING, DBG_UEID,ueId, "CellId [%u]:RbId[%d] already exists",
206 cellId,entCfg->rbId);
207 /* Rb Cb already exist for pdpcp */
208 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
209 CPJ_CFG_REAS_SAME_RBID);
211 RLOG_ARG2(L_ERROR,DBG_UEID,ueId, "RB Id already present-- cellId(%d), rbId(%d)",
212 cellId, entCfg->rbId);
215 else if (NULLP == rbCb)
217 /* Create Rb Cb and place in Ue Cb */
218 rbCb = pjDbmCreateDlRbCb(gCb, entCfg->rbId, entCfg->rbType, *ueCb, PJ_CFG_PDCP);
221 /* Create Rb Cb Failed*/
222 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
223 CPJ_CFG_REAS_ENT_CREAT_FAIL);
225 RLOG_ARG2(L_ERROR,DBG_UEID,ueId, "Failed to Create RB CB -- cellId(%d) rbId(%d)",
226 cellId, entCfg->rbId);
231 /* Copy the Recived information into RbCb */
232 ret = pjCfgFillPjDlRbCb(gCb, rbCb, *ueCb,isHo, entCfg , entCfm);
234 /* Fill the Cfm status and Reason */
235 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
244 * Hanlder to update the PJRB with the received infromation during
245 * configuration or re configuration.
248 * 1. update the data base with the new configuration informtion received. @n
249 * 2. update the data base with the new re-configuration informtion received. @n
250 * 3. If required Initiliaze the tx/rx Buffers and Timers. @n
251 * 4. Return Success or Failure to the caller with reason and status
254 * @param [out] rbCb - RB Control Block
255 * @param [out] entCfm - PDCP Entiry Confirmation
256 * @param [in] ueCb - UE Control Block
257 * @param [in] entCfg - PDCP Entity Configuration
262 PRIVATE S16 pjCfgFillPjDlRbCb
272 PRIVATE S16 pjCfgFillPjDlRbCb(gCb, pjRbCb, ueCb,isHo, cfgEnt, cfmEnt)
281 S16 tmrVal; /* Timer Value */
282 /* kw005.201 added support for L2 measurement */
283 TRC3(pjCfgFillPjDlRbCb);
288 RLOG_ARG3(L_DEBUG,DBG_UEID,ueCb->key.ueId, "Received Fill Req cellId(%d), rbId(%d),cfgType(%d)",
290 cfgEnt->rbId, cfgEnt->cfgType);
292 switch (cfgEnt->cfgType)
294 /* Cfg Type received as ADD RB */
297 pjRbCb->state = PJ_STATE_NORMAL;
298 pjRbCb->rbId = cfgEnt->rbId;
299 pjRbCb->rbType = cfgEnt->rbType;
300 pjRbCb->mode = cfgEnt->m.addCfg.rlcInfo.mode;
301 pjRbCb->dir = cfgEnt->m.addCfg.rlcInfo.dir;
304 if(PJ_SRB == pjRbCb->rbType)
306 /* SN length is fixed for SRB */
307 pjRbCb->snLen = PJ_SRB_SN_LEN;
312 if (CM_LTE_MODE_UM == pjRbCb->mode)
314 /* SN length can be 12 bit or 18 bit in UM mode */
315 pjRbCb->snLen = cfgEnt->m.addCfg.rlcInfo.m.rlcUm.pdcpSNSize;
316 #ifdef NR_PDCP_DRB_SN_18_BIT
317 pjRbCb->snLen = PJ_18_BIT_SN;
319 pjRbCb->snLen = PJ_12_BIT_SN;
324 /* SN length can be 12/18 bit for AM mode */
325 pjRbCb->snLen = cfgEnt->m.addCfg.rlcInfo.m.rlcAm.pdcpSNSize;
326 #ifdef NR_PDCP_DRB_SN_18_BIT
327 pjRbCb->snLen = PJ_18_BIT_SN;
329 pjRbCb->snLen = PJ_12_BIT_SN;
333 pjRbCb->state = PJ_STATE_HO;
338 pjRbCb->maxTxSn = (1 << pjRbCb->snLen);
339 /* Initialize all off board timers */
340 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
341 cmInitTimers(&pjRbCb->dlCb.obdTmr,PJ_RB_MAX_TIMERS);
344 RLOG_ARG2(L_DEBUG,DBG_UEID,ueCb->key.ueId,
345 "Received RB Req with -- Dir(%d), mode(%d)",
346 pjRbCb->dir, pjRbCb->mode);
349 if (PJ_DIR_DL & pjRbCb->dir)
351 pjRbCb->dlCb.discTmrInt = cfgEnt->m.addCfg.discardTmr;
352 pjRbCb->dlCb.cfmReqd = cfgEnt->m.addCfg.cfmReqd;
353 /* pjRbCb->dlCb.count = 0xffffffff; */
355 /* Discard Timer is Enabled */
356 if(pjRbCb->dlCb.discTmrInt > 0 )
358 cmInitTimers(&pjRbCb->dlCb.discTmr,PJ_RB_MAX_TIMERS);
359 /* 1. The discTmr value is absolute value in ms units
360 2. Store the DiscardTmr value in terms of Layer resolution
361 ie discTmrVal = dicTrmVal/(SS_TICKS*Layer Resolution)
362 and round to next integer value.
364 tmrVal = (S16)(pjRbCb->dlCb.discTmrInt % (SS_TICKS_SEC
365 * gCb->pjGenCfg.timeRes)); /*KW_FIX*/
366 pjRbCb->dlCb.discTmrInt = (S16)(pjRbCb->dlCb.discTmrInt /
367 (SS_TICKS_SEC * gCb->pjGenCfg.timeRes));
369 pjRbCb->dlCb.discTmrInt +=1; /* Round to next integer value if
373 /*Initialization for Tx Buf */
374 gCb->pjGenCfg.nmbDlBins = PJ_MAX_HASH_BINS;
375 pjDbmDlBufInit(gCb, &pjRbCb->dlCb.txBuf,gCb->pjGenCfg.nmbDlBins);
376 cmLListInit(&pjRbCb->dlCb.dlPktQ);
379 /* Update the Compressor Informatio in Rb Cb */
380 if(cfgEnt->rbType == CM_LTE_DRB)
382 pjCfgUpdDlCompInfo(gCb, pjRbCb, ueCb,&(cfgEnt->m.addCfg.hdrCompCfg));
383 /* kw005.201 added support for L2 measurement */
385 pjRbCb->qci = cfgEnt->m.addCfg.qci;
386 pjAddToDlL2Meas(gCb,pjRbCb,
387 ueCb->key.cellId,ueCb->key.ueId);
394 /* Cfg Type received as Modify RB */
397 if(CPJ_RECFG_CFMREQ & cfgEnt->m.modCfg.bitFlag)
398 pjRbCb->dlCb.cfmReqd = cfgEnt->m.modCfg.cfmReqd;
400 /* Header Compression profile has been modified */
402 if(TRUE == cfgEnt->m.modCfg.hdrCompCfg.hdrCompUsed)
404 /* Close All the channels */
405 pjUtlDlCmpReset(gCb, pjRbCb);
406 pjCfgUpdDlCompInfo(gCb, pjRbCb, ueCb, &cfgEnt->m.modCfg.hdrCompCfg);
409 /* In case of Hand off scenario: At Target eNode-B,
410 Handoff information will send in re-cfg req */
412 if(TRUE & cfgEnt->m.modCfg.hoInfo.isHoPres)
414 /* Store the HO information and call for Status Report
416 if(CPJ_HO_DL & cfgEnt->m.modCfg.hoInfo.isHoPres)
418 pjRbCb->dlCb.count = cfgEnt->m.modCfg.hoInfo.dlCount - 1;
419 if (pjRbCb->snLen != cfgEnt->m.modCfg.hoInfo.snLen)
421 pjRbCb->snLen = cfgEnt->m.modCfg.hoInfo.snLen;
424 pjDlmProcessDlPktQ(gCb, pjRbCb);
425 pjRbCb->state = PJ_STATE_NORMAL;
431 /* Un Expected cfg type */
434 RLOG_ARG1(L_ERROR,DBG_CELLID, ueCb->key.cellId,
435 "pjCfgFillRbCb Failed -- for the invalid cfgType(%d)",
440 } /* pjCfgFillPjRbCb */
447 * Hanlder to process the re-configuration for existing PJRB from the upper
451 * 1. This function fetch the PJRB from pdcp data base. @n
452 * 2. update the data base with the new configuration informtion received. @n
453 * 3. Return Success or Failure to the caller with reason and status
456 * @param [in] gCb - PDCP Instance Control block
457 * @param [in] ueId - UE Identifier
458 * @param [in] cellId - CELL Identifier
459 * @param [in] entCfg - Entity Configuration to be done.
460 * @param [out] entCfm - Entity Confirmation.
466 PUBLIC S16 pjCfgReCfgDlRb
474 PUBLIC S16 pjCfgReCfgDlRb (gCb,ueCb, entCfg, entCfm)
482 PjDlRbCb *rbCb; /* Rb Cb */
484 TRC3(pjCfgReCfgDlRb);
489 RLOG2(L_DEBUG, "pjCfgReCfgRb - Received for -- cellId(%d),ueId(%d)",
490 ueCb->key.cellId, ueCb->key.ueId);
493 PJ_DBM_FETCH_DL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
494 /* Rb Cb is not present or Rb Cb is not configured for PDCP */
497 RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId [%u]:RbId[%d] already exists",
498 ueCb->key.cellId,entCfg->rbId);
499 /* Fill entCfm structure */
500 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
501 CPJ_CFG_REAS_PDCPID_UNKWN);
503 RLOG_ARG2(L_ERROR,DBG_UEID,ueCb->key.ueId,
504 "RB Cb is not present -- cellId(%d), rbId(%d)",
505 ueCb->key.cellId, entCfg->rbId);
509 /* Copy the received infromation in to Rb Cb */
510 ret = pjCfgFillPjDlRbCb(gCb, rbCb, ueCb,FALSE, entCfg , entCfm);
512 /* Fill the Cfm status and Reason */
513 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
523 * This function deletes the existing RB(PDCP and RLC) from Ue Cb.
526 * 1. Stop the timers and deallocate tx/rx Buffs for PJRB CB. @n
527 * 2. Delete the existing RB Cb(PDCP and RLC) from Ue Cb. @n
529 * @param [in] ueId - UE Identifier
530 * @param [in] cellId - CELL Identifier
531 * @param [in] entCfg - Entity Configuration to be done.
532 * @param [out] entCfm - Entity Confirmation.
538 PUBLIC S16 pjCfgDelDlRb
546 PUBLIC S16 pjCfgDelDlRb (gCb, ueCb, entCfg, entCfm)
554 PjDlRbCb *rbCb; /* Rb Cb */
561 RLOG2(L_DEBUG, "pjCfgDelRb- Received for -- cellId(%d),ueId(%d)",
562 ueCb->key.cellId,ueCb->key.ueId);
565 PJ_DBM_FETCH_DL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
567 /* RB Cb is not present or not configured for PDCP */
570 RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId [%u]:RbId[%d] already exists",
571 ueCb->key.cellId,entCfg->rbId);
572 /* Fill entCfm structure with invalid pdcp Id */
573 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
574 CPJ_CFG_REAS_INVALID_PDCPID);
576 RLOG_ARG2(L_ERROR,DBG_UEID,ueCb->key.ueId,
577 "RB Cb is not found, Deletion Failed -- cellId(%d), rbId(%d)",
578 ueCb->key.cellId, entCfg->rbId);
581 /* Delete PDCP Related infromation from RB CB */
582 ret= pjCfgDelPjDlRbCb(gCb, ueCb, rbCb);
586 /* Fill entCfm structure with invalid pdcp Id */
587 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
588 CPJ_CFG_REAS_INVALID_PDCPID);
590 RLOG_ARG2(L_ERROR,DBG_UEID,ueCb->key.ueId,
591 "RB Cb Deletion Failed -- cellId(%d), rbId(%d)",
592 ueCb->key.cellId, entCfg->rbId);
595 rbCb->pktAdmitCnt= 0;
596 /* Fill the Cfm status and Reason */
597 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
610 * This primitive is used to re-establish downlink SRB2 and/or DRB'S during RRC connection
611 * re-configuration procedure.
614 * 1. This function will trigger re-establishment for SRB2 and/or DRB's
616 * @param [in] gCb - PDCP Instance Control block
617 * @param [in] ueId - UE Identifier
618 * @param [in] cellId - CELL Identifier
619 * @param [in] entCfg - Entity Configuration to be done.
620 * @param [out] entCfm - Entity Configuration cfm.
626 PUBLIC S16 pjCfgReEstDlRb
634 PUBLIC S16 pjCfgReEstDlRb (gCb,ueCb, entCfg, entCfm)
642 PjDlRbCb *rbCb; /* Rb Cb */
644 TRC3(pjCfgReEstDlRb);
649 RLOG2(L_DEBUG, "pjCfgReEstRb- Received for -- cellId(%d),ueId(%d)",
650 ueCb->key.cellId, ueCb->key.ueId);
653 PJ_DBM_FETCH_DL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
654 /* Rb Cb is not present or Rb Cb is not configured for PDCP */
657 RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId [%u]:RbId[%d] already exists",
658 ueCb->key.cellId,entCfg->rbId);
659 /* Fill entCfm structure with invalid PDCP Id*/
660 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
661 CPJ_CFG_REAS_PDCPID_UNKWN);
663 RLOG_ARG1(L_ERROR,DBG_UEID,ueCb->key.ueId,
664 "Re-Est Failed : DL RB CB is not present -- cellId(%d)",
670 /* A Cfm with failure is sent if the re-establishment comes when RBs are not in
672 if (ueCb->libInfo.state != PJ_STATE_REEST )
674 /* Fill entCfm structure with invalid PDCP Id*/
675 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
676 CPJ_CFG_REAS_INVALID_STATE);
678 RLOG_ARG1(L_ERROR,DBG_UEID,ueCb->key.ueId,
679 "Re-Est Failed : RB State is Not REEST -- cellId(%d)",
684 /* 5. Call the respective reestablishment functions for SRB */
685 if(rbCb->rbType == PJ_SRB)
687 pjDlmReEstSrb(gCb,rbCb);
691 /* During Re-Establishment DL RAB state is assumed to be in PJ_STATE_NORMAL
692 * and the Status Report is sent only if this is the state.
693 * But if the Reestablishment happens during HO(PJ_STATE_REEST_HO)
694 * due to the state change during HO no Status Report is sent after successful
697 rbCb->state = PJ_STATE_NORMAL;
698 rbCb->pktAdmitCnt = 0;
699 if (rbCb->mode == PJ_DRB_UM)
701 pjDlmReEstDrbUm(gCb,rbCb);
705 pjDlmReEstDrbAm(gCb,rbCb);
707 }/* if(rbType == .... */
716 * This primitive Delete Ue Cb from PDCP/RLC data base.
719 * 1. This primitive Delete the Ue Cb from PDCP/RLC Data base.
721 * @param [in] ueId - UE Identifier
722 * @param [in] cellId - CELL Identifier
723 * @param [in] entCfg - Entity Configuration to be done.
724 * @param [out] entCfm - Entity Confirmation.
730 PUBLIC S16 pjCfgDelDlUe
738 PUBLIC S16 pjCfgDelDlUe (gCb, ueCb, entCfg, entCfm)
747 RLOG_ARG1(L_DEBUG,DBG_UEID,ueCb->key.ueId,
748 "pjCfgDelUe- Received for -- cellId(%d)",
752 pjDbmDelDlUeCb(gCb, ueCb, FALSE);
755 PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
764 * This primitive configure the security information of an Ue Cb.
767 * 1. This primitive configure the security information of an Ue Cb.
768 * 2. Initilize the Integrity/Ciphering Channels if required.
770 * @param [in] secCfg - Entity Configuration to be done.
771 * @param [out] secCfm - Entity Configuration Cfm done.
777 PUBLIC S16 pjCfgPrcSecDlCfg
780 UdxSecCfgReqInfo *secCfg,
781 UdxSecCfgCfmInfo *cfgCfm
784 PUBLIC S16 pjCfgPrcSecDlCfg (gCb, secCfg, cfgCfm)
786 UdxSecCfgReqInfo *secCfg;
787 UdxSecCfgCfmInfo *cfgCfm;
793 TRC3(pjCfgPrcSecDlCfg);
799 RLOG2(L_DEBUG, "pjCfgPrcSecCfg- Received for -- cellId(%d),ueId(%d)",
800 secCfg->cellId, secCfg->ueId);
803 ret = pjDbmFetchDlUeCb(gCb, secCfg->ueId, secCfg->cellId, &ueCb);
805 /* Ue Cb is not present */
806 if( ROK != ret || NULLP == ueCb)
808 RLOG_ARG1(L_ERROR, DBG_CELLID, secCfg->cellId,"UeId[%u] not found",
810 /* Fill entCfm structure */
811 PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
812 CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN);
816 ueCb->secInfo.selSecAct= secCfg->secCfg.selSecAct;
818 /* Store Integrity Information */
819 ueCb->secInfo.intInfo.algoType=secCfg->secCfg.integInfo.algoType;
820 cmMemcpy(&ueCb->secInfo.intInfo.intKey[0], &secCfg->secCfg.integInfo.intKey[0], CPJ_INTG_KEY_LEN);
822 /* Store Ciphering Informaiton */
823 ueCb->secInfo.cipherInfo.algoType=secCfg->secCfg.cipherInfo.algoType;
825 cmMemcpy(ueCb->secInfo.cipherInfo.cpKey,
826 &secCfg->secCfg.cipherInfo.ctrlplnKey[0],CPJ_CIPHER_KEY_LEN);
828 cmMemcpy(ueCb->secInfo.cipherInfo.upKey,
829 &secCfg->secCfg.cipherInfo.usrplnKey[0],CPJ_CIPHER_KEY_LEN);
831 /* Security Activation Done */
832 ueCb->secInfo.secAct = TRUE;
834 if(TRUE == secCfg->secCfg.isHo)
836 ueCb->secInfo.firstMsg = FALSE;
840 ueCb->secInfo.firstMsg = TRUE;
843 ueCb->secInfo.secCxt.cellId = secCfg->cellId;
844 ueCb->secInfo.secCxt.ueId = secCfg->ueId;
845 ueCb->secInfo.secCxt.dir = PJ_SEC_DIR_DL;
848 RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId,
849 "Security Paramters stored in UE CB are -- cellId(%d)"
850 "Integrity Algo(%ld), cipherAlgoType(%ld) ",
851 secCfg->cellId, ueCb->secInfo.intInfo.algoType,
852 ueCb->secInfo.cipherInfo.algoType);
854 RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId,
855 "Security Paramters stored in UE CB are -- cellId(%d)"
856 "Integrity Algo(%d), cipherAlgoType(%d) ",
857 secCfg->cellId, ueCb->secInfo.intInfo.algoType,
858 ueCb->secInfo.cipherInfo.algoType);
860 /* Open the Security Channels */
862 if(ueCb->secInfo.secAct)
866 ueCb->secInfo.secCxt.cfgTxId = ueCb->libInfo.nxtAvlbTxId;
869 ret = pjUtlDlIntInit(gCb, ueCb);
871 /* Integrity Init failed */
874 PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
875 CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_INTINIT_FAILED);
880 ret = pjUtlDlCpInit(gCb, ueCb);
881 /* Ciphering Control Plane Init failed */
884 PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
885 CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_CCIPHR_FAILED);
890 ret = pjUtlDlUpInit(gCb, ueCb);
892 /* Ciphering User Plane Init failed */
895 PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
896 CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UCIPHR_FAILED);
902 /* Fill Cfg Cfm with Status OK */
903 PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
904 CPJ_CFG_CFM_OK,CPJ_CFG_REAS_NONE);
907 } /* pjCfgPrcSecCfg */
912 * This primitive changes the ueId of existing Ue Cb.
916 * 1. This function delete the UeCb from hashList. @n
917 * 2. Update the Ue Cb with the new Keys. @n
918 * 3. Insert the UeCb in hash list with new Key. @n
920 * @param [in] ueInfo - Old UE Information
921 * @param [in] newUeInfo - New UE Information
922 * @param [out] status - Status
928 PUBLIC S16 pjCfgDlUeIdChng
932 UdxUeInfo *newUeInfo,
936 PUBLIC S16 pjCfgDlUeIdChng (gCb, ueInfo, newUeInfo, status)
939 UdxUeInfo *newUeInfo;
946 TRC3(pjCfgDlUeIdChng)
951 RLOG2(L_DEBUG, "pjCfgUeIdChng- Recived for -- cellId(%d),ueId(%d)",
952 ueInfo->cellId, ueInfo->ueId);
954 if ( (ueInfo->ueId == newUeInfo->ueId) &&
955 (ueInfo->cellId == newUeInfo->cellId))
957 status->reason = CPJ_CFG_REAS_SAME_UEID;
958 status->status = CPJ_CFG_CFM_NOK;
959 RLOG_ARG2(L_ERROR,DBG_CELLID,ueInfo->cellId,"Old UeId[%d] same as new UeId[%d]",
960 ueInfo->ueId,newUeInfo->ueId);
964 ret = pjDbmFetchDlUeCb(gCb, newUeInfo->ueId, newUeInfo->cellId, &ueCb);
967 RLOG_ARG1(L_ERROR, DBG_CELLID, newUeInfo->cellId, "NewUeId[%d]:ueCb already exists",
969 status->reason = CPJ_CFG_REAS_SAME_UEID;
970 status->status = CPJ_CFG_CFM_NOK;
974 ret = pjDbmFetchDlUeCb(gCb, ueInfo->ueId, ueInfo->cellId, &ueCb);
977 RLOG_ARG1(L_ERROR,DBG_CELLID,ueInfo->cellId,"UeId [%d]: UeCb not found",
979 status->reason = CPJ_CFG_REAS_UE_UNKWN;
980 status->status = CPJ_CFG_CFM_NOK;
984 ret = cmHashListDelete(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb);
987 RLOG_ARG1(L_ERROR,DBG_CELLID,ueInfo->cellId,"UeId[%u] HashList Deletion Failed",
989 status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL;
990 status->status = CPJ_CFG_CFM_NOK;
994 /* update the hash key with new values */
995 ueCb->key.ueId = newUeInfo->ueId;
996 ueCb->key.cellId = newUeInfo->cellId;
998 ret = cmHashListInsert(&(gCb->u.dlCb->ueLstCp), (PTR)ueCb,
999 (U8 *)&(ueCb->key), (U16) sizeof(PjUeKey));
1003 RLOG_ARG1(L_ERROR,DBG_CELLID,newUeInfo->cellId,"UeId[%u] HashList Insertion Failed",
1005 status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL;
1006 status->status = CPJ_CFG_CFM_NOK;
1010 } /* pjCfgUeIdChng */
1015 * This primitive reports the Count informatin of all RBs of an Ue Cb.
1018 * 1. This function reports the count information of all the RBs of an UE.
1020 * @param [in] ueId - UE Identifier
1021 * @param [in] cellId - CELL Identifier
1022 * @param [out] countCfm - Count Information
1028 PUBLIC S16 pjCfgPrcDlCount
1031 UdxCountReqInfo *countReq,
1032 UdxCountCfmInfo *countCfm
1035 PUBLIC S16 pjCfgPrcDlCount (gCb, countReq, countCfm)
1037 UdxCountReqInfo *countReq;
1038 UdxCountCfmInfo *countCfm;
1047 TRC3(pjCfgPrcDlCount);
1049 /* Initialization */
1056 RLOG2(L_DEBUG, "pjCfgPrcCount - Count Request Received for - cellId(%d),ueId(%d)",
1057 countReq->cellId, countReq->ueId);
1060 ret = pjDbmFetchDlUeCb(gCb, countReq->ueId, countReq->cellId, &ueCb);
1061 countCfm->ueId = countReq->ueId;
1062 countCfm->cellId = countReq->cellId;
1063 countCfm->transId = countReq->transId;
1065 /* Ue Cb is not present */
1066 if( ROK != ret || NULLP == ueCb)
1068 RLOG_ARG1(L_ERROR, DBG_CELLID, countCfm->cellId,"UeId[%u] not found",countCfm->ueId);
1069 /* Fill entCfm structure */
1070 countCfm->numRb = numRb;
1071 countCfm->status = CPJ_CFG_CFM_NOK;
1072 countCfm->reason = CPJ_CFG_REAS_UE_UNKWN;
1076 /* Loop through all DRBs */
1077 for(numRb=0, idx=0; idx < PJ_MAX_DRB_PER_UE && numRb < UDX_MAX_DRB; idx++) /* KW_FIX */
1079 rbCb = ueCb->drbCb[idx];
1080 /* RB is present and configured for PDCP Layer */
1083 countCfm->countInfo[numRb].rbId= rbCb->rbId;
1084 countCfm->countInfo[numRb].dir = rbCb->dir;
1085 countCfm->countInfo[numRb].dlCount= rbCb->dlCb.count;
1086 countCfm->countInfo[numRb].ulCount= 0;
1091 /* Fill CountCfm with status and reason */
1092 countCfm->numRb = numRb;
1095 countCfm->status =CPJ_CFG_CFM_OK;
1096 countCfm->reason =CPJ_CFG_REAS_NONE;
1100 countCfm->status =CPJ_CFG_CFM_NOK;
1101 countCfm->reason =CPJ_CFG_REAS_NO_DRBS;
1106 } /* pjCfgPrcCount */
1110 * This primitive reports SDU status information of all RBs of an Ue Cb.
1113 * 1. This primitive Trigger the Handoff Request procedure
1115 * @param [in] ueId - UE Identifier
1116 * @param [in] cellId - CELL Identifier
1117 * @param [out] sduStaCfm - SDU Status Information
1123 PUBLIC S16 pjCfgPrcDlSduSta
1126 UdxSduStaReqInfo *staReq
1129 PUBLIC S16 pjCfgPrcDlSduSta (gCb, staReq)
1131 UdxSduStaReqInfo *staReq;
1138 UdxSduStaInfo *staInfo;
1139 PjDlHoCfmInfo *hoCfmInfo;
1140 UdxSduStaCfmInfo *cfmInfo;
1141 PjUdxDlSapCb *udxSap;
1143 TRC3(pjCfgPrcDlSduSta);
1145 /* Initialization */
1149 RLOG2(L_DEBUG, "pjCfgPrcSduSta - Received for -- cellId(%d),ueId(%d)",
1150 staReq->cellId, staReq->ueId);
1152 /* Memory leak fix ccpu00135359 */
1153 udxSap = &(gCb->u.dlCb->udxDlSap[0]);
1154 PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfmInfo,
1155 sizeof (UdxSduStaCfmInfo), ret);
1158 #if (ERRCLASS & ERRCLS_DEBUG) /*KW_FIX*/
1159 RLOG0(L_FATAL, "Memory Allocation failed.");
1161 PJ_PST_FREE(gCb->u.dlCb->udxDlSap[0].pst.region,
1162 gCb->u.dlCb->udxDlSap[0].pst.pool,
1163 staReq, sizeof(UdxSduStaReqInfo));
1167 cfmInfo->ueId = staReq->ueId;
1168 cfmInfo->cellId = staReq->cellId;
1169 cfmInfo->transId = staReq->transId;
1170 cfmInfo->status = CPJ_CFG_CFM_OK;
1173 ret = pjDbmFetchDlUeCb(gCb, staReq->ueId, staReq->cellId, &ueCb);
1175 /* UeCb is not present */
1176 if( ROK != ret || NULLP == ueCb)
1178 RLOG_ARG1(L_ERROR, DBG_CELLID, staReq->cellId,"UeId[%u] not found",staReq->ueId);
1179 cfmInfo->status = CPJ_CFG_CFM_NOK;
1180 cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN;
1181 cfmInfo->numRb = numRb;
1183 /* Caller should return cfm with failure */
1184 RLOG_ARG1(L_ERROR,DBG_UEID,staReq->ueId,
1185 "UE Cb is not found -- cellId(%d)",
1188 /* Send Failure SduStaCfm */
1189 PjDlUdxSduStaCfm(&gCb->u.dlCb->udxDlSap[0].pst,
1190 gCb->u.dlCb->udxDlSap[0].suId, cfmInfo);
1195 /* Call Ho Start handler for this UE */
1196 pjUtlDlReEstHO(gCb, ueCb);
1198 for(rbCnt=0, numRb=0; rbCnt < PJ_MAX_DRB_PER_UE && numRb < CPJ_MAX_DRB; rbCnt++)
1200 hoCfmInfo = &ueCb->hoInfo->hoCfmInfo[rbCnt];
1201 staInfo = &cfmInfo->sduStaInfo[numRb];
1202 if(hoCfmInfo->pres != TRUE)
1207 staInfo->rbId = hoCfmInfo->rbId;
1208 staInfo->dir = hoCfmInfo->dir;
1209 staInfo->dlSduStaInfo.count = hoCfmInfo->count;
1210 staInfo->dlSduStaInfo.hoPres = TRUE;
1213 cfmInfo->numRb = numRb;
1214 cfmInfo->status = ROK;
1215 cfmInfo->reason = CPJ_CFG_REAS_NONE;
1216 PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo,
1217 (PJ_MAX_DRB_PER_UE * sizeof(PjDlHoCfmInfo)));
1218 PJ_FREE(gCb,ueCb->hoInfo, sizeof(PjDlHoInfo));
1220 PjDlUdxSduStaCfm(&gCb->u.dlCb->udxDlSap[0].pst,
1221 gCb->u.dlCb->udxDlSap[0].suId, cfmInfo);
1223 } /* pjCfgPrcSduSta */
1229 * This primitive to update the ROHC Comp details in PJRB Cb.
1232 * 1. This primitive to update the ROHC comp detils in PJRB Cb.
1234 * @param [in] pjRbCb - RB Control Block
1235 * @param [in] ueCb - Ue Control Block
1236 * @param [in] hdrCompCfg- Comp Cfg Information
1242 PRIVATE S16 pjCfgUpdDlCompInfo
1247 UdxHdrCompCfg *rohcCfg
1250 PRIVATE S16 pjCfgUpdDlCompInfo(gCb, rbCb, ueCb, rohcCfg)
1254 UdxHdrCompCfg *rohcCfg;
1261 TRC3(pjCfgUpdDlCompInfo);
1263 /* Initialization */
1268 RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Received for -- cellId(%d),RbId(%d)",
1269 rbCb->rbId, ueCb->key.ueId);
1271 /* Header Compresion information present */
1272 if(rohcCfg->hdrCompUsed)
1274 /* Header Compression is enabled */
1275 rbCb->rohc.hdrCmpUsed = TRUE;
1277 /* User Can Configure multipel profiles. Maximum profile ID should be used */
1278 for(; idx<CPJ_MAX_ROHC_PROF_LIST; idx++)
1280 if((rohcCfg->rohcInfo.profLst[idx] )&&
1281 (profId < rohcProfId[idx]))
1282 profId = rohcProfId[idx];
1287 /* Header Compression is disabled */
1288 rbCb->rohc.hdrCmpUsed = FALSE;
1292 /* Store the profile Id and MaxCid */
1294 rbCb->rohc.profId = profId;
1295 rbCb->rohc.maxCid = rohcCfg->rohcInfo.maxCid;
1297 /* Store the ue Details in Compressor Context */
1298 rbCb->cmpCxt.ueId = ueCb->key.ueId;
1299 rbCb->cmpCxt.cellId = ueCb->key.cellId;
1300 rbCb->cmpCxt.rbId = rbCb->rbId;
1301 rbCb->cmpCxt.rbType = rbCb->rbType;
1303 RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Selected -- profId(%d),maxCid(%d)",
1304 rbCb->rohc.profId, rbCb->rohc.maxCid);
1308 if(rbCb->rohc.hdrCmpUsed)
1310 ret=pjUtlDlCmpInit(gCb, rbCb);
1314 } /* pjCfgUpdCompInfo */
1319 * This primitive to delete RB from Ue Cb.
1322 * 1. To delete the PJRB Cb from UeCb.
1324 * @param [in] ueCb - Ue Control Block
1325 * @param [in] rbCb - Rb Control Block
1331 PUBLIC S16 pjCfgDelPjDlRbCb
1338 PUBLIC S16 pjCfgDelPjDlRbCb(gCb,ueCb,rbCb)
1345 /* kw005.201 added support for L2 measurement */
1348 TRC3(pjCfgDelPjDlRbCb);
1350 /* Initialization */
1353 /* RbCb is present and Configured for PDCP */
1356 RLOG_ARG1(L_DEBUG, DBG_UEID,ueCb->key.ueId,
1357 "Delete RB Req Received for -- rbId (%d)",rbCb->rbId);
1360 PJ_UPD_L2_DECR_PER_QCI_RB_COUNT(gCb, rbCb);
1363 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
1364 /* Stop off board timers */
1365 if(PJ_DIR_DL & rbCb->dir)
1366 pjStopTmr(gCb, (PTR)rbCb, PJ_EVT_DL_OBD_TMR);
1368 /* Deinit Tx Buffers */
1369 pjDbmTxDeInit(gCb, &rbCb->dlCb.txBuf);
1370 pjUtlEmptyDlPktList(gCb, rbCb);
1372 if (rbCb->dlCb.staRep != NULL)
1374 PJ_FREE_BUF(rbCb->dlCb.staRep);
1377 if (PJ_SRB == rbCb->rbType)
1381 else if(PJ_DRB == rbCb->rbType)
1384 if (rbCb->rohc.hdrCmpUsed)
1386 pjUtlCmpClose(gCb,rbCb->cmpCxtId);
1391 pjDbmDelDlRbCb(gCb,rbCb->rbId, rbCb->rbType, &rbCb, PJ_CFG_PDCP,ueCb);
1394 } /* pjCfgDelPjRBCb */
1399 * Handler to process the downlink re-establishment Request for SRB1 during
1400 * RRC Re-Establishment request.
1403 * 1. This primitive is used to re-establish SRB1 only during RRC Re-establishment
1404 * 2. New Security Algo will applied
1406 * @param [in] gCb - PDCP Instance Control block.
1407 * @param [in] reEstReq - Entity Configuration to be done.
1408 * @param [out] reEstCfm - Entity Configuration cfm.
1414 PUBLIC S16 pjCfgDlReEstReq
1417 UdxReEstReqInfo *reEstReq,
1418 UdxReEstCfmInfo *reEstCfm
1421 PUBLIC S16 pjCfgDlReEstReq (gCb, reEstReq, reEstCfm)
1423 UdxReEstReqInfo *reEstReq;
1424 UdxReEstCfmInfo *reEstCfm;
1431 TRC3(pjCfgDlReEstReq);
1433 /* Initialization */
1434 rlcId.cellId = reEstReq->pdcpId.cellId;
1435 rlcId.ueId = reEstReq->pdcpId.ueId;
1436 rlcId.rbId = reEstReq->pdcpId.rbId;
1437 rlcId.rbType = reEstReq->pdcpId.rbType;
1439 RLOG2(L_DEBUG, "ReEst Req Received for -- cellId(%d),ueId(%d)",
1440 reEstReq->pdcpId.cellId, reEstReq->pdcpId.ueId);
1442 ret = pjDbmFetchDlRbCb(gCb,rlcId,&rbCb);
1444 /* Ue Cb is not present */
1445 if( ROK != ret || NULLP == rbCb)
1447 RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:RbId[%d] not found",
1448 rlcId.cellId, rlcId.rbId);
1449 /* Fill entCfm structure */
1450 PJ_CFG_FILL_REESTREQ_CFM(reEstCfm, reEstReq->pdcpId.ueId,reEstReq->pdcpId.cellId,
1451 reEstReq->transId, CPJ_CFG_CFM_NOK);
1455 /* Copy Security Information */
1456 cmMemcpy(&rbCb->ueCb->secInfo.intInfo.intKey[0], &reEstReq->intKey[0], PJ_INTG_KEY_LEN);
1457 cmMemcpy(&rbCb->ueCb->secInfo.cipherInfo.cpKey[0], &reEstReq->ctrlplnKey[0], PJ_CIPHER_KEY_LEN);
1458 cmMemcpy(&rbCb->ueCb->secInfo.cipherInfo.upKey[0], &reEstReq->usrplnKey[0], PJ_CIPHER_KEY_LEN);
1460 /* Mark Security Action Done */
1461 rbCb->ueCb->secInfo.secAct = TRUE;
1463 /* update the status as success. Chances of failure after this is minimal*/
1464 PJ_CFG_FILL_REESTREQ_CFM(reEstCfm, reEstReq->pdcpId.ueId,reEstReq->pdcpId.cellId,
1465 reEstReq->transId, CPJ_CFG_CFM_OK);
1468 /* In case of Async need to save the cfm information */
1469 pjUtlDlSaveCfmInfo(gCb, rbCb->ueCb, PJ_REEST_ASYNC_CFM, TRUE, ENTPJ,
1470 (PTR)reEstCfm, NULLP);
1471 PJ_FREE(gCb,reEstCfm, sizeof(CpjReEstCfmInfo));
1474 /* Call ReEst for SRB1 */
1475 pjUtlDlReEstSrb1(gCb, rbCb);
1478 } /* pjCfgReEstReq */
1482 PRIVATE S16 pjAddToDlL2Meas(PjCb *gCb, PjDlRbCb *pjRbCb,U8 cellId,U16 ueId)
1484 PjL2MeasEvtCb *measEvtCb = NULLP;
1485 PjL2MeasCb *measCb = NULLP;
1489 for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++)
1491 measEvtCb = &gCb->u.dlCb->pjL2Cb.pjL2EvtCb[cntr];
1492 measCb = &(measEvtCb->measCb);
1494 if (measCb->measType & LPJ_L2MEAS_DL_DISC)
1496 pjUtlPlcMeasDatInDlL2Sts(&measCb->measData[pjRbCb->qci],
1497 &pjRbCb->rbL2Cb, measCb->measType);
1498 measCb->qci[pjRbCb->qci] = pjRbCb->qci;
1500 measCb->measData[pjRbCb->qci].totDrbsPerQci++;
1504 }/*pjAddToDlL2Meas*/
1505 #endif /*LTE_L2_MEAS*/
1509 /********************************************************************30**
1512 **********************************************************************/