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: NR RLC - Configuration Manager file
25 Desc: It contains the following configuraiton primtives
38 *********************************************************************21*/
40 /** @file rlc_cfg_dl.c
41 @brief RLC Downlink Configuration Module
45 /* header (.h) include files */
46 #include "common_def.h"
48 #include "lkw.h" /* LKW defines */
49 #include "ckw.h" /* CKW defines */
50 #include "kwu.h" /* KWU defines */
51 #include "rgu.h" /* RGU defines */
52 #include "rlc_err.h" /* RLC error options */
53 #include "rlc_env.h" /* RLC environment options */
56 /* extern (.x) include files */
57 #include "lkw.x" /* LKW */
58 #include "ckw.x" /* CKW */
59 #include "kwu.x" /* KWU */
60 #include "rgu.x" /* RGU */
62 #include "rlc_utils.h" /* RLC defines */
63 #include "rlc_dl_ul_inf.h"
65 #include "du_app_rlc_inf.h"
67 #define RLC_MODULE RLC_DBGMASK_CFG
68 /*Added for adding new Ue in onging L2 Meas*/
72 * @brief Handle modification of UE ID for L2 Meas data structs
75 * @param[in] ueId ue ID
82 static S16 rlcHdlMeasDlUeIdChg(RlcCb *gCb, uint8_t cellId,uint8_t oldUeId, uint8_t newUeId)
84 RlcL2MeasEvtCb *measEvtCb = NULLP;
85 RlcL2MeasCb *measCb = NULLP;
89 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
91 measEvtCb = &(gCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
92 measCb = &(measEvtCb->measCb);
95 if(measCb->measType & LKW_L2MEAS_DL_IP )
98 for(ueIdx = 0; ueIdx < measCb->val.ipThMeas.numUes; ueIdx++)
100 if((measCb->val.ipThMeas.ueInfoLst[ueIdx].ueId) == oldUeId)
102 measCb->val.ipThMeas.ueInfoLst[ueIdx].ueId = newUeId;
113 * @brief Handler to delete an UE's L2 Meas ctxt
116 * @param[in] ueId ue ID
123 static S16 rlcDelFrmDlL2Meas(RlcCb *gCb, uint8_t cellId,uint8_t ueId)
125 RlcL2MeasEvtCb *measEvtCb = NULLP;
126 RlcL2MeasCb *measCb = NULLP;
131 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
133 measEvtCb = &gCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr];
134 measCb = &(measEvtCb->measCb);
137 if(measCb->measType & LKW_L2MEAS_DL_IP )
140 for(ueIdx = 0; ((ueIdx < measCb->val.ipThMeas.numUes) &&
141 (ueIdx < gCb->genCfg.maxUe)); ueIdx++)
143 if((measCb->val.ipThMeas.ueInfoLst[ueIdx].ueId) == ueId)
145 measCb->val.ipThMeas.ueInfoLst[ueIdx].isValid = FALSE;
146 if (measCb->val.ipThMeas.numUes-1 == ueIdx)
148 measCb->val.ipThMeas.numUes--;
160 static S16 rlcAddToDlL2Meas(RlcCb *gCb, RlcDlRbCb *rlcRbCb,uint8_t cellId,uint8_t ueId)
162 RlcL2MeasEvtCb *measEvtCb = NULLP;
163 RlcL2MeasCb *measCb = NULLP;
169 #ifndef XEON_SPECIFIC_CHANGES
170 uint8_t freeIdx = gCb->genCfg.maxUe;
172 uint16_t freeIdx = LKW_MAX_UE;
176 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
178 measEvtCb = &gCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr];
179 measCb = &(measEvtCb->measCb);
181 freeIdx = gCb->genCfg.maxUe;
183 if(measCb->measType &
184 (LKW_L2MEAS_ACT_UE | LKW_L2MEAS_UU_LOSS | LKW_L2MEAS_DL_DELAY))
186 for(cntr1 =0;((cntr1 < measCb->val.nonIpThMeas.numQci) &&
187 (cntr1 < LKW_MAX_QCI));cntr1++)
189 if(measCb->val.nonIpThMeas.qci[cntr1] != rlcRbCb->qci)
191 measCb->val.nonIpThMeas.qci[cntr1] = rlcRbCb->qci;
192 gCb->u.dlCb->rlcL2Cb.measOn[rlcRbCb->qci] |=measCb->measType;
198 if(((rlcRbCb->rbL2Cb.measOn & measCb->measType) == LKW_L2MEAS_NONE))
200 if (measCb->measType & LKW_L2MEAS_ACT_UE)
202 if((rlcRbCb->mode == RLC_MODE_UM) &&
203 (rlcRbCb->dir & RLC_DIR_DL ))
205 if (rlcRbCb->m.umDl.sduQ.count)
207 if (rlcRbCb->ueCb->numActRb[rlcRbCb->qci] == 0)
209 rlcRbCb->ueCb->numActRb[rlcRbCb->qci]++;
210 gCb->u.dlCb->rlcL2Cb.numActUe[rlcRbCb->qci]++;
214 else if (rlcRbCb->mode == RLC_MODE_AM)
216 if ((rlcRbCb->m.amDl.cntrlBo) ||
217 (rlcRbCb->m.amDl.retxBo) ||
218 (rlcRbCb->m.amDl.bo))
220 if (rlcRbCb->ueCb->numActRb[rlcRbCb->qci] == 0)
222 rlcRbCb->ueCb->numActRb[rlcRbCb->qci]++;
223 gCb->u.dlCb->rlcL2Cb.numActUe[rlcRbCb->qci]++;
229 if((measCb->measType & LKW_L2MEAS_DL_IP))
232 for(ueIdx = 0; ((ueIdx < measCb->val.ipThMeas.numUes) &&
233 (ueIdx < gCb->genCfg.maxUe)); ueIdx++)
235 if ((freeIdx == gCb->genCfg.maxUe) &&
236 (measCb->val.ipThMeas.ueInfoLst[ueIdx].isValid == FALSE))
241 if((measCb->val.ipThMeas.ueInfoLst[ueIdx].ueId) == ueId)
247 if (ueIdx == measCb->val.ipThMeas.numUes)
249 if (gCb->genCfg.maxUe == measCb->val.ipThMeas.numUes)
253 if (gCb->genCfg.maxUe == freeIdx)
255 measCb->val.ipThMeas.numUes++;
261 measCb->val.ipThMeas.ueInfoLst[ueIdx].isValid = TRUE;
262 memset(&measCb->val.ipThMeas.ueInfoLst[ueIdx].measData[0],0x00,(sizeof(RlcL2Cntr) *LKW_MAX_QCI));
263 measCb->val.ipThMeas.ueInfoLst[ueIdx].numQci = 0;
265 measCb->val.ipThMeas.ueInfoLst[ueIdx].ueId = ueId;
266 measCb->val.ipThMeas.ueInfoLst[ueIdx].cellId = cellId;
267 numQci = &(measCb->val.ipThMeas.ueInfoLst[ueIdx].numQci);
269 for (qciIdx =0; ((qciIdx < *numQci) &&
270 (qciIdx < LKW_MAX_QCI)) ; qciIdx++)
272 if (measCb->val.ipThMeas.ueInfoLst[ueIdx].qci[qciIdx] == rlcRbCb->qci)
278 /* Fix Klock Warning */
279 if ((qciIdx == *numQci) && (qciIdx < LKW_MAX_QCI))
281 measCb->val.ipThMeas.ueInfoLst[ueIdx].qci[qciIdx] = rlcRbCb->qci;
285 rlcUtlPlcMeasDatInL2Sts(&measCb->val.ipThMeas.ueInfoLst[ueIdx].measData[rlcRbCb->qci],
286 &rlcRbCb->rbL2Cb, measCb->measType);
288 else if (measCb->measType &
289 (LKW_L2MEAS_DL_DISC | LKW_L2MEAS_DL_DELAY | LKW_L2MEAS_UU_LOSS))
291 rlcUtlPlcMeasDatInL2Sts(&measCb->val.nonIpThMeas.measData[rlcRbCb->qci],
292 &rlcRbCb->rbL2Cb, measCb->measType);
293 measCb->val.nonIpThMeas.qci[rlcRbCb->qci] = rlcRbCb->qci;
294 measCb->val.nonIpThMeas.measData[rlcRbCb->qci].totDrbsPerQci++;
296 rlcRbCb->rbL2Cb.measOn |= measCb->measType;
299 }/*rlcAddToDlL2Meas*/
300 #endif /*LTE_L2_MEAS*/
305 * This primitive fills the RbCb
307 * @param [in] gCb - RLC Instance Control Block
308 * @param [out] rbCb - RB Control Block
309 * @param [out] ueCb - UE Control Block
310 * @param [in] entCfg - RLC Entity configuration
316 static S16 rlcCfgFillDlRbCb(RlcCb *gCb,RlcDlRbCb *rbCb,RlcDlUeCb *ueCb,RlcEntCfgInfo *entCfg)
319 DU_LOG("\nDEBUG --> RLC_DL : rlcCfgFillRbCb(ueId(%d),cellId(%d) rbType(%d))",
324 /* Initialize according to entMode */
325 switch (entCfg->entMode)
329 rbCb->lch.lChId = entCfg->lCh[0].lChId;
330 rbCb->lch.lChType = entCfg->lCh[0].type;
331 rbCb->dir = entCfg->dir;
337 rbCb->lch.lChId = entCfg->lCh[0].lChId;
338 rbCb->lch.lChType = entCfg->lCh[0].type;
339 rbCb->dir = entCfg->dir;
341 /* Spec 38.322 Section 7.1
342 * All UM state variables can take values from 0 to 63 for 6 bit SN or
343 * from 0 to 4095 for 12 bit SN. All arithmetic operations on UM state
344 * variables are affected by the UM modulus
345 * (i.e. final value = [value from arithmetic operation] modulo 64
346 * for 6 bit SN and 4096 for 12 bit SN)
348 rbCb->m.umDl.snLen = entCfg->m.umInfo.dl.snLen;
349 if (entCfg->m.umInfo.dl.snLen == RLC_UM_CFG_6BIT_SN_LEN)
350 rbCb->m.umDl.modBitMask = 0x3f;
352 rbCb->m.umDl.modBitMask = 0xfff;
354 ueCb->lCh[rbCb->lch.lChId - 1].dlRbCb = rbCb;
360 /* Down Link Information
361 * indx = 0 as Down Link */
362 rbCb->lch.lChId = entCfg->lCh[0].lChId;
363 rbCb->lch.lChType = entCfg->lCh[0].type;
364 rbCb->dir = RLC_DIR_BOTH;
366 rbCb->m.amDl.pollPdu = entCfg->m.amInfo.dl.pollPdu;
367 rbCb->m.amDl.pollByte = entCfg->m.amInfo.dl.pollByte;
368 rbCb->m.amDl.maxRetx = entCfg->m.amInfo.dl.maxRetx;
369 rbCb->m.amDl.pollRetxTmrInt = entCfg->m.amInfo.dl.pollRetxTmr;
370 rbCb->m.amDl.snLen = entCfg->m.amInfo.dl.snLen;
372 if(RLC_AM_CFG_12BIT_SN_LEN == rbCb->m.amDl.snLen)
374 rbCb->m.amDl.snModMask = (1 << RLC_SN_LEN_12BITS) - 1; /* 5GNR */
378 rbCb->m.amDl.snModMask = (1 << RLC_SN_LEN_18BITS) - 1; /* 5GNR */
381 cmInitTimers(&(rbCb->m.amDl.pollRetxTmr), 1);
382 ueCb->lCh[rbCb->lch.lChId - 1].dlRbCb = rbCb;
387 rbCb->m.amDl.txBufLst,
388 (RLC_TX_BUF_BIN_SIZE * sizeof(CmLListCp)));
389 for(hashIndex = 0; hashIndex < RLC_TX_BUF_BIN_SIZE; hashIndex++)
391 cmLListInit(&(rbCb->m.amDl.txBufLst[hashIndex]));
398 DU_LOG("\nERROR --> RLC_DL : Invalid RB Mode ueId(%d),cellId(%d)",
407 RLC_ALLOC(gCb, rbCb->snssai, sizeof(Snssai));
408 if(rbCb->snssai == NULLP)
410 DU_LOG("\nERROR --> RLC_DL : rlcCfgFillDlRbCb(): Failed to allocate memory");
413 memcpy(rbCb->snssai, entCfg->snssai, sizeof(Snssai));
415 rbCb->mode = entCfg->entMode;
416 rbCb->discTmrInt = entCfg->discardTmr;
423 * @brief This primitive Initializes the RB Cb
425 * @param [in] gCb - RLC Instance Control Block
426 * @param [out] rbCb - RB Control Block
427 * @param [in] ptr - Void pointer
428 * @param [in] entCfg - Entity Configuration
434 static S16 rlcCfgUpdateDlRb
439 RlcEntCfgInfo *entCfg
443 if (rbCb->mode != entCfg->entMode)
445 DU_LOG("\nERROR --> RLC_DL : RB Mode Mismatch : exp [%d] rcv [%d] UEID:%d CELLID:%d",
450 return (CKW_CFG_REAS_RB_MODE_MIS);
457 RlcDlCellCb *cellCb = (RlcDlCellCb *)ptr;
459 rbCb->dir = entCfg->dir;
460 rbCb->lch.lChId = entCfg->lCh[0].lChId;
461 rbCb->lch.lChType = entCfg->lCh[0].type;
462 cellCb->lCh[rbCb->lch.lChId - 1].dlRbCb = rbCb;
468 RlcDlUeCb *ueCb = (RlcDlUeCb *)ptr;
470 if (entCfg->lCh[0].type == CM_LTE_LCH_DCCH)
472 return (CKW_CFG_REAS_LCHTYPE_MIS);
475 ueCb->lCh[rbCb->lch.lChId - 1].dlRbCb = NULLP;
476 ueCb->lCh[entCfg->lCh[0].lChId - 1].dlRbCb = rbCb;
478 rbCb->lch.lChId = entCfg->lCh[0].lChId;
479 rbCb->lch.lChType = entCfg->lCh[0].type;
480 rbCb->dir = entCfg->dir;
486 RlcDlUeCb *ueCb = (RlcDlUeCb *)ptr;
488 ueCb->lCh[rbCb->lch.lChId - 1].dlRbCb = NULLP;
489 ueCb->lCh[entCfg->lCh[1].lChId - 1].dlRbCb = rbCb;
492 rbCb->lch.lChId = entCfg->lCh[1].lChId;
493 rbCb->lch.lChType = entCfg->lCh[1].type;
494 rbCb->m.amDl.pollRetxTmrInt = entCfg->m.amInfo.dl.pollRetxTmr;
495 rbCb->m.amDl.pollPdu = entCfg->m.amInfo.dl.pollPdu;
496 rbCb->m.amDl.pollByte = entCfg->m.amInfo.dl.pollByte;
497 rbCb->m.amDl.maxRetx = entCfg->m.amInfo.dl.maxRetx;
507 RLC_ALLOC(gCb, rbCb->snssai, sizeof(Snssai));
508 if(rbCb->snssai == NULLP)
510 DU_LOG("\nERROR --> RLC_DL : rlcCfgFillDlRbCb(): Failed to allocate memory");
514 memcpy(rbCb->snssai,entCfg->snssai,sizeof(Snssai));
517 rbCb->discTmrInt = entCfg->discardTmr;
519 return (CKW_CFG_REAS_NONE);
525 * This primitive adds new RB in Ue/Cell Cb.
528 * This function does following steps -
529 * - If UE ID is 0 then
530 * - Check for CELL CB is present
531 * - If yes, Check for RB ID
532 * - If RB ID is present Status Indication with reason
533 * - Else, Create New RB CB in CELL CB
534 * - If no Create New CELL CB and RB CB
536 * - Check for UE CB is present
537 * - If yes Check for RB ID
538 * - If RB ID is present Status Indication with reason
539 * - Else, Create New RB CB in UE CB
540 * - If no Create New UE CB and RB CB
541 * - Fill entity confirmation
543 * @param [in] gCb - RLC Instance Control Block
544 * @param [in] ueId - UE Identifier
545 * @param [in] cellId - CELL Identifier
546 * @param [in] entCfg - Entity Configuration to be done.
547 * @param [out] entCfm - Entity Confirmation.
558 RlcEntCfgInfo *entCfg,
559 RlcEntCfgCfmInfo *entCfm
562 RlcDlUeCb *ueCb = NULLP; /* UE Control Block */
563 RlcDlCellCb *cellCb; /* Cell Control Block */
564 RlcDlRbCb *rlcRbCb; /* KW RB Control Block */
565 uint8_t reason; /* Rb Identifier */
567 DU_LOG("\nDEBUG --> RLC_DL : rlcCfgAddRb(cellId(%d),UEID:%d cfgType(%d))",
574 /* Fill entCfm structure */
575 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
576 CKW_CFG_REAS_CELL_UNKWN);
577 DU_LOG("\nERROR --> RLC_DL : Add DLRb,CellId is 0 for UEID:%d",
581 if ((entCfg->rguSapId >= gCb->genCfg.maxRguSaps) || (entCfg->rguSapId < 0))
583 RLCDBGP_ERROR(gCb, "rlcCfgAddDlRb(ueId(%u), cellId(%u), Invalid rguSapId (%d)\n",
584 ueId, cellId, entCfg->rguSapId);
589 /* Process Adding new RB */
592 if(entCfg->rbId >= RLC_MAX_RB_PER_CELL)
594 /* Fill entCfm structure */
595 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
597 CKW_CFG_REAS_RB_UNKWN);
598 DU_LOG("\nERROR --> RLC_DL : Invalid RbId ,Max is [%d] CELLID:%d UEID:%d",
605 if (((entCfg->lCh[0].type == CM_LTE_LCH_BCCH) ||
606 (entCfg->lCh[0].type == CM_LTE_LCH_PCCH) ||
607 (entCfg->lCh[0].type == CM_LTE_LCH_CCCH)) &&
608 (entCfg->entMode == RLC_MODE_TM))
610 /* Cell CB present */
611 rlcDbmFetchDlCellCb(gCb, cellId, &cellCb);
614 /* Get rbCb from cellCb->rbCb List */
615 if (( cellCb->rbCb[entCfg->rbId] != NULLP))
617 /* Fill entCfm structure */
618 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
620 CKW_CFG_REAS_RB_PRSNT);
621 DU_LOG("\nERROR --> RLC_DL : RbId [%d] already exists UEID:%d",
627 else /* Cell CB UNKNOWN */
630 if ( ROK != rlcDbmCreateDlCellCb(gCb,cellId, &cellCb))
632 /* Fill entCfm structure */
633 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
635 CKW_CFG_REAS_CELL_CREAT_FAIL);
636 DU_LOG("\nERROR --> RLC_DL : cellCb Creation failed RBID:%d UEID:%d",
644 if(entCfg->lCh[0].lChId <= 0)
646 DU_LOG("\nERROR --> RLC_DL : Invalid LcId CELLID:%d UEID:%d RBID:%d",
650 /* Fill entCfm structure */
651 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
652 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_LCHID);
657 RLC_ALLOC(gCb,rlcRbCb, sizeof (RlcDlRbCb));
660 DU_LOG("\nERROR --> RLC_DL : Memory allocation failed for rbId:%d CELLID:%d",
663 /* Fill entCfm structure */
664 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
665 CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_CREAT_FAIL);
668 rlcRbCb->rlcId.rbId = entCfg->rbId;
669 cellCb->rbCb[entCfg->rbId] = rlcRbCb;
670 RLC_LMM_RB_STS_INC(gCb);
671 cellCb->lCh[entCfg->lCh[0].lChId - 1].dlRbCb = rlcRbCb;
675 reason= (entCfg->entMode != RLC_MODE_TM)? CKW_CFG_REAS_RB_MODE_MIS:
676 CKW_CFG_REAS_LCHTYPE_MIS;
677 /* Fill entCfm structure */
678 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
679 CKW_CFG_CFM_NOK, reason);
685 if (!(RLC_VALIDATE_UE_RBID(entCfg->rbType, entCfg->rbId)))
687 /* Fill entCfm structure */
688 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
689 CKW_CFG_REAS_RB_UNKWN);
690 DU_LOG("\nERROR --> RLC_DL : Invalid RbId for RbType[%d] UEID:%d",
695 if ((((entCfg->lCh[0].type == CM_LTE_LCH_DCCH) &&
696 (entCfg->entMode != RLC_MODE_UM) &&
697 (CM_LTE_SRB == entCfg->rbType)) ||
698 ((entCfg->lCh[0].type == CM_LTE_LCH_DTCH) &&
699 (CM_LTE_DRB == entCfg->rbType))) &&
700 (entCfg->entMode != RLC_MODE_TM))
703 if ( rlcDbmFetchDlUeCb(gCb,ueId, cellId, &ueCb) == ROK)
705 /* Get rbCb from ueCb->rbCb list */
706 RLC_DBM_GET_RBCB_FROM_UECB(entCfg->rbId, entCfg->rbType, ueCb, rlcRbCb);
708 if(( rlcRbCb != NULLP))
710 /* Fill entCfm structure */
711 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
712 CKW_CFG_REAS_RB_PRSNT);
713 DU_LOG("\nERROR --> RLC_DL : CellId[%u]:rbId [%d] already exists",
719 else /* UE CB UNKNOWN */
722 if ( rlcDbmCreateDlUeCb(gCb,ueId, cellId, &ueCb) != ROK)
724 /* Fill entCfm structure */
725 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
726 CKW_CFG_REAS_UE_CREAT_FAIL);
727 DU_LOG("\nERROR --> RLC_DL : UeId [%u]:ueCb Creation Failed RBID:%d",
732 /* Start throughput calculation for this UE */
733 gCb->rlcThpt.thptPerUe[ueId -1].ueId = ueId;
734 gCb->rlcThpt.thptPerUe[ueId -1].dataVol = 0;
735 gCb->rlcThpt.numActvUe++;
738 /* Validate LChId for UM and AM modes */
739 if ((entCfg->lCh[0].lChId <= 0) ||
740 ((entCfg->entMode == RLC_MODE_AM)&&
741 (entCfg->lCh[1].lChId <= 0)))
743 /* Fill entCfm structure */
744 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
745 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_LCHID);
750 RLC_ALLOC(gCb,rlcRbCb, sizeof (RlcDlRbCb));
753 /* Fill entCfm structure */
754 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,CKW_CFG_CFM_NOK,
755 CKW_CFG_REAS_RB_CREAT_FAIL);
756 DU_LOG("\nERROR --> RLC_DL : Memory allocation failed RBID:%d CELLID:%d",
762 /* copy the RB Cb into UECb */
763 rlcRbCb->rlcId.rbId = entCfg->rbId;
764 if(entCfg->rbType == CM_LTE_SRB)
765 ueCb->srbCb[entCfg->rbId] = rlcRbCb;
767 ueCb->drbCb[entCfg->rbId] = rlcRbCb;
769 RLC_LMM_RB_STS_INC(gCb);
774 if (entCfg->entMode == RLC_MODE_TM)
776 reason = CKW_CFG_REAS_RB_MODE_MIS;
780 reason = CKW_CFG_REAS_LCHTYPE_MIS;
783 /* Fill entCfm structure */
784 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK, reason);
790 rlcRbCb->rlcId.cellId = cellId;
791 rlcRbCb->rlcId.ueId = ueId;
792 rlcRbCb->rlcId.rbType = entCfg->rbType;
793 rlcRbCb->inst = gCb->init.inst;
794 #ifdef TENB_MULT_CELL_SUPPRT
795 rlcRbCb->rguSapId = entCfg->rguSapId;
800 if (rlcCfgFillDlRbCb(gCb,rlcRbCb, ueCb, entCfg) != ROK)
802 /* Fill entCfm structure */
803 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
804 CKW_CFG_REAS_RB_CREAT_FAIL);
806 /* Delete RB CB created */
807 RLC_FREE(gCb,rlcRbCb, sizeof(RlcDlRbCb));
808 DU_LOG("\nERROR --> RLC_DL : Filling of RbCb failed UEID:%d CELLID:%d",
813 rlcRbCb->qci = entCfg->qci;
815 rlcRbCb->ueCb = ueCb;
816 if (entCfg->lCh[0].type == CM_LTE_LCH_DTCH)
819 rlcAddToDlL2Meas(gCb, rlcRbCb,cellId,ueId);
821 #endif /* LTE_L2_MEAS */
823 /* Fill entCfm structure */
824 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_OK, CKW_CFG_REAS_NONE);
832 * This primitive reconfigures the existing RB in Ue/Cell Cb.
835 * This primitive executes following steps in reconfiguration of existing
837 * - If UE ID is 0 then
838 * - Check for CELL CB is present
839 * - If yes, Check for RB ID
840 * - If RB ID is present Reconfigure the RB CB
841 * - Else, Status Indication with Reason
842 * - Else, Status Indication with Reason
844 * - Check for UE CB is present
845 * - If yes, Check for RB ID
846 * - If RB ID is prenset Reconfigure the CELL CB
847 * - Else, Status Indication with Reason
848 * - Else, Status Indication with Reason
849 * - Fill entity confirmation
851 * @param [in] gCb - RLC Instance Control Block
852 * @param [in] ueId - UE Identifier
853 * @param [in] cellId - CELL Identifier
854 * @param [in] entCfg - Entity Configuration to be done.
855 * @param [out] entCfm - Entity Confirmation
866 RlcEntCfgInfo *entCfg,
867 RlcEntCfgCfmInfo *entCfm
870 RlcDlRbCb *rbCb; /* RB Control Block */
871 RlcDlRbCb tRbCb; /* KW RB Control Block */
872 RlcDlCellCb *cellCb; /* Cell Control Block */
873 RlcDlUeCb *ueCb; /* Ue Control Block */
876 DU_LOG("\nDEBUG --> RLC_DL : rlcCfgReCfgRb(cellId(%d), cfgType(%d)) RBID:%d",
877 cellId, entCfg->cfgType,entCfg->rbId);
880 /* Check for UeCb or CellCb */
883 if(entCfg->rbId >= RLC_MAX_RB_PER_CELL)
885 /* Fill entCfm structure */
886 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
887 CKW_CFG_REAS_RB_UNKWN);
888 DU_LOG("\nERROR --> RLC_DL : Invalid RbId , Max is [%d] UEID:%d CELLID:%d",
895 rlcDbmFetchDlCellCb(gCb,cellId, &cellCb);
898 /* Fill entCfm structure */
899 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
900 CKW_CFG_REAS_CELL_UNKWN);
901 DU_LOG("\nERROR --> RLC_DL : CellCb not found ueId:%d RBID:%d CELLID:%d",
909 RLC_DBM_GET_CELL_RBCB(entCfg->rbId, cellCb->rbCb, rbCb);
913 /* Fill entCfm structure */
914 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
915 CKW_CFG_REAS_RB_UNKWN);
916 DU_LOG("\nERROR --> RLC_DL : CELLID:%d RBID:%d not found",
922 /* Take backup of rbCb before updating.
923 * Because in failure case restore original rbCb
925 memcpy(&tRbCb, rbCb, sizeof(RlcDlRbCb));
928 ret = rlcCfgUpdateDlRb(gCb,rbCb, cellCb,entCfg);
931 /* Fill entCfm structure */
932 RLC_CFG_FILL_CFG_CFM(entCfm,
938 DU_LOG("\nERROR --> RLC_DL : CELLID:%u RBID:%d updation failed",
941 memcpy(rbCb, &tRbCb, sizeof(RlcDlRbCb));
948 if (!(RLC_VALIDATE_UE_RBID(entCfg->rbType, entCfg->rbId)))
950 /* Fill entCfm structure */
951 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
952 CKW_CFG_REAS_RB_UNKWN);
953 DU_LOG("\nERROR --> RLC_DL : CELLID:%d Invalid RBID:%d for RbType[%d]",
960 ret = rlcDbmFetchDlUeCb(gCb,ueId, cellId, &ueCb);
963 /* Fill entCfm structure */
964 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
965 CKW_CFG_CFM_NOK, CKW_CFG_REAS_UE_UNKWN);
966 DU_LOG("\nERROR --> RLC_DL : UEID:%d UeCb not found RBID:%d",
973 RLC_DBM_GET_RBCB_FROM_UECB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
977 /* Fill entCfm structure */
978 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
979 CKW_CFG_REAS_RB_UNKWN);
980 DU_LOG("\nERROR --> RLC_DL : CELLID:%d RBID:%d not found",
986 /* Take backup of rbCb before updating.
987 * Because in failure case restore original rbCb
989 memcpy(&tRbCb, rbCb, sizeof(RlcDlRbCb));
992 ret = rlcCfgUpdateDlRb(gCb,rbCb,ueCb, entCfg);
993 if (ret != CKW_CFG_REAS_NONE)
995 /* Fill entCfm structure */
996 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
998 DU_LOG("\nERROR --> RLC_DL : CELLID:%d RBID:%d updation failed",
1001 memcpy(rbCb, &tRbCb, sizeof(RlcDlRbCb));
1007 /* Fill entCfm structure */
1008 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_OK, CKW_CFG_REAS_NONE);
1015 * @brief This primitive deletes the existing RB in Ue/Cell Cb.
1018 * - If UE ID is 0 then
1019 * - Check for CELL CB is present
1020 * - If yes, Check for RB ID
1021 * - If RB ID is prenset Delete the RB CB
1022 * - If there is no RB CB exist in CELL CB then Delete CELL CB.
1023 * - Else, Status Indication with Reason
1024 * - Else, Status Indication with Reason
1026 * - Check for UE CB is present
1027 * - If yes, Check for RB ID
1028 * - If RB ID is prenset Delete the RB CB
1029 * - If there is no RB CB exist in UE CB then Delete UE CB.
1030 * - Else, Status Indication with Reason
1031 * - Else, Status Indication with Reason
1032 * - Fill entity confirmation
1034 * @param [in] gCb - RLC Instance Control Block
1035 * @param [in] ueId - UE Identifier
1036 * @param [in] cellId - CELL Identifier
1037 * @param [in] entCfg - Entity Configuration to be done.
1038 * @param [out] entCfm - Entity Confirmation
1049 RlcEntCfgInfo *entCfg,
1050 RlcEntCfgCfmInfo *entCfm
1053 S16 ret; /* Return Value */
1054 RlcDlUeCb *ueCb; /* UE Control Block */
1055 RlcDlCellCb *cellCb; /* UE Control Block */
1056 RlcDlRbCb *rlcRbCb; /* KW RB Control Block */
1058 DU_LOG("\nDEBUG --> RLC_DL : rlcCfgDelRb(RBID(%d), cellId(%d), cfgType(%d))",
1065 /* Get cellCb and delete rbCb from it */
1068 if(entCfg->rbId >= RLC_MAX_RB_PER_CELL)
1070 /* Fill entCfm structure */
1071 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1072 CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_UNKWN);
1073 DU_LOG("\nERROR --> RLC_DL : Invalid RbId, Max is [%d] UEID:%d CELLID:%d",
1074 RLC_MAX_RB_PER_CELL,
1080 rlcDbmFetchDlCellCb(gCb,cellId, &cellCb);
1083 /* Fill entCfm structure */
1084 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1085 CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_UNKWN);
1086 DU_LOG("\nERROR --> RLC_DL : CellCb not found UEID:%d RBID:%d",
1093 RLC_DBM_GET_CELL_RBCB(entCfg->rbId, cellCb->rbCb, rlcRbCb);
1095 if ( rlcRbCb == NULLP)
1097 /* Fill entCfm structure */
1098 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1099 CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_UNKWN);
1100 DU_LOG("\nERROR --> RLC_DL : CellId[%u]:RbId[%d] not found",
1106 /* Assign NULLP to rbCb in rbCbLst */
1107 cellCb->rbCb[entCfg->rbId] = NULLP;
1109 /* Assign NULLP to dlRbCb/ulRbCb.
1110 * Delete Hashlist allocated for it if any */
1111 cellCb->lCh[rlcRbCb->lch.lChId - 1].dlRbCb = NULLP;
1112 RLC_FREE(gCb,rlcRbCb->snssai, sizeof(Snssai));
1113 RLC_FREE(gCb,rlcRbCb, sizeof(RlcDlRbCb)); /*Vartika: Mem leak fix */
1115 /* Get ueCb and delete rbCb from it */
1118 if (!(RLC_VALIDATE_UE_RBID(entCfg->rbType, entCfg->rbId)))
1120 /* Fill entCfm structure */
1121 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1122 CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_UNKWN);
1123 DU_LOG("\nERROR --> RLC_DL : Invalid RbId for RbType[%d] UEID:%d CELLID:%d",
1131 ret = rlcDbmFetchDlUeCb(gCb,ueId, cellId, &ueCb);
1134 /* Fill entCfm structure */
1135 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1136 CKW_CFG_CFM_NOK, CKW_CFG_REAS_UE_UNKWN);
1137 DU_LOG("\nERROR --> RLC_DL : UeId [%d]: UeCb not found RBID:%d",
1144 RLC_DBM_GET_RBCB_FROM_UECB(entCfg->rbId, entCfg->rbType, ueCb, rlcRbCb);
1146 if ( rlcRbCb == NULLP)
1148 /* Fill entCfm structure */
1149 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
1150 CKW_CFG_REAS_RB_UNKWN);
1151 DU_LOG("\nERROR --> RLC_DL : CellId[%u]:RbId[%d] not found",
1156 ueCb->lCh[rlcRbCb->lch.lChId - 1].dlRbCb = NULLP;
1159 RLC_UPD_L2_DECR_NONIP_PER_QCI_RB_COUNT(gCb, rlcRbCb);
1161 /* Free the Buffers of RbCb */
1162 if( RLC_MODE_UM == rlcRbCb->mode)
1164 rlcUmmFreeDlRbCb(gCb,rlcRbCb);
1166 RLC_FREE(gCb,rlcRbCb, sizeof(RlcDlRbCb));
1168 else if( RLC_MODE_AM == rlcRbCb->mode)
1170 rlcAmmFreeDlRbCb(gCb,rlcRbCb);
1173 /* Assign NULLP to rbCb in rbCbLst */
1174 if ( entCfg->rbType == CM_LTE_SRB )
1176 ueCb->srbCb[entCfg->rbId] = NULLP;
1180 ueCb->drbCb[entCfg->rbId] = NULLP;
1184 RLC_LMM_RB_STS_DEC(gCb);
1186 /* Fill entCfm structure */
1187 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_OK,
1195 * @brief This primitive re-establish the existing RB in Ue/Cell Cb.
1198 * - If UE ID is 0 then
1199 * - Check for CELL CB is present
1200 * - If yes, Check for RB ID
1201 * - If RB ID is prenset initialize the parameters of the RB CB
1202 * - Else, Status Indication with Reason
1203 * - Else, Status Indication with Reason
1205 * - Check for UE CB is present
1206 * - If yes, Check for RB ID
1207 * - If RB ID is prenset initialize the parameters of the RB CB
1208 * - Else, Status Indication with Reason
1209 * - Else, Status Indication with Reason
1210 * - Fill entity confirmation
1212 * @param [in] gCb - RLC Instance Control Block
1213 * @param [in] ueId - UE Identifier
1214 * @param [in] cellId - CELL Identifier
1215 * @param [in] entCfg - Entity Configuration to be done.
1216 * @param [out] entCfm - Entity Confirmation
1228 RlcEntCfgInfo *entCfg,
1229 RlcEntCfgCfmInfo *entCfm
1232 RlcDlRbCb *rbCb; /* RB Control Block */
1233 CmLteRlcId rlcId; /* RLC Identifier */
1235 DU_LOG("\nDEBUG --> RLC_DL : rlcCfgReEstDlRb(ueId(%d), cellId(%d), cfgType(%d))",
1242 rlcId.cellId = cellId;
1243 rlcId.rbId = entCfg->rbId;
1244 rlcId.rbType = entCfg->rbType;
1246 rlcDbmFetchDlRbCbByRbId(gCb,&rlcId, &rbCb);
1249 /* Fill entCfm structure */
1250 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, rlcId.rbType, CKW_CFG_CFM_NOK,
1251 CKW_CFG_REAS_RB_UNKWN);
1252 DU_LOG("\nERROR --> RLC_DL : CellId[%u]:RbId[%d] not found",
1258 rbCb->rlcId.ueId = ueId;
1264 rlcDlTmmReEstablish(gCb,rbCb);
1270 rlcDlUmmReEstablish(gCb,rlcId,sndReEstInd,rbCb);
1276 rlcAmmDlReEstablish(gCb, rlcId, rbCb);
1281 /* Fill entCfm structure */
1282 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1283 CKW_CFG_CFM_OK, CKW_CFG_REAS_NONE);
1290 * @brief This primitive deletes the RBs in Ue Cb.
1293 * - If UE ID is 0 then
1294 * - Status Indication with Reason
1296 * - Check for UE CB is present
1297 * - If yes, Delete all RB CB in UE CB and Delete UE CB also.
1298 * - Else, Status Indication with Reason
1299 * - Fill entity confirmation
1301 * @param [in] gCb - RLC Instance Control Block
1302 * @param [in] ueId - UE Identifier
1303 * @param [in] cellId - CELL Identifier
1304 * @param [in] entCfg - Entity Configuration to be done.
1305 * @param [out] entCfm - Entity Confirmation
1316 RlcEntCfgInfo *entCfg,
1317 RlcEntCfgCfmInfo *entCfm
1320 S16 ret; /* Return Value */
1321 RlcDlUeCb *ueCb; /* UE Control Block */
1323 DU_LOG("\nDEBUG --> RLC_DL : rlcCfgDelUe(ueId(%d), cellId(%d), cfgType(%d))",
1330 /* Check for ueId is present or not */
1333 /* Fill entCfm structure */
1334 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1335 CKW_CFG_CFM_NOK, CKW_CFG_REAS_UE_UNKWN);
1336 DU_LOG("\nERROR --> RLC_DL : ueId(%d), cellId(%d)",
1343 ret = rlcDbmFetchDlUeCb(gCb,ueId, cellId, &ueCb);
1346 /* Fill entCfm structure */
1347 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1348 CKW_CFG_CFM_NOK, CKW_CFG_REAS_UE_UNKWN);
1349 DU_LOG("\nERROR --> RLC_DL : UEID:%d UeCb not found RBID:%d",
1356 rlcDelFrmDlL2Meas(gCb,cellId,ueId);
1357 rlcDbmDelAllDlL2MeasTbFrmUe(gCb,ueCb);
1360 rlcDbmDelDlUeCb(gCb,ueCb, FALSE);
1362 /* Fill entCfm structure */
1363 RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1364 CKW_CFG_CFM_OK, CKW_CFG_REAS_NONE);
1371 * @brief This primitive deletes the RBs in Ue Cb.
1374 * - If CELL ID is 0 then
1375 * - Status Indication with Reason
1377 * - Check for CELL CB is present
1378 * - If yes, Delete all RB CB in CELL CB and Delete CELL CB also.
1379 * - Else, Status Indication with Reason
1380 * - Fill entity confirmation
1382 * @param [in] cellId - CELL Identifier
1383 * @param [in] entCfg - Entity Configuration to be done.
1384 * @param [out] entCfm - Entity Confirmation
1394 RlcEntCfgInfo *entCfg,
1395 RlcEntCfgCfmInfo *entCfm
1398 RlcDlCellCb *cellCb; /* UE Control Block */
1399 uint8_t rbId; /* RB Identifier */
1401 DU_LOG("\nDEBUG --> RLC_DL : rlcCfgDelCell( cellId(%d), cfgType(%d)",
1406 rbId = entCfg->rbId;
1408 /* Check for ueId is present or not */
1411 /* Fill entCfm structure */
1412 RLC_CFG_FILL_CFG_CFM(entCfm, rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
1413 CKW_CFG_REAS_CELL_UNKWN);
1414 DU_LOG("\nERROR --> RLC_DL : cellId is 0 (%d) ",
1420 rlcDbmFetchDlCellCb(gCb,cellId, &cellCb);
1423 /* Fill entCfm structure */
1424 RLC_CFG_FILL_CFG_CFM(entCfm, rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
1425 CKW_CFG_REAS_CELL_UNKWN);
1426 DU_LOG("\nERROR --> RLC_DL : CellCb not found for RBID:%d",
1432 rlcDbmDelDlCellCb(gCb,cellCb);
1434 /* Fill entCfm structure */
1435 /* kw005.201 added support for L2 Measurement */
1436 RLC_CFG_FILL_CFG_CFM(entCfm, rbId, entCfg->rbType, CKW_CFG_CFM_OK,
1443 * @brief This primitive changes the ueId of Ue Cb.
1446 * - If oldUeId and newUeId are
1447 * - Confirm the Status with Reason
1448 * - If UeId not present
1449 * - Confirm the Status with Reason
1451 * - Copy rbCbs from old UeCb to new UeCb
1453 * - Fill entity confirmation
1455 * @param [in] ueInfo - Old UE Information
1456 * @param [in] newUeInfo - New UE Information
1457 * @param [out] status - Status
1463 S16 rlcCfgDlUeIdChng
1467 CkwUeInfo *newUeInfo,
1472 /*kw004.201 Adding of Missing Trace in RLC PDCP*/
1474 if ( (ueInfo->ueId == newUeInfo->ueId) &&
1475 (ueInfo->cellId == newUeInfo->cellId))
1477 status->reason = CKW_CFG_REAS_SAME_UEID;
1478 status->status = CKW_CFG_CFM_NOK;
1479 DU_LOG("\nERROR --> RLC_DL : Old UeId[%d] same as new UeId[%d]",
1485 if(ROK == rlcDbmFetchDlUeCb(gCb,newUeInfo->ueId, newUeInfo->cellId, &ueCb))
1487 DU_LOG("\nERROR --> RLC_DL : NewUeId[%d]:ueCb already exists",
1489 status->reason = CKW_CFG_REAS_UE_EXISTS;
1490 status->status = CKW_CFG_CFM_NOK;
1494 if(ROK != rlcDbmFetchDlUeCb(gCb,ueInfo->ueId, ueInfo->cellId, &ueCb))
1497 DU_LOG("\nERROR --> RLC_DL : UeId [%d]: UeCb not found",
1499 status->reason = CKW_CFG_REAS_UE_UNKWN;
1500 status->status = CKW_CFG_CFM_NOK;
1505 rlcHdlMeasDlUeIdChg(gCb, ueInfo->cellId, ueInfo->ueId, newUeInfo->ueId);
1507 if(ROK != cmHashListDelete(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb))
1509 DU_LOG("\nERROR --> RLC_DL : UeId[%u] HashList Deletion Failed",
1511 status->reason = CKW_CFG_REAS_UE_CREAT_FAIL;
1512 status->status = CKW_CFG_CFM_NOK;
1516 /* update the hash key with new values */
1517 ueCb->ueId = newUeInfo->ueId;
1518 ueCb->cellId = newUeInfo->cellId;
1520 if(ROK != cmHashListInsert(&(gCb->u.dlCb->ueLstCp),
1521 (PTR)ueCb, (uint8_t *)&(ueCb->ueId),
1522 (uint16_t) sizeof(CmLteRnti)))
1525 DU_LOG("\nERROR --> RLC_DL : UeId[%u] HashList Insertion Failed",
1527 status->reason = CKW_CFG_REAS_UE_CREAT_FAIL;
1528 status->status = CKW_CFG_CFM_NOK;
1535 /********************************************************************30**
1538 **********************************************************************/