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*/
52 /* header (.h) include files */
53 #include "common_def.h"
54 #include "lkw.h" /* LKW defines */
55 #include "ckw.h" /* CKW defines */
56 #include "rgu.h" /* RGU defines */
57 #include "kwu.h" /* KWU defines */
58 #include "kw_err.h" /* Err defines */
59 #include "kw_env.h" /* RLC environment options */
60 #include "kw.h" /* RLC defines */
64 /* extern (.x) include files */
65 #include "lkw.x" /* LKW */
66 #include "ckw.x" /* CKW */
67 #include "rgu.x" /* RGU */
68 #include "kwu.x" /* KWU */
75 TSL2UeStatsCb* TSL2MapUeStatsBlk (uint16_t rnti);
79 * @brief RLC Downlink database module
81 #define RLC_MODULE RLC_DBGMASK_DUT
85 * @brief Handler to initialize hash list
88 * This function initializes the UeCb, CellCb hash lists
94 S16 rlcDbmDlInit(RlcCb *gCb)
97 /* Initialize ueCb Hash List */
98 if(ROK != cmHashListInit(&(gCb->u.dlCb->ueLstCp),
99 (uint16_t) RLC_UE_LIST_BUCKET_SIZE,
102 (uint16_t) CM_HASH_KEYTYPE_CONID,
103 RLC_GET_MEM_REGION(gCb),
104 RLC_GET_MEM_POOL(gCb)))
106 DU_LOG("\nERROR --> RLC_DL : UeLstCp Initialization Failed");
110 /* Initialize cellCb Hash List */
111 if(ROK != cmHashListInit(&(gCb->u.dlCb->cellLstCp),
112 (uint16_t) RLC_CELL_LIST_BUCKET_SIZE,
115 (uint16_t) CM_HASH_KEYTYPE_CONID,
116 RLC_GET_MEM_REGION(gCb),
117 RLC_GET_MEM_POOL(gCb)))
119 cmHashListDeinit(&gCb->u.dlCb->ueLstCp);
120 DU_LOG("\nERROR --> RLC_DL : CellLstCp Initialization Failed");
124 /* kw005.201 added support for L2 Measurement */
125 #ifdef LTE_L2_MEAS_RLC
126 /* Initialize qcI Hash List */
127 if(ROK != cmHashListInit(&(rlcCb.rlcL2Cb.qciHlCp),
128 (uint16_t) RLC_QCI_LIST_BUCKET_SIZE,
131 (uint16_t) CM_HASH_KEYTYPE_DEF,
135 cmHashListDeinit(&gCb->u.dlCb->cellLstCp);
136 cmHashListDeinit(&gCb->u.dlCb->ueLstCp);
137 DU_LOG("\nERROR --> RLC_DL : rlcDbmInit: cmHashListInit Failed for rlcCb.qciHlCp");
141 /* Initialize tbHlCp Hash List */
142 if(ROK != cmHashListInit(&(rlcCb.rlcL2Cb.tbHlCp),
143 (uint16_t) RLC_TB_LIST_BUCKET_SIZE,
146 (uint16_t) CM_HASH_KEYTYPE_DEF,
150 cmHashListDeinit(&rlcCb.rlcL2Cb.qciHlCp);
151 cmHashListDeinit(&gCb->u.dlCb->cellLstCp);
152 cmHashListDeinit(&gCb->u.dlCb->ueLstCp);
153 DU_LOG("\nERROR --> RLC_DL : rlcDbmInit: cmHashListInit Failed for rlcCb.tbHlCp");
156 #endif /* LTE_L2_MEAS */
163 * @brief Handler to De initialize hash list
165 * @param[in] gCb RLC Instance Control Block
169 Void rlcDbmDlDeInit(RlcCb *gCb)
173 /* De Initialize ueCb Hash List */
174 cmHashListDeinit(&(gCb->u.dlCb->ueLstCp));
176 /* De Initialize cellCb Hash List */
177 cmHashListDeinit(&(gCb->u.dlCb->cellLstCp));
179 /* kw005.201 added support for L2 Measurement */
180 #ifdef LTE_L2_MEAS_RLC
181 /* De Initialize qciCb Hash List */
182 cmHashListDeinit(&(rlcCb.rlcL2Cb.qciHlCp));
184 /* De Initialize tbHlCp Hash List */
185 cmHashListDeinit(&(rlcCb.rlcL2Cb.tbHlCp));
187 #endif /* LTE_L2_MEAS */
190 } /* rlcDbmDlDeInit */
194 * @brief Handler to fetch rbCb by the rlcId
197 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb in
198 * the upper interface (CKW/KWU).
200 * @param[in] gCb RLC Instance Control Block
201 * @param[in] rlcId RLC Identifier
202 * @param[out] rbCb RB Control Block
206 void rlcDbmFetchDlRbCbByRbId(RlcCb *gCb,CmLteRlcId *rlcId, RlcDlRbCb **rbCb)
210 /* Check for UE CB or CELL CB */
211 if (rlcId->ueId == 0)
215 if(rlcId->rbId >= RLC_MAX_RB_PER_CELL)
217 DU_LOG("\nERROR --> RLC_DL : rlcDbmFetchDlRbCbByRbId : Invalid RbId, Max is [%d] \
218 UEID:%d CELLID:%d", RLC_MAX_RB_PER_CELL, rlcId->ueId, rlcId->cellId);
222 rlcDbmFetchDlCellCb(gCb,rlcId->cellId, &cellCb);
225 DU_LOG("\nERROR --> RLC_DL : rlcDbmFetchDlRbCbByRbId : CellCb[%d] not found UEID:%d \
226 RBID:%d", rlcId->cellId, rlcId->ueId, rlcId->rbId);
230 *rbCb = cellCb->rbCb[rlcId->rbId];
235 if (!(RLC_VALIDATE_UE_RBID(rlcId->rbType, rlcId->rbId)))
237 DU_LOG("\nERROR --> RLC_DL : rlcDbmFetchDlRbCbByRbId : Invalid RbId[%d] for RbType[%d] \
238 RBID:%d CELLID:%d", rlcId->rbId, rlcId->rbType, rlcId->ueId, rlcId->cellId);
242 if (ROK != rlcDbmFetchDlUeCb(gCb,rlcId->ueId, rlcId->cellId, &ueCb))
244 DU_LOG("\nERROR --> RLC_DL : rlcDbmFetchDlRbCbByRbId : UeId [%d]: UeCb not found RBID:%d",\
245 rlcId->ueId, rlcId->rbId);
249 RLC_DBM_GET_RBCB_FROM_UECB(rlcId->rbId, rlcId->rbType, ueCb, *rbCb);
253 } /* rlcDbmFetchDlRbCbByRbId */
257 * @brief Handler to fetch rbCb from Local Channel Id
260 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb
261 * from local Channel Id (CKW/KWU).
263 * @param[in] gCb - RLC Instance Control Block
264 * @param[in] cellId - CELL Identifier
265 * @param[in] ueId - UE Identifier
266 * @param[in] lcId - Logical Channel Identifier
267 * @param[out] rbCb - RB Control Block
272 void rlcDbmFetchDlRbCbFromLchId(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId, \
273 CmLteLcId lcId, RlcDlRbCb **rbCb)
277 /* Check for UE CB or CELL CB */
282 rlcDbmFetchDlCellCb(gCb, cellId, &cellCb);
285 DU_LOG("\nERROR --> RLC_DL : rlcDbmFetchDlRbCbFromLchId: CellCb[%d] not found UEID:%d", \
290 *rbCb = cellCb->lCh[lcId - 1].dlRbCb;
294 if (rlcDbmFetchDlUeCb(gCb, ueId, cellId, &ueCb) != ROK)
296 DU_LOG("\nERROR --> RLC_DL : rlcDbmFetchDlRbCbFromLchId: UeId [%d]: UeCb not found",ueId);
300 *rbCb = ueCb->lCh[lcId - 1].dlRbCb;
303 } /* rlcDbmFetchDlRbCbFromLchId */
307 * @brief Handler to delete RbCb
310 * This function is invoked by CFG to remove RbCb from Ue/Cell hashlist
312 * @param[in] gCb - RLC Instance Control Block
313 * @param[in] rbCbLst - Rb Cb List
314 * @param[in] numRbCb - Number of rbCbs
319 Void rlcDbmDelAllDlRb(RlcCb *gCb,RlcDlRbCb **rbCbLst,uint8_t numRbCb)
324 for (idx = 0; idx < numRbCb; idx++)
326 if (rbCbLst[idx] != NULLP)
329 RLC_UPD_L2_DECR_NONIP_PER_QCI_RB_COUNT(gCb, (rbCbLst[idx]));
331 if( RLC_MODE_UM == rbCbLst[idx]->mode)
333 rlcUmmFreeDlRbCb(gCb,rbCbLst[idx]);
335 RLC_FREE (gCb,rbCbLst[idx], sizeof (RlcDlRbCb));
337 else if( RLC_MODE_AM == rbCbLst[idx]->mode)
339 rlcAmmFreeDlRbCb(gCb,rbCbLst[idx]);
342 else if(RLC_MODE_TM == rbCbLst[idx]->mode)
344 cmLListCatLList(&(gCb->u.dlCb->toBeFreed.sduLst),&(rbCbLst[idx]->m.tm.sduQ));
345 RLC_FREE (gCb,rbCbLst[idx], sizeof (RlcDlRbCb));
353 } /* rlcDbmDelAllDlRb */
357 * @brief Handler to create an UeCb
360 * This function is invoked by CFG to create UeCb and insert into the
361 * Ue hashlist of RlcCb.
363 * @param[in] gCb RLC Instance Control Block
364 * @param[in] ueId UE Identifier
365 * @param[in] cellId Cell Identifier
366 * @param[in] ueCb UE Control Block
373 S16 rlcDbmCreateDlUeCb(RlcCb *gCb,CmLteRnti ueId,CmLteCellId cellId,RlcDlUeCb **ueCb)
377 RLC_ALLOC(gCb,*ueCb, sizeof(RlcDlUeCb));
379 #if (ERRCLASS & ERRCLS_ADD_RES)
382 DU_LOG("\nERROR --> RLC_DL : Memory allocation failed cellID:%d",
386 #endif /* ERRCLASS & ERRCLS_ADD_RES */
390 tUeCb->cellId = cellId;
392 if (ROK != cmHashListInsert(&(gCb->u.dlCb->ueLstCp),
394 (uint8_t *)&(tUeCb->ueId),
395 (uint16_t) sizeof(CmLteRnti)))
397 DU_LOG("\nERROR --> RLC_DL : UeId[%u] HashList Insertion Failed",
401 /* kw005.201 ccpu00117318, updating the statistics */
406 } /* kwDbmCreateUeCb */
410 * @brief Handler to Fetch an UeCb
413 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
416 * @param[in] gCb RLC Instance Control Block
417 * @param[in] ueId UE Identifier
418 * @param[in] cellId Cell Identifier
419 * @param[out] ueCb UE Control Block
425 uint8_t rlcDbmFetchDlUeCb(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId, RlcDlUeCb **ueCb)
427 return (cmHashListFind(&(gCb->u.dlCb->ueLstCp),
432 } /* rlcDbmFetchDlUeCb */
436 * @brief Handler to delete an UeCb
439 * This function is invoked by CFG to delete UeCb from the Ue hashlist
443 * @param[in] gCb RLC Instance Control Block
444 * @param[in] ueCb UE Control Block
445 * @param[in] abrtFlag Abort Flag
450 Void rlcDbmDelDlUeCb(RlcCb *gCb,RlcDlUeCb *ueCb,Bool abortFlag)
453 #if (!defined(KW_PDCP) || !(defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)))
455 #endif /* (!defined(KW_PDCP) || ! (defined(PJ_SEC_ASYNC) ||
456 defined(PJ_CMP_ASYNC)))*/
458 /* Delete all logical channels */
459 RLC_MEM_ZERO(ueCb->lCh,sizeof(RlcDlLch) * RLC_MAX_LCH_PER_UE);
461 /* Delete all SRB RbCbs in UeCb */
462 rlcDbmDelAllDlRb(gCb,ueCb->srbCb, RLC_MAX_SRB_PER_UE);
464 /* Delete all DRB RbCbs in UeCb */
465 rlcDbmDelAllDlRb(gCb,ueCb->drbCb, RLC_MAX_DRB_PER_UE);
467 /* Delete ueCb entry from ueLstCp */
468 if(ROK != cmHashListDelete(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb))
470 DU_LOG("\nERROR --> RLC_DL : UeId[%u] HashList Insertion Failed",
473 /* kw005.201 ccpu00117318, updating the statistics */
476 /* Deallocate ueCb */
477 RLC_FREE(gCb,ueCb, sizeof(RlcDlUeCb));
484 * @brief Handler to delete all UeCbs
487 * This function is invoked by CFG to delete all UeCbs from the Ue
490 * @param[in] gCb RLC Instance Control Block
494 Void rlcDbmDelAllDlUe(RlcCb *gCb)
496 RlcDlUeCb *ueCb = NULLP;
498 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
499 while (ROK == cmHashListGetNext(&(gCb->u.dlCb->ueLstCp),
504 rlcDbmDelDlUeCb(gCb,ueCb, TRUE);
510 } /* kwDbmDelAllUe */
512 /* kw005.201 added support for L2 Measurement */
514 Void rlcDbmDelAllDlL2MeasTbFrmUe(RlcCb *gCb,RlcDlUeCb *ueCb)
517 RlcL2MeasTb *l2MeasTb = NULLP;
518 for(tbIdx = 0; tbIdx < RLC_MAX_TB_PER_UE; tbIdx++)
520 l2MeasTb = ueCb->l2MeasTbCb[tbIdx];
521 if(l2MeasTb != NULLP)
523 RLC_FREE(gCb,l2MeasTb, sizeof(RlcL2MeasTb));
524 ueCb->l2MeasTbCb[tbIdx] = NULLP;
528 }/* End of kwDbmDelL2MeasTb */
529 #endif /* LTE_L2_MEAS */
532 * @brief Handler to create CellCb
535 * This function is invoked by CFG to create CellCb and insert into
536 * the Cell hashlist of RlcCb.
538 * @param[in] gCb RLC Instance Control Block
539 * @param[in] cellId Cell Identifier
540 * @param[in] cellCb Cell Control Block
546 S16 rlcDbmCreateDlCellCb(RlcCb *gCb,CmLteCellId cellId,RlcDlCellCb **cellCb)
548 RlcDlCellCb *tCellCb;
551 RLC_ALLOC(gCb,*cellCb, sizeof(RlcDlCellCb));
552 #if (ERRCLASS & ERRCLS_ADD_RES)
553 if (*cellCb == NULLP)
555 DU_LOG("\nERROR --> RLC_DL : Memory allocation failed");
558 #endif /* ERRCLASS & ERRCLS_ADD_RES */
561 tCellCb->cellId = cellId;
563 if(ROK != cmHashListInsert(&(gCb->u.dlCb->cellLstCp),
565 (uint8_t *)&(tCellCb->cellId),
566 (uint16_t) sizeof(CmLteCellId)))
568 DU_LOG("\nERROR --> RLC_DL : HashList Insertion Failed");
573 } /* rlcDbmCreateDlCellCb */
577 * @brief Handler to Fetch an CellCb
580 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
583 * @param[in] gCb RLC Instance Control Block
584 * @param[in] cellId Cell Identifier
585 * @param[out] cellCb UE Control Block
592 uint8_t rlcDbmFetchDlCellCb(RlcCb *gCb, CmLteCellId cellId, RlcDlCellCb **cellCb)
596 if(ROK != cmHashListFind(&(gCb->u.dlCb->cellLstCp),
597 (uint8_t *)&(cellId),
602 DU_LOG("\nERROR --> RLC_DL : CellCb [%d] not found", cellId);
607 } /* kwDbmFetchCellCb */
611 * @brief Handler to delete CellCb
614 * This function is invoked by CFG to delete CellCb from the Cell hashlist
617 * @param[in] gCb RLC Instance Control Block
618 * @param[in] cellCb Cell Control Block
622 Void rlcDbmDelDlCellCb(RlcCb *gCb,RlcDlCellCb *cellCb)
625 /* Delete all rbCbs in cellCb */
626 rlcDbmDelAllDlRb(gCb,cellCb->rbCb, RLC_MAX_RB_PER_CELL);
628 /* Delete cellCb entry in hash list cellLstCp */
629 if(ROK != cmHashListDelete(&(gCb->u.dlCb->cellLstCp), (PTR) cellCb))
631 DU_LOG("\nERROR --> RLC_DL : HashList Deletion Failed");
634 /* Deallocate cellCb */
635 RLC_FREE(gCb, cellCb, sizeof(RlcDlCellCb));
638 } /* kwDbmDelCellCb */
642 * @brief Handler to delete all UeCbs
645 * This function is invoked by CFG to delete all UeCbs from the Ue
647 * @param[in] gCb RLC Instance Control Block
651 Void rlcDbmDelAllDlCell(RlcCb *gCb)
653 RlcDlCellCb *cellCb = NULLP;
655 /* Until no more cellCb is ueLstCp hash list get and delete cellCb */
656 while (ROK == cmHashListGetNext(&(gCb->u.dlCb->cellLstCp),
660 rlcDbmDelDlCellCb(gCb, cellCb);
666 } /* rlcDbmDelAllDlCell */
670 * @brief Handler to delete all UeCbs and CellCbs
673 * This function is invoked by LMM to delete all UeCbs from the Ue
674 * hashlist of RlcCb and cellCbs from the Cell hashlist of rlcCb.
676 * @param[in] gCb RLC Instance Control Block
680 S16 rlcDbmDlShutdown(RlcCb *gCb)
683 rlcDbmDelAllDlCell(gCb);
685 rlcDbmDelAllDlUe(gCb);
691 } /* kwDbmShutdown */
694 /********************************************************************30**
697 **********************************************************************/