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,
29 *********************************************************************21*/
30 static const char* RLOG_MODULE_NAME="DBM";
31 static int RLOG_MODULE_ID=2048;
32 static int RLOG_FILE_ID=194;
35 /* header (.h) include files */
36 #include "common_def.h"
37 #include "lkw.h" /* LKW defines */
38 #include "ckw.h" /* CKW defines */
39 #include "kwu.h" /* KWU defines */
40 #include "rgu.h" /* RGU defines */
41 #include "kw_err.h" /* Err defines */
42 #include "kw_env.h" /* RLC environment options */
44 #include "kw.h" /* RLC defines */
47 /* extern (.x) include files */
48 #include "lkw.x" /* LKW */
49 #include "ckw.x" /* CKW */
50 #include "kwu.x" /* KWU */
51 #include "rgu.x" /* RGU */
58 * @brief RLC Uplink database module
61 #define RLC_MODULE RLC_DBGMASK_DUT
65 * @brief Handler to initialize hash list
68 * This function initializes the UeCb, CellCb and transactions hash lists
70 * @param[in] gCb RLC instance control block
86 /* Initialize ueCb Hash List */
87 if(ROK != cmHashListInit(&(gCb->u.ulCb->ueLstCp),
88 (uint16_t) RLC_UE_LIST_BUCKET_SIZE,
91 (uint16_t) CM_HASH_KEYTYPE_CONID,
92 RLC_GET_MEM_REGION(gCb),
93 RLC_GET_MEM_POOL(gCb)))
95 RLOG0(L_ERROR, "UeLstCp Initialization Failed");
99 /* Initialize cellCb Hash List */
100 if(ROK != cmHashListInit(&(gCb->u.ulCb->cellLstCp),
101 (uint16_t) RLC_CELL_LIST_BUCKET_SIZE,
104 (uint16_t) CM_HASH_KEYTYPE_CONID,
105 RLC_GET_MEM_REGION(gCb),
106 RLC_GET_MEM_POOL(gCb)))
108 cmHashListDeinit(&gCb->u.ulCb->ueLstCp);
109 RLOG0(L_ERROR, "CellLstCp Initialization Failed");
113 if(ROK != cmHashListInit(&(gCb->u.ulCb->transIdLstCp),
114 (uint16_t) RLC_TRANS_ID_LST_BKT_SIZE,
117 (uint16_t) CM_HASH_KEYTYPE_CONID,
118 RLC_GET_MEM_REGION(gCb),
119 RLC_GET_MEM_POOL(gCb)))
121 cmHashListDeinit(&gCb->u.ulCb->ueLstCp);
122 cmHashListDeinit(&gCb->u.ulCb->cellLstCp);
123 RLOG0(L_ERROR, "transIdLstCp Initialization Failed");
127 /* kw005.201 added support for L2 Measurement */
129 /* Initialize qcI Hash List */
130 #endif /* LTE_L2_MEAS */
137 * @brief Handler to De initialize hash list
139 * @param[in] gCb RLC Instance Control Block
149 Void rlcDbmUlDeInit(gCb)
154 /* De Initialize ueCb Hash List */
155 cmHashListDeinit(&(gCb->u.ulCb->ueLstCp));
157 /* De Initialize cellCb Hash List */
158 cmHashListDeinit(&(gCb->u.ulCb->cellLstCp));
160 /* De Initialize transaction Hash List */
161 cmHashListDeinit(&(gCb->u.ulCb->transIdLstCp));
162 /* kw005.201 added support for L2 Measurement */
163 #ifdef LTE_L2_MEAS_RLC
164 /* De Initialize qciCb Hash List */
165 cmHashListDeinit(&(rlcCb.rlcL2Cb.qciHlCp));
166 #endif /* LTE_L2_MEAS */
173 * @brief Handler to fetch rbCb by the rlcId
176 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb in
177 * the upper interface (CKW/KWU).
179 * @param[in] gCb RLC Instance Control Block
180 * @param[in] rlcId RLC Identifier
181 * @param[out] rbCb RB Control Block
186 Void rlcDbmFetchUlRbCbByRbId
193 Void rlcDbmFetchUlRbCbByRbId(gCb, rlcId, rbCb)
201 /* Check for UE CB or CELL CB */
202 if (rlcId->ueId == 0)
206 if(rlcId->rbId >= RLC_MAX_RB_PER_CELL)
208 RLOG_ARG3(L_ERROR,DBG_RBID,rlcId->rbId ,
209 "Invalid RbId, cellId:%d UEID:%d Max is [%d]",
212 RLC_MAX_RB_PER_CELL);
216 rlcDbmFetchUlCellCb(gCb,rlcId->cellId, &cellCb);
219 RLOG_ARG2(L_ERROR,DBG_CELLID,rlcId->cellId,
220 "CellCb not found RBID:%d UEID:%d",
226 *rbCb = cellCb->rbCb[rlcId->rbId];
232 if (!(RLC_VALIDATE_UE_RBID(rlcId->rbType, rlcId->rbId)))
234 RLOG_ARG3(L_ERROR,DBG_RBID, rlcId->rbId,
235 "Invalid RbId for RbType[%d] CELLID:%d UEID:%d",
242 if (rlcDbmFetchUlUeCb(gCb,rlcId->ueId, rlcId->cellId, &ueCb) != ROK)
244 RLOG_ARG2(L_ERROR,DBG_CELLID, rlcId->cellId,
245 "UeId [%d]: UeCb not found RBID:%d",
251 RLC_DBM_GET_RBCB_FROM_UECB(rlcId->rbId, rlcId->rbType, ueCb, *rbCb);
254 } /* rlcDbmFetchUlRbCbByRbId */
258 * @brief Handler to fetch rbCb from Local Channel Id
261 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb
262 * from local Channel Id (CKW/KWU).
264 * @param[in] gCb - RLC Instance Control Block
265 * @param[in] cellId - CELL Identifier
266 * @param[in] ueId - UE Identifier
267 * @param[in] lcId - Logical Channel Identifier
268 * @param[out] rbCb - RB Control Block
273 void rlcDbmFetchUlRbCbFromLchId(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId,\
274 CmLteLcId lcId, RlcUlRbCb **rbCb)
280 /* Check for UE CB or CELL CB */
285 rlcDbmFetchUlCellCb(gCb,cellId, &cellCb);
288 DU_LOG("\nRLC : rlcDbmFetchUlRbCbFromLchId: CellCb[%d] not found UEID:%d",\
293 *rbCb = cellCb->lCh[lcId - 1].ulRbCb;
297 if (rlcDbmFetchUlUeCb(gCb,ueId, cellId, &ueCb) != ROK)
299 DU_LOG("\nRLC : rlcDbmFetchUlRbCbFromLchId: UeId [%d]: UeCb not found",ueId);
303 *rbCb = ueCb->lCh[lcId - 1].ulRbCb;
306 } /* kwDbmFetchRbCbFromLchId */
310 * @brief Handler to delete RbCb
313 * This function is invoked by CFG to remove RbCb from Ue/Cell hashlist
315 * @param[in] gCb - RLC Instance Control Block
316 * @param[in] rbCbLst - Rb Cb List
317 * @param[in] numRbCb - Number of rbCbs
323 Void rlcDbmDelAllUlRb
330 Void rlcDbmDelAllUlRb(gCb, rbCbLst, numRbCb)
336 uint32_t idx; /* Index */
338 for (idx = 0; idx < numRbCb; idx++)
340 if (rbCbLst[idx] != NULLP)
342 /* Free the Buffers of RbCb */
343 if( CM_LTE_MODE_UM == rbCbLst[idx]->mode )
345 rlcUmmFreeUlRbCb(gCb,rbCbLst[idx]);
347 else if(CM_LTE_MODE_AM == rbCbLst[idx]->mode)
349 rlcAmmFreeUlRbCb(gCb,rbCbLst[idx]);
352 RLC_FREE (gCb,rbCbLst[idx], sizeof (RlcUlRbCb));
357 } /* kwDbmDelAllRb */
361 * @brief Handler to create an UeCb
364 * This function is invoked by CFG to create UeCb and insert into the
365 * Ue hashlist of RlcCb.
367 * @param[in] gCb RLC Instance Control Block
368 * @param[in] ueId UE Identifier
369 * @param[in] cellId Cell Identifier
370 * @param[in] ueCb UE Control Block
386 S16 rlcDbmAddUlUeCb(gCb, ueId, cellId, ueCb)
395 ueCb->cellId = cellId;
397 if(ROK != cmHashListInsert(&(gCb->u.ulCb->ueLstCp),
399 (uint8_t *)&(ueCb->ueId),
400 (uint16_t) sizeof(CmLteRnti)))
402 RLOG_ARG1(L_ERROR,DBG_CELLID,cellId,
403 "UeId[%u] HashList Insertion Failed",
407 /* kw005.201 ccpu00117318, updating the statistics */
416 * @brief Handler to add a transaction
419 * This function adds a transaction.
421 * @param[in] gCb RLC Instance Control Block
422 * @param[in] cfg Configuration information
430 S16 rlcDbmAddUlTransaction
436 S16 rlcDbmAddUlTransaction(gCb, cfg)
438 RlcUlCfgTmpData *cfg;
442 RLOG1(L_DEBUG, "(transId(%ld)", cfg->transId);
444 RLOG1(L_DEBUG, "(transId(%d))", cfg->transId);
447 return (cmHashListInsert(&(gCb->u.ulCb->transIdLstCp),
449 (uint8_t *)&(cfg->transId),
450 (uint16_t) sizeof(cfg->transId)));
455 * @brief Handler to find a transaction
458 * This function find transaction using transaction Id
461 * @param[in] gCb RLC Instance Control Block
462 * @param[in] transId Transaction Id
463 * @param[out] cfg Configuration information attached to this transaction
471 S16 rlcDbmFindUlTransaction
475 RlcUlCfgTmpData **cfg
478 S16 rlcDbmFindUlTransaction(gCb, cfg)
481 RlcUlCfgTmpData **cfg;
485 if(ROK != cmHashListFind(&(gCb->u.ulCb->transIdLstCp),
486 (uint8_t *) &transId,
488 RLC_DEF_SEQ_NUM,(PTR *) cfg))
490 RLOG1(L_ERROR,"TransId [%ld] not found",transId);
499 * @brief Handler to delete a transaction
502 * This function deletes a transaction
505 * @param[in] gCb RLC Instance Control Block
506 * @param[in] cfg Configuration information
514 S16 rlcDbmDelUlTransaction
520 S16 rlcDbmDelUlTransaction(gCb, cfg)
522 RlcUlCfgTmpData *cfg;
526 if(cmHashListDelete(&(gCb->u.ulCb->transIdLstCp),(PTR) (cfg)) != ROK)
528 RLOG0(L_ERROR,"HashList Deletion failed");
537 * @brief Handler to delete all transaction
540 * This function deletes all transaction
542 * @param[in] gCb RLC Instance Control Block
550 S16 rlcDbmDelAllUlTransactions
555 S16 rlcDbmDelAllUlTransactions(gCb)
559 RlcUlCfgTmpData *cfg = NULL;
561 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
562 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->transIdLstCp),
566 if(rlcDbmDelUlTransaction(gCb, cfg) != ROK)
579 * @brief Handler to Fetch an UeCb
582 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
585 * @param[in] gCb RLC Instance Control Block
586 * @param[in] ueId UE Identifier
587 * @param[in] cellId Cell Identifier
588 * @param[out] ueCb UE Control Block
594 uint8_t rlcDbmFetchUlUeCb(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId, RlcUlUeCb **ueCb)
596 return (cmHashListFind(&(gCb->u.ulCb->ueLstCp),
597 (uint8_t *)&(ueId), sizeof(CmLteRnti),
604 * @brief Handler to delete an UeCb
607 * This function is invoked by CFG to delete UeCb from the Ue hashlist
611 * @param[in] gCb RLC Instance Control Block
612 * @param[in] ueCb UE Control Block
613 * @param[in] abrtFlag Abort Flag
626 Void rlcDbmDelUlUeCb(gCb,eCb, abortFlag)
633 #if (!defined(KW_PDCP) || !(defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)))
635 #endif /* (!defined(KW_PDCP) || ! (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)))*/
637 /* Delete all logical channels */
638 RLC_MEM_ZERO(ueCb->lCh,sizeof(RlcUlLch) * RLC_MAX_LCH_PER_UE);
640 /* Delete all SRB RbCbs in UeCb */
641 rlcDbmDelAllUlRb(gCb,ueCb->srbCb, RLC_MAX_SRB_PER_UE);
643 /* Delete all DRB RbCbs in UeCb */
644 rlcDbmDelAllUlRb(gCb,ueCb->drbCb, RLC_MAX_DRB_PER_UE);
646 /* Delete ueCb entry from ueLstCp */
647 if(ROK != cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb))
649 RLOG_ARG1(L_ERROR,DBG_UEID,ueCb->ueId,
650 "HashList Deletion Failed cellId(%d)",
653 /* kw005.201 ccpu00117318, updating the statistics */
655 /* Deallocate ueCb */
656 RLC_FREE(gCb,ueCb, sizeof(RlcUlUeCb));
662 * @brief Handler to delete all UeCbs
665 * This function is invoked by CFG to delete all UeCbs from the Ue
668 * @param[in] gCb RLC Instance Control Block
673 Void rlcDbmDelAllUlUe
678 Void rlcDbmDelAllUlUe(gCb)
682 RlcUlUeCb *ueCb = NULLP; /* UE Control Block */
684 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
685 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->ueLstCp),
689 rlcDbmDelUlUeCb(gCb,ueCb, TRUE);
699 * @brief Handler to create CellCb
702 * This function is invoked by CFG to create CellCb and insert into
703 * the Cell hashlist of RlcCb.
705 * @param[in] gCb RLC Instance Control Block
706 * @param[in] cellId Cell Identifier
707 * @param[in] cellCb Cell Control Block
714 S16 rlcDbmAddUlCellCb
721 S16 rlcDbmAddUlCellCb(gCb, cellId, cellCb)
727 RlcUlCellCb *tCellCb;
730 tCellCb->cellId = cellId;
732 if(ROK != cmHashListInsert(&(gCb->u.ulCb->cellLstCp),
734 (uint8_t *)&(tCellCb->cellId),
735 (uint16_t) sizeof(CmLteCellId)))
737 RLOG_ARG0(L_ERROR,DBG_CELLID,tCellCb->cellId,
738 "HashList Insertion Failed");
747 * @brief Handler to Fetch an CellCb
750 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
753 * @param[in] gCb RLC Instance Control Block
754 * @param[in] cellId Cell Identifier
755 * @param[out] cellCb UE Control Block
762 void rlcDbmFetchUlCellCb(RlcCb *gCb, CmLteCellId cellId, RlcUlCellCb **cellCb)
765 if(ROK != cmHashListFind(&(gCb->u.ulCb->cellLstCp),
766 (uint8_t *)&(cellId),sizeof(CmLteCellId),
767 RLC_DEF_SEQ_NUM, (PTR*) cellCb))
769 DU_LOG("\nRLC : rlcDbmFetchUlCellCb : CellCb[%d] not found", cellId);
777 * @brief Handler to delete CellCb
780 * This function is invoked by CFG to delete CellCb from the Cell hashlist
783 * @param[in] gCb RLC Instance Control Block
784 * @param[in] cellCb Cell Control Block
789 Void rlcDbmDelUlCellCb
795 Void rlcDbmDelUlCellCb(gCb, cellCb)
801 /* Delete all rbCbs in cellCb */
802 rlcDbmDelAllUlRb(gCb,cellCb->rbCb, RLC_MAX_RB_PER_CELL);
804 /* Delete cellCb entry in hash list cellLstCp */
805 if(ROK != cmHashListDelete(&(gCb->u.ulCb->cellLstCp), (PTR) cellCb))
807 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
808 "HashList Deletion Failed");
810 /* Deallocate cellCb */
811 RLC_FREE(gCb, cellCb, sizeof(RlcUlCellCb));
814 } /* kwDbmDelCellCb */
818 * @brief Handler to delete all UeCbs
821 * This function is invoked by CFG to delete all UeCbs from the Ue
823 * @param[in] gCb RLC Instance Control Block
828 Void rlcDbmDelAllUlCell
833 Void rlcDbmDelAllUlCell(gCb)
837 RlcUlCellCb *cellCb = NULLP; /* Cell Control Block */
839 /* Until no more cellCb is ueLstCp hash list get and delete cellCb */
840 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->cellLstCp),
844 rlcDbmDelUlCellCb(gCb,cellCb);
854 * @brief Handler to delete all UeCbs and CellCbs
857 * This function is invoked by LMM to delete all UeCbs from the Ue
858 * hashlist of RlcCb and cellCbs from the Cell hashlist of rlcCb.
860 * @param[in] gCb RLC Instance Control Block
864 Void rlcDbmUlShutdown
869 Void rlcDbmUlShutdown(gCb)
874 rlcDbmDelAllUlCell(gCb);
876 rlcDbmDelAllUlUe(gCb);
884 /********************************************************************30**
887 **********************************************************************/