1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /********************************************************************20**
21 Name: RLC - Database module file
25 Desc: Source code for Database Module functions such as,
49 *********************************************************************21*/
50 static const char* RLOG_MODULE_NAME="DBM";
51 static int RLOG_MODULE_ID=2048;
52 static int RLOG_FILE_ID=193;
55 /* header (.h) include files */
56 #include "common_def.h"
57 #include "lkw.h" /* LKW defines */
58 #include "ckw.h" /* CKW defines */
59 #include "rgu.h" /* RGU defines */
60 #include "kwu.h" /* KWU defines */
61 #include "kw_err.h" /* Err defines */
62 #include "kw_env.h" /* RLC environment options */
63 #include "kw.h" /* RLC defines */
67 /* extern (.x) include files */
68 #include "lkw.x" /* LKW */
69 #include "ckw.x" /* CKW */
70 #include "rgu.x" /* RGU */
71 #include "kwu.x" /* KWU */
78 TSL2UeStatsCb* TSL2MapUeStatsBlk (uint16_t rnti);
82 * @brief RLC Downlink database module
84 #define RLC_MODULE RLC_DBGMASK_DUT
88 * @brief Handler to initialize hash list
91 * This function initializes the UeCb, CellCb hash lists
103 S16 rlcDbmDlInit(gCb)
108 /* Initialize ueCb Hash List */
109 if(ROK != cmHashListInit(&(gCb->u.dlCb->ueLstCp),
110 (uint16_t) RLC_UE_LIST_BUCKET_SIZE,
113 (uint16_t) CM_HASH_KEYTYPE_CONID,
114 RLC_GET_MEM_REGION(gCb),
115 RLC_GET_MEM_POOL(gCb)))
117 RLOG0(L_ERROR, "UeLstCp Initialization Failed");
121 /* Initialize cellCb Hash List */
122 if(ROK != cmHashListInit(&(gCb->u.dlCb->cellLstCp),
123 (uint16_t) RLC_CELL_LIST_BUCKET_SIZE,
126 (uint16_t) CM_HASH_KEYTYPE_CONID,
127 RLC_GET_MEM_REGION(gCb),
128 RLC_GET_MEM_POOL(gCb)))
130 cmHashListDeinit(&gCb->u.dlCb->ueLstCp);
131 RLOG0(L_ERROR, "CellLstCp Initialization Failed");
135 /* kw005.201 added support for L2 Measurement */
136 #ifdef LTE_L2_MEAS_RLC
137 /* Initialize qcI Hash List */
138 if(ROK != cmHashListInit(&(rlcCb.rlcL2Cb.qciHlCp),
139 (uint16_t) RLC_QCI_LIST_BUCKET_SIZE,
142 (uint16_t) CM_HASH_KEYTYPE_DEF,
146 cmHashListDeinit(&gCb->u.dlCb->cellLstCp);
147 cmHashListDeinit(&gCb->u.dlCb->ueLstCp);
148 RLOG0(L_ERROR, "rlcDbmInit: cmHashListInit Failed for rlcCb.qciHlCp");
152 /* Initialize tbHlCp Hash List */
153 if(ROK != cmHashListInit(&(rlcCb.rlcL2Cb.tbHlCp),
154 (uint16_t) RLC_TB_LIST_BUCKET_SIZE,
157 (uint16_t) CM_HASH_KEYTYPE_DEF,
161 cmHashListDeinit(&rlcCb.rlcL2Cb.qciHlCp);
162 cmHashListDeinit(&gCb->u.dlCb->cellLstCp);
163 cmHashListDeinit(&gCb->u.dlCb->ueLstCp);
164 RLOG0(L_ERROR, "rlcDbmInit: cmHashListInit Failed for rlcCb.tbHlCp");
167 #endif /* LTE_L2_MEAS */
174 * @brief Handler to De initialize hash list
176 * @param[in] gCb RLC Instance Control Block
186 Void rlcDbmDlDeInit(gCb)
192 /* De Initialize ueCb Hash List */
193 cmHashListDeinit(&(gCb->u.dlCb->ueLstCp));
195 /* De Initialize cellCb Hash List */
196 cmHashListDeinit(&(gCb->u.dlCb->cellLstCp));
198 /* kw005.201 added support for L2 Measurement */
199 #ifdef LTE_L2_MEAS_RLC
200 /* De Initialize qciCb Hash List */
201 cmHashListDeinit(&(rlcCb.rlcL2Cb.qciHlCp));
203 /* De Initialize tbHlCp Hash List */
204 cmHashListDeinit(&(rlcCb.rlcL2Cb.tbHlCp));
206 #endif /* LTE_L2_MEAS */
209 } /* rlcDbmDlDeInit */
213 * @brief Handler to fetch rbCb by the rlcId
216 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb in
217 * the upper interface (CKW/KWU).
219 * @param[in] gCb RLC Instance Control Block
220 * @param[in] rlcId RLC Identifier
221 * @param[out] rbCb RB Control Block
225 void rlcDbmFetchDlRbCbByRbId(RlcCb *gCb,CmLteRlcId *rlcId, RlcDlRbCb **rbCb)
229 /* Check for UE CB or CELL CB */
230 if (rlcId->ueId == 0)
234 if(rlcId->rbId >= RLC_MAX_RB_PER_CELL)
236 DU_LOG("\nRLC : rlcDbmFetchDlRbCbByRbId : Invalid RbId, Max is [%d] \
237 UEID:%d CELLID:%d", RLC_MAX_RB_PER_CELL, rlcId->ueId, rlcId->cellId);
241 rlcDbmFetchDlCellCb(gCb,rlcId->cellId, &cellCb);
244 DU_LOG("\nRLC : rlcDbmFetchDlRbCbByRbId : CellCb[%d] not found UEID:%d \
245 RBID:%d", rlcId->cellId, rlcId->ueId, rlcId->rbId);
249 *rbCb = cellCb->rbCb[rlcId->rbId];
254 if (!(RLC_VALIDATE_UE_RBID(rlcId->rbType, rlcId->rbId)))
256 DU_LOG("\n rlcDbmFetchDlRbCbByRbId : Invalid RbId[%d] for RbType[%d] \
257 RBID:%d CELLID:%d", rlcId->rbId, rlcId->rbType, rlcId->ueId, rlcId->cellId);
261 if (ROK != rlcDbmFetchDlUeCb(gCb,rlcId->ueId, rlcId->cellId, &ueCb))
263 DU_LOG("\n rlcDbmFetchDlRbCbByRbId : UeId [%d]: UeCb not found RBID:%d",\
264 rlcId->ueId, rlcId->rbId);
268 RLC_DBM_GET_RBCB_FROM_UECB(rlcId->rbId, rlcId->rbType, ueCb, *rbCb);
272 } /* rlcDbmFetchDlRbCbByRbId */
276 * @brief Handler to fetch rbCb from Local Channel Id
279 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb
280 * from local Channel Id (CKW/KWU).
282 * @param[in] gCb - RLC Instance Control Block
283 * @param[in] cellId - CELL Identifier
284 * @param[in] ueId - UE Identifier
285 * @param[in] lcId - Logical Channel Identifier
286 * @param[out] rbCb - RB Control Block
291 void rlcDbmFetchDlRbCbFromLchId(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId, \
292 CmLteLcId lcId, RlcDlRbCb **rbCb)
296 /* Check for UE CB or CELL CB */
301 rlcDbmFetchDlCellCb(gCb, cellId, &cellCb);
304 DU_LOG("\nRLC: rlcDbmFetchDlRbCbFromLchId: CellCb[%d] not found UEID:%d", \
309 *rbCb = cellCb->lCh[lcId - 1].dlRbCb;
313 if (rlcDbmFetchDlUeCb(gCb, ueId, cellId, &ueCb) != ROK)
315 DU_LOG("\nRLC: rlcDbmFetchDlRbCbFromLchId: UeId [%d]: UeCb not found",ueId);
319 *rbCb = ueCb->lCh[lcId - 1].dlRbCb;
322 } /* rlcDbmFetchDlRbCbFromLchId */
326 * @brief Handler to delete RbCb
329 * This function is invoked by CFG to remove RbCb from Ue/Cell hashlist
331 * @param[in] gCb - RLC Instance Control Block
332 * @param[in] rbCbLst - Rb Cb List
333 * @param[in] numRbCb - Number of rbCbs
339 Void rlcDbmDelAllDlRb
346 Void rlcDbmDelAllDlRb(gCb, rbCbLst, numRbCb)
355 for (idx = 0; idx < numRbCb; idx++)
357 if (rbCbLst[idx] != NULLP)
360 RLC_UPD_L2_DECR_NONIP_PER_QCI_RB_COUNT(gCb, (rbCbLst[idx]));
362 if( CM_LTE_MODE_UM == rbCbLst[idx]->mode)
364 rlcUmmFreeDlRbCb(gCb,rbCbLst[idx]);
366 RLC_FREE (gCb,rbCbLst[idx], sizeof (RlcDlRbCb));
368 else if( CM_LTE_MODE_AM == rbCbLst[idx]->mode)
370 rlcAmmFreeDlRbCb(gCb,rbCbLst[idx]);
373 else if(CM_LTE_MODE_TM == rbCbLst[idx]->mode)
375 cmLListCatLList(&(gCb->u.dlCb->toBeFreed.sduLst),&(rbCbLst[idx]->m.tm.sduQ));
376 RLC_FREE (gCb,rbCbLst[idx], sizeof (RlcDlRbCb));
384 } /* rlcDbmDelAllDlRb */
388 * @brief Handler to create an UeCb
391 * This function is invoked by CFG to create UeCb and insert into the
392 * Ue hashlist of RlcCb.
394 * @param[in] gCb RLC Instance Control Block
395 * @param[in] ueId UE Identifier
396 * @param[in] cellId Cell Identifier
397 * @param[in] ueCb UE Control Block
405 S16 rlcDbmCreateDlUeCb
413 S16 rlcDbmCreateDlUeCb(gCb,ueId, cellId, ueCb)
422 RLC_ALLOC(gCb,*ueCb, sizeof(RlcDlUeCb));
424 #if (ERRCLASS & ERRCLS_ADD_RES)
427 RLOG_ARG1(L_FATAL,DBG_UEID,ueId,
428 "Memory allocation failed cellID:%d",
432 #endif /* ERRCLASS & ERRCLS_ADD_RES */
436 tUeCb->cellId = cellId;
438 if (ROK != cmHashListInsert(&(gCb->u.dlCb->ueLstCp),
440 (uint8_t *)&(tUeCb->ueId),
441 (uint16_t) sizeof(CmLteRnti)))
443 RLOG_ARG1(L_ERROR,DBG_CELLID,cellId,
444 "UeId[%u] HashList Insertion Failed",
448 /* kw005.201 ccpu00117318, updating the statistics */
453 } /* kwDbmCreateUeCb */
457 * @brief Handler to Fetch an UeCb
460 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
463 * @param[in] gCb RLC Instance Control Block
464 * @param[in] ueId UE Identifier
465 * @param[in] cellId Cell Identifier
466 * @param[out] ueCb UE Control Block
472 uint8_t rlcDbmFetchDlUeCb(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId, RlcDlUeCb **ueCb)
474 return (cmHashListFind(&(gCb->u.dlCb->ueLstCp),
479 } /* rlcDbmFetchDlUeCb */
483 * @brief Handler to delete an UeCb
486 * This function is invoked by CFG to delete UeCb from the Ue hashlist
490 * @param[in] gCb RLC Instance Control Block
491 * @param[in] ueCb UE Control Block
492 * @param[in] abrtFlag Abort Flag
505 Void rlcDbmDelDlUeCb(gCb,eCb, abortFlag)
512 #if (!defined(KW_PDCP) || !(defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)))
514 #endif /* (!defined(KW_PDCP) || ! (defined(PJ_SEC_ASYNC) ||
515 defined(PJ_CMP_ASYNC)))*/
517 /* Delete all logical channels */
518 RLC_MEM_ZERO(ueCb->lCh,sizeof(RlcDlLch) * RLC_MAX_LCH_PER_UE);
520 /* Delete all SRB RbCbs in UeCb */
521 rlcDbmDelAllDlRb(gCb,ueCb->srbCb, RLC_MAX_SRB_PER_UE);
523 /* Delete all DRB RbCbs in UeCb */
524 rlcDbmDelAllDlRb(gCb,ueCb->drbCb, RLC_MAX_DRB_PER_UE);
526 /* Delete ueCb entry from ueLstCp */
527 if(ROK != cmHashListDelete(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb))
529 RLOG_ARG1(L_ERROR,DBG_CELLID,ueCb->cellId,
530 "UeId[%u] HashList Insertion Failed",
533 /* kw005.201 ccpu00117318, updating the statistics */
536 /* Deallocate ueCb */
537 RLC_FREE(gCb,ueCb, sizeof(RlcDlUeCb));
544 * @brief Handler to delete all UeCbs
547 * This function is invoked by CFG to delete all UeCbs from the Ue
550 * @param[in] gCb RLC Instance Control Block
555 Void rlcDbmDelAllDlUe
560 Void rlcDbmDelAllDlUe(gCb)
564 RlcDlUeCb *ueCb = NULLP;
566 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
567 while (ROK == cmHashListGetNext(&(gCb->u.dlCb->ueLstCp),
572 rlcDbmDelDlUeCb(gCb,ueCb, TRUE);
578 } /* kwDbmDelAllUe */
580 /* kw005.201 added support for L2 Measurement */
583 Void rlcDbmDelAllDlL2MeasTbFrmUe
589 Void rlcDbmDelAllDlL2MeasTbFrmUe(gCb,ueCb)
595 RlcL2MeasTb *l2MeasTb = NULLP;
596 for(tbIdx = 0; tbIdx < RLC_MAX_TB_PER_UE; tbIdx++)
598 l2MeasTb = ueCb->l2MeasTbCb[tbIdx];
599 if(l2MeasTb != NULLP)
601 RLC_FREE(gCb,l2MeasTb, sizeof(RlcL2MeasTb));
602 ueCb->l2MeasTbCb[tbIdx] = NULLP;
606 }/* End of kwDbmDelL2MeasTb */
607 #endif /* LTE_L2_MEAS */
610 * @brief Handler to create CellCb
613 * This function is invoked by CFG to create CellCb and insert into
614 * the Cell hashlist of RlcCb.
616 * @param[in] gCb RLC Instance Control Block
617 * @param[in] cellId Cell Identifier
618 * @param[in] cellCb Cell Control Block
625 S16 rlcDbmCreateDlCellCb
632 S16 rlcDbmCreateDlCellCb(gCb,cellId, cellCb)
635 RlcDlCellCb **cellCb;
638 RlcDlCellCb *tCellCb;
641 RLC_ALLOC(gCb,*cellCb, sizeof(RlcDlCellCb));
642 #if (ERRCLASS & ERRCLS_ADD_RES)
643 if (*cellCb == NULLP)
645 RLOG_ARG0(L_FATAL, DBG_CELLID,cellId,"Memory allocation failed");
648 #endif /* ERRCLASS & ERRCLS_ADD_RES */
651 tCellCb->cellId = cellId;
653 if(ROK != cmHashListInsert(&(gCb->u.dlCb->cellLstCp),
655 (uint8_t *)&(tCellCb->cellId),
656 (uint16_t) sizeof(CmLteCellId)))
658 RLOG_ARG0(L_ERROR,DBG_CELLID,cellId,"HashList Insertion Failed");
663 } /* rlcDbmCreateDlCellCb */
667 * @brief Handler to Fetch an CellCb
670 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
673 * @param[in] gCb RLC Instance Control Block
674 * @param[in] cellId Cell Identifier
675 * @param[out] cellCb UE Control Block
682 uint8_t rlcDbmFetchDlCellCb(RlcCb *gCb, CmLteCellId cellId, RlcDlCellCb **cellCb)
686 if(ROK != cmHashListFind(&(gCb->u.dlCb->cellLstCp),
687 (uint8_t *)&(cellId),
692 DU_LOG("\nRLC : CellCb [%d] not found", cellId);
697 } /* kwDbmFetchCellCb */
701 * @brief Handler to delete CellCb
704 * This function is invoked by CFG to delete CellCb from the Cell hashlist
707 * @param[in] gCb RLC Instance Control Block
708 * @param[in] cellCb Cell Control Block
713 Void rlcDbmDelDlCellCb
719 Void rlcDbmDelDlCellCb(gCb,cellCb)
725 /* Delete all rbCbs in cellCb */
726 rlcDbmDelAllDlRb(gCb,cellCb->rbCb, RLC_MAX_RB_PER_CELL);
728 /* Delete cellCb entry in hash list cellLstCp */
729 if(ROK != cmHashListDelete(&(gCb->u.dlCb->cellLstCp), (PTR) cellCb))
731 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"HashList Deletion Failed");
734 /* Deallocate cellCb */
735 RLC_FREE(gCb, cellCb, sizeof(RlcDlCellCb));
738 } /* kwDbmDelCellCb */
742 * @brief Handler to delete all UeCbs
745 * This function is invoked by CFG to delete all UeCbs from the Ue
747 * @param[in] gCb RLC Instance Control Block
752 Void rlcDbmDelAllDlCell
757 Void rlcDbmDelAllDlCell(gCb)
761 RlcDlCellCb *cellCb = NULLP;
763 /* Until no more cellCb is ueLstCp hash list get and delete cellCb */
764 while (ROK == cmHashListGetNext(&(gCb->u.dlCb->cellLstCp),
768 rlcDbmDelDlCellCb(gCb, cellCb);
774 } /* rlcDbmDelAllDlCell */
778 * @brief Handler to delete all UeCbs and CellCbs
781 * This function is invoked by LMM to delete all UeCbs from the Ue
782 * hashlist of RlcCb and cellCbs from the Cell hashlist of rlcCb.
784 * @param[in] gCb RLC Instance Control Block
794 S16 rlcDbmDlShutdown(gCb)
799 rlcDbmDelAllDlCell(gCb);
801 rlcDbmDelAllDlUe(gCb);
807 } /* kwDbmShutdown */
810 /********************************************************************30**
813 **********************************************************************/