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
88 /* Initialize ueCb Hash List */
89 if(ROK != cmHashListInit(&(gCb->u.ulCb->ueLstCp),
90 (U16) RLC_UE_LIST_BUCKET_SIZE,
93 (U16) CM_HASH_KEYTYPE_CONID,
94 RLC_GET_MEM_REGION(gCb),
95 RLC_GET_MEM_POOL(gCb)))
97 RLOG0(L_ERROR, "UeLstCp Initialization Failed");
101 /* Initialize cellCb Hash List */
102 if(ROK != cmHashListInit(&(gCb->u.ulCb->cellLstCp),
103 (U16) RLC_CELL_LIST_BUCKET_SIZE,
106 (U16) CM_HASH_KEYTYPE_CONID,
107 RLC_GET_MEM_REGION(gCb),
108 RLC_GET_MEM_POOL(gCb)))
110 cmHashListDeinit(&gCb->u.ulCb->ueLstCp);
111 RLOG0(L_ERROR, "CellLstCp Initialization Failed");
115 if(ROK != cmHashListInit(&(gCb->u.ulCb->transIdLstCp),
116 (U16) RLC_TRANS_ID_LST_BKT_SIZE,
119 (U16) CM_HASH_KEYTYPE_CONID,
120 RLC_GET_MEM_REGION(gCb),
121 RLC_GET_MEM_POOL(gCb)))
123 cmHashListDeinit(&gCb->u.ulCb->ueLstCp);
124 cmHashListDeinit(&gCb->u.ulCb->cellLstCp);
125 RLOG0(L_ERROR, "transIdLstCp Initialization Failed");
129 /* kw005.201 added support for L2 Measurement */
131 /* Initialize qcI Hash List */
132 #endif /* LTE_L2_MEAS */
139 * @brief Handler to De initialize hash list
141 * @param[in] gCb RLC Instance Control Block
151 Void rlcDbmUlDeInit(gCb)
155 TRC3(rlcDbmUlDeInit);
158 /* De Initialize ueCb Hash List */
159 cmHashListDeinit(&(gCb->u.ulCb->ueLstCp));
161 /* De Initialize cellCb Hash List */
162 cmHashListDeinit(&(gCb->u.ulCb->cellLstCp));
164 /* De Initialize transaction Hash List */
165 cmHashListDeinit(&(gCb->u.ulCb->transIdLstCp));
166 /* kw005.201 added support for L2 Measurement */
167 #ifdef LTE_L2_MEAS_RLC
168 /* De Initialize qciCb Hash List */
169 cmHashListDeinit(&(rlcCb.rlcL2Cb.qciHlCp));
170 #endif /* LTE_L2_MEAS */
177 * @brief Handler to fetch rbCb by the rlcId
180 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb in
181 * the upper interface (CKW/KWU).
183 * @param[in] gCb RLC Instance Control Block
184 * @param[in] rlcId RLC Identifier
185 * @param[out] rbCb RB Control Block
190 Void rlcDbmFetchUlRbCbByRbId
197 Void rlcDbmFetchUlRbCbByRbId(gCb, rlcId, rbCb)
203 TRC3(rlcDbmFetchUlRbCbByRbId)
207 /* Check for UE CB or CELL CB */
208 if (rlcId->ueId == 0)
212 if(rlcId->rbId >= RLC_MAX_RB_PER_CELL)
214 RLOG_ARG3(L_ERROR,DBG_RBID,rlcId->rbId ,
215 "Invalid RbId, cellId:%d UEID:%d Max is [%d]",
218 RLC_MAX_RB_PER_CELL);
222 rlcDbmFetchUlCellCb(gCb,rlcId->cellId, &cellCb);
225 RLOG_ARG2(L_ERROR,DBG_CELLID,rlcId->cellId,
226 "CellCb not found RBID:%d UEID:%d",
232 *rbCb = cellCb->rbCb[rlcId->rbId];
238 if (!(RLC_VALIDATE_UE_RBID(rlcId->rbType, rlcId->rbId)))
240 RLOG_ARG3(L_ERROR,DBG_RBID, rlcId->rbId,
241 "Invalid RbId for RbType[%d] CELLID:%d UEID:%d",
248 if (rlcDbmFetchUlUeCb(gCb,rlcId->ueId, rlcId->cellId, &ueCb) != ROK)
250 RLOG_ARG2(L_ERROR,DBG_CELLID, rlcId->cellId,
251 "UeId [%d]: UeCb not found RBID:%d",
257 RLC_DBM_GET_RBCB_FROM_UECB(rlcId->rbId, rlcId->rbType, ueCb, *rbCb);
260 } /* rlcDbmFetchUlRbCbByRbId */
264 * @brief Handler to fetch rbCb from Local Channel Id
267 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb
268 * from local Channel Id (CKW/KWU).
270 * @param[in] gCb - RLC Instance Control Block
271 * @param[in] cellId - CELL Identifier
272 * @param[in] ueId - UE Identifier
273 * @param[in] lcId - Logical Channel Identifier
274 * @param[out] rbCb - RB Control Block
279 void rlcDbmFetchUlRbCbFromLchId(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId,\
280 CmLteLcId lcId, RlcUlRbCb **rbCb)
286 /* Check for UE CB or CELL CB */
291 rlcDbmFetchUlCellCb(gCb,cellId, &cellCb);
294 DU_LOG("\nRLC : rlcDbmFetchUlRbCbFromLchId: CellCb[%d] not found UEID:%d",\
299 *rbCb = cellCb->lCh[lcId - 1].ulRbCb;
303 if (rlcDbmFetchUlUeCb(gCb,ueId, cellId, &ueCb) != ROK)
305 DU_LOG("\nRLC : rlcDbmFetchUlRbCbFromLchId: UeId [%d]: UeCb not found",ueId);
309 *rbCb = ueCb->lCh[lcId - 1].ulRbCb;
312 } /* kwDbmFetchRbCbFromLchId */
316 * @brief Handler to delete RbCb
319 * This function is invoked by CFG to remove RbCb from Ue/Cell hashlist
321 * @param[in] gCb - RLC Instance Control Block
322 * @param[in] rbCbLst - Rb Cb List
323 * @param[in] numRbCb - Number of rbCbs
329 Void rlcDbmDelAllUlRb
336 Void rlcDbmDelAllUlRb(gCb, rbCbLst, numRbCb)
344 TRC3(rlcDbmDelAllUlRb)
347 for (idx = 0; idx < numRbCb; idx++)
349 if (rbCbLst[idx] != NULLP)
351 /* Free the Buffers of RbCb */
352 if( CM_LTE_MODE_UM == rbCbLst[idx]->mode )
354 rlcUmmFreeUlRbCb(gCb,rbCbLst[idx]);
356 else if(CM_LTE_MODE_AM == rbCbLst[idx]->mode)
358 rlcAmmFreeUlRbCb(gCb,rbCbLst[idx]);
361 RLC_FREE (gCb,rbCbLst[idx], sizeof (RlcUlRbCb));
366 } /* kwDbmDelAllRb */
370 * @brief Handler to create an UeCb
373 * This function is invoked by CFG to create UeCb and insert into the
374 * Ue hashlist of RlcCb.
376 * @param[in] gCb RLC Instance Control Block
377 * @param[in] ueId UE Identifier
378 * @param[in] cellId Cell Identifier
379 * @param[in] ueCb UE Control Block
395 S16 rlcDbmAddUlUeCb(gCb, ueId, cellId, ueCb)
402 TRC3(rlcDbmAddUlUeCb)
406 ueCb->cellId = cellId;
408 if(ROK != cmHashListInsert(&(gCb->u.ulCb->ueLstCp),
411 (U16) sizeof(CmLteRnti)))
413 RLOG_ARG1(L_ERROR,DBG_CELLID,cellId,
414 "UeId[%u] HashList Insertion Failed",
418 /* kw005.201 ccpu00117318, updating the statistics */
427 * @brief Handler to add a transaction
430 * This function adds a transaction.
432 * @param[in] gCb RLC Instance Control Block
433 * @param[in] cfg Configuration information
441 S16 rlcDbmAddUlTransaction
447 S16 rlcDbmAddUlTransaction(gCb, cfg)
449 RlcUlCfgTmpData *cfg;
452 TRC3(rlcDbmAddUlTransaction)
455 RLOG1(L_DEBUG, "(transId(%ld)", cfg->transId);
457 RLOG1(L_DEBUG, "(transId(%d))", cfg->transId);
460 return (cmHashListInsert(&(gCb->u.ulCb->transIdLstCp),
462 (U8 *)&(cfg->transId),
463 (U16) sizeof(cfg->transId)));
468 * @brief Handler to find a transaction
471 * This function find transaction using transaction Id
474 * @param[in] gCb RLC Instance Control Block
475 * @param[in] transId Transaction Id
476 * @param[out] cfg Configuration information attached to this transaction
484 S16 rlcDbmFindUlTransaction
488 RlcUlCfgTmpData **cfg
491 S16 rlcDbmFindUlTransaction(gCb, cfg)
494 RlcUlCfgTmpData **cfg;
497 TRC3(rlcDbmFindUlTransaction)
499 if(ROK != cmHashListFind(&(gCb->u.ulCb->transIdLstCp),
502 RLC_DEF_SEQ_NUM,(PTR *) cfg))
504 RLOG1(L_ERROR,"TransId [%ld] not found",transId);
513 * @brief Handler to delete a transaction
516 * This function deletes a transaction
519 * @param[in] gCb RLC Instance Control Block
520 * @param[in] cfg Configuration information
528 S16 rlcDbmDelUlTransaction
534 S16 rlcDbmDelUlTransaction(gCb, cfg)
536 RlcUlCfgTmpData *cfg;
539 TRC3(rlcDbmDelUlTransaction)
542 if(cmHashListDelete(&(gCb->u.ulCb->transIdLstCp),(PTR) (cfg)) != ROK)
544 RLOG0(L_ERROR,"HashList Deletion failed");
553 * @brief Handler to delete all transaction
556 * This function deletes all transaction
558 * @param[in] gCb RLC Instance Control Block
566 S16 rlcDbmDelAllUlTransactions
571 S16 rlcDbmDelAllUlTransactions(gCb)
575 RlcUlCfgTmpData *cfg = NULL;
577 TRC3(kwDbmDelAllUlTransctions)
579 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
580 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->transIdLstCp),
584 if(rlcDbmDelUlTransaction(gCb, cfg) != ROK)
597 * @brief Handler to Fetch an UeCb
600 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
603 * @param[in] gCb RLC Instance Control Block
604 * @param[in] ueId UE Identifier
605 * @param[in] cellId Cell Identifier
606 * @param[out] ueCb UE Control Block
612 uint8_t rlcDbmFetchUlUeCb(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId, RlcUlUeCb **ueCb)
614 return (cmHashListFind(&(gCb->u.ulCb->ueLstCp),
615 (uint8_t *)&(ueId), sizeof(CmLteRnti),
622 * @brief Handler to delete an UeCb
625 * This function is invoked by CFG to delete UeCb from the Ue hashlist
629 * @param[in] gCb RLC Instance Control Block
630 * @param[in] ueCb UE Control Block
631 * @param[in] abrtFlag Abort Flag
644 Void rlcDbmDelUlUeCb(gCb,eCb, abortFlag)
650 TRC3(rlcDbmDelUlUeCb)
653 #if (!defined(KW_PDCP) || !(defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)))
655 #endif /* (!defined(KW_PDCP) || ! (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)))*/
657 /* Delete all logical channels */
658 RLC_MEM_ZERO(ueCb->lCh,sizeof(RlcUlLch) * RLC_MAX_LCH_PER_UE);
660 /* Delete all SRB RbCbs in UeCb */
661 rlcDbmDelAllUlRb(gCb,ueCb->srbCb, RLC_MAX_SRB_PER_UE);
663 /* Delete all DRB RbCbs in UeCb */
664 rlcDbmDelAllUlRb(gCb,ueCb->drbCb, RLC_MAX_DRB_PER_UE);
666 /* Delete ueCb entry from ueLstCp */
667 if(ROK != cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb))
669 RLOG_ARG1(L_ERROR,DBG_UEID,ueCb->ueId,
670 "HashList Deletion Failed cellId(%d)",
673 /* kw005.201 ccpu00117318, updating the statistics */
675 /* Deallocate ueCb */
676 RLC_FREE(gCb,ueCb, sizeof(RlcUlUeCb));
682 * @brief Handler to delete all UeCbs
685 * This function is invoked by CFG to delete all UeCbs from the Ue
688 * @param[in] gCb RLC Instance Control Block
693 Void rlcDbmDelAllUlUe
698 Void rlcDbmDelAllUlUe(gCb)
702 RlcUlUeCb *ueCb = NULLP; /* UE Control Block */
704 TRC3(rlcDbmDelAllUlUe)
707 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
708 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->ueLstCp),
712 rlcDbmDelUlUeCb(gCb,ueCb, TRUE);
722 * @brief Handler to create CellCb
725 * This function is invoked by CFG to create CellCb and insert into
726 * the Cell hashlist of RlcCb.
728 * @param[in] gCb RLC Instance Control Block
729 * @param[in] cellId Cell Identifier
730 * @param[in] cellCb Cell Control Block
737 S16 rlcDbmAddUlCellCb
744 S16 rlcDbmAddUlCellCb(gCb, cellId, cellCb)
750 RlcUlCellCb *tCellCb;
752 TRC3(rlcDbmAddUlCellCb)
757 tCellCb->cellId = cellId;
759 if(ROK != cmHashListInsert(&(gCb->u.ulCb->cellLstCp),
761 (U8 *)&(tCellCb->cellId),
762 (U16) sizeof(CmLteCellId)))
764 RLOG_ARG0(L_ERROR,DBG_CELLID,tCellCb->cellId,
765 "HashList Insertion Failed");
774 * @brief Handler to Fetch an CellCb
777 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
780 * @param[in] gCb RLC Instance Control Block
781 * @param[in] cellId Cell Identifier
782 * @param[out] cellCb UE Control Block
789 void rlcDbmFetchUlCellCb(RlcCb *gCb, CmLteCellId cellId, RlcUlCellCb **cellCb)
792 if(ROK != cmHashListFind(&(gCb->u.ulCb->cellLstCp),
793 (uint8_t *)&(cellId),sizeof(CmLteCellId),
794 RLC_DEF_SEQ_NUM, (PTR*) cellCb))
796 DU_LOG("\nRLC : rlcDbmFetchUlCellCb : CellCb[%d] not found", cellId);
804 * @brief Handler to delete CellCb
807 * This function is invoked by CFG to delete CellCb from the Cell hashlist
810 * @param[in] gCb RLC Instance Control Block
811 * @param[in] cellCb Cell Control Block
816 Void rlcDbmDelUlCellCb
822 Void rlcDbmDelUlCellCb(gCb, cellCb)
827 TRC3(rlcDbmDelUlCellCb)
830 /* Delete all rbCbs in cellCb */
831 rlcDbmDelAllUlRb(gCb,cellCb->rbCb, RLC_MAX_RB_PER_CELL);
833 /* Delete cellCb entry in hash list cellLstCp */
834 if(ROK != cmHashListDelete(&(gCb->u.ulCb->cellLstCp), (PTR) cellCb))
836 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
837 "HashList Deletion Failed");
839 /* Deallocate cellCb */
840 RLC_FREE(gCb, cellCb, sizeof(RlcUlCellCb));
843 } /* kwDbmDelCellCb */
847 * @brief Handler to delete all UeCbs
850 * This function is invoked by CFG to delete all UeCbs from the Ue
852 * @param[in] gCb RLC Instance Control Block
857 Void rlcDbmDelAllUlCell
862 Void rlcDbmDelAllUlCell(gCb)
866 RlcUlCellCb *cellCb = NULLP; /* Cell Control Block */
868 TRC3(rlcDbmDelAllUlCell)
871 /* Until no more cellCb is ueLstCp hash list get and delete cellCb */
872 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->cellLstCp),
876 rlcDbmDelUlCellCb(gCb,cellCb);
886 * @brief Handler to delete all UeCbs and CellCbs
889 * This function is invoked by LMM to delete all UeCbs from the Ue
890 * hashlist of RlcCb and cellCbs from the Cell hashlist of rlcCb.
892 * @param[in] gCb RLC Instance Control Block
896 Void rlcDbmUlShutdown
901 Void rlcDbmUlShutdown(gCb)
905 TRC3(rlcDbmUlShutdown)
907 rlcDbmDelAllUlCell(gCb);
909 rlcDbmDelAllUlUe(gCb);
917 /********************************************************************30**
920 **********************************************************************/