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
76 S16 rlcDbmUlInit(RlcCb *gCb)
78 /* Initialize ueCb Hash List */
79 if(ROK != cmHashListInit(&(gCb->u.ulCb->ueLstCp),
80 (uint16_t) RLC_UE_LIST_BUCKET_SIZE,
83 (uint16_t) CM_HASH_KEYTYPE_CONID,
84 RLC_GET_MEM_REGION(gCb),
85 RLC_GET_MEM_POOL(gCb)))
87 RLOG0(L_ERROR, "UeLstCp Initialization Failed");
91 /* Initialize cellCb Hash List */
92 if(ROK != cmHashListInit(&(gCb->u.ulCb->cellLstCp),
93 (uint16_t) RLC_CELL_LIST_BUCKET_SIZE,
96 (uint16_t) CM_HASH_KEYTYPE_CONID,
97 RLC_GET_MEM_REGION(gCb),
98 RLC_GET_MEM_POOL(gCb)))
100 cmHashListDeinit(&gCb->u.ulCb->ueLstCp);
101 RLOG0(L_ERROR, "CellLstCp Initialization Failed");
105 if(ROK != cmHashListInit(&(gCb->u.ulCb->transIdLstCp),
106 (uint16_t) RLC_TRANS_ID_LST_BKT_SIZE,
109 (uint16_t) CM_HASH_KEYTYPE_CONID,
110 RLC_GET_MEM_REGION(gCb),
111 RLC_GET_MEM_POOL(gCb)))
113 cmHashListDeinit(&gCb->u.ulCb->ueLstCp);
114 cmHashListDeinit(&gCb->u.ulCb->cellLstCp);
115 RLOG0(L_ERROR, "transIdLstCp Initialization Failed");
119 /* kw005.201 added support for L2 Measurement */
121 /* Initialize qcI Hash List */
122 #endif /* LTE_L2_MEAS */
129 * @brief Handler to De initialize hash list
131 * @param[in] gCb RLC Instance Control Block
135 Void rlcDbmUlDeInit(RlcCb *gCb)
138 /* De Initialize ueCb Hash List */
139 cmHashListDeinit(&(gCb->u.ulCb->ueLstCp));
141 /* De Initialize cellCb Hash List */
142 cmHashListDeinit(&(gCb->u.ulCb->cellLstCp));
144 /* De Initialize transaction Hash List */
145 cmHashListDeinit(&(gCb->u.ulCb->transIdLstCp));
146 /* kw005.201 added support for L2 Measurement */
147 #ifdef LTE_L2_MEAS_RLC
148 /* De Initialize qciCb Hash List */
149 cmHashListDeinit(&(rlcCb.rlcL2Cb.qciHlCp));
150 #endif /* LTE_L2_MEAS */
157 * @brief Handler to fetch rbCb by the rlcId
160 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb in
161 * the upper interface (CKW/KWU).
163 * @param[in] gCb RLC Instance Control Block
164 * @param[in] rlcId RLC Identifier
165 * @param[out] rbCb RB Control Block
169 Void rlcDbmFetchUlRbCbByRbId
178 /* Check for UE CB or CELL CB */
179 if (rlcId->ueId == 0)
183 if(rlcId->rbId >= RLC_MAX_RB_PER_CELL)
185 RLOG_ARG3(L_ERROR,DBG_RBID,rlcId->rbId ,
186 "Invalid RbId, cellId:%d UEID:%d Max is [%d]",
189 RLC_MAX_RB_PER_CELL);
193 rlcDbmFetchUlCellCb(gCb,rlcId->cellId, &cellCb);
196 RLOG_ARG2(L_ERROR,DBG_CELLID,rlcId->cellId,
197 "CellCb not found RBID:%d UEID:%d",
203 *rbCb = cellCb->rbCb[rlcId->rbId];
209 if (!(RLC_VALIDATE_UE_RBID(rlcId->rbType, rlcId->rbId)))
211 RLOG_ARG3(L_ERROR,DBG_RBID, rlcId->rbId,
212 "Invalid RbId for RbType[%d] CELLID:%d UEID:%d",
219 if (rlcDbmFetchUlUeCb(gCb,rlcId->ueId, rlcId->cellId, &ueCb) != ROK)
221 RLOG_ARG2(L_ERROR,DBG_CELLID, rlcId->cellId,
222 "UeId [%d]: UeCb not found RBID:%d",
228 RLC_DBM_GET_RBCB_FROM_UECB(rlcId->rbId, rlcId->rbType, ueCb, *rbCb);
231 } /* rlcDbmFetchUlRbCbByRbId */
235 * @brief Handler to fetch rbCb from Local Channel Id
238 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb
239 * from local Channel Id (CKW/KWU).
241 * @param[in] gCb - RLC Instance Control Block
242 * @param[in] cellId - CELL Identifier
243 * @param[in] ueId - UE Identifier
244 * @param[in] lcId - Logical Channel Identifier
245 * @param[out] rbCb - RB Control Block
250 void rlcDbmFetchUlRbCbFromLchId(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId,\
251 CmLteLcId lcId, RlcUlRbCb **rbCb)
257 /* Check for UE CB or CELL CB */
262 rlcDbmFetchUlCellCb(gCb,cellId, &cellCb);
265 DU_LOG("\nRLC : rlcDbmFetchUlRbCbFromLchId: CellCb[%d] not found UEID:%d",\
270 *rbCb = cellCb->lCh[lcId - 1].ulRbCb;
274 if (rlcDbmFetchUlUeCb(gCb,ueId, cellId, &ueCb) != ROK)
276 DU_LOG("\nRLC : rlcDbmFetchUlRbCbFromLchId: UeId [%d]: UeCb not found",ueId);
280 *rbCb = ueCb->lCh[lcId - 1].ulRbCb;
283 } /* kwDbmFetchRbCbFromLchId */
287 * @brief Handler to delete RbCb
290 * This function is invoked by CFG to remove RbCb from Ue/Cell hashlist
292 * @param[in] gCb - RLC Instance Control Block
293 * @param[in] rbCbLst - Rb Cb List
294 * @param[in] numRbCb - Number of rbCbs
299 Void rlcDbmDelAllUlRb
306 uint32_t idx; /* Index */
308 for (idx = 0; idx < numRbCb; idx++)
310 if (rbCbLst[idx] != NULLP)
312 /* Free the Buffers of RbCb */
313 if( RLC_MODE_UM == rbCbLst[idx]->mode )
315 rlcUmmFreeUlRbCb(gCb,rbCbLst[idx]);
317 else if(RLC_MODE_AM == rbCbLst[idx]->mode)
319 rlcAmmFreeUlRbCb(gCb,rbCbLst[idx]);
322 RLC_FREE (gCb,rbCbLst[idx], sizeof (RlcUlRbCb));
327 } /* kwDbmDelAllRb */
331 * @brief Handler to create an UeCb
334 * This function is invoked by CFG to create UeCb and insert into the
335 * Ue hashlist of RlcCb.
337 * @param[in] gCb RLC Instance Control Block
338 * @param[in] ueId UE Identifier
339 * @param[in] cellId Cell Identifier
340 * @param[in] ueCb UE Control Block
357 ueCb->cellId = cellId;
359 if(ROK != cmHashListInsert(&(gCb->u.ulCb->ueLstCp),
361 (uint8_t *)&(ueCb->ueId),
362 (uint16_t) sizeof(CmLteRnti)))
364 RLOG_ARG1(L_ERROR,DBG_CELLID,cellId,
365 "UeId[%u] HashList Insertion Failed",
369 /* kw005.201 ccpu00117318, updating the statistics */
378 * @brief Handler to add a transaction
381 * This function adds a transaction.
383 * @param[in] gCb RLC Instance Control Block
384 * @param[in] cfg Configuration information
391 S16 rlcDbmAddUlTransaction
398 RLOG1(L_DEBUG, "(transId(%ld)", cfg->transId);
400 RLOG1(L_DEBUG, "(transId(%d))", cfg->transId);
403 return (cmHashListInsert(&(gCb->u.ulCb->transIdLstCp),
405 (uint8_t *)&(cfg->transId),
406 (uint16_t) sizeof(cfg->transId)));
411 * @brief Handler to find a transaction
414 * This function find transaction using transaction Id
417 * @param[in] gCb RLC Instance Control Block
418 * @param[in] transId Transaction Id
419 * @param[out] cfg Configuration information attached to this transaction
426 S16 rlcDbmFindUlTransaction
430 RlcUlCfgTmpData **cfg
434 if(ROK != cmHashListFind(&(gCb->u.ulCb->transIdLstCp),
435 (uint8_t *) &transId,
437 RLC_DEF_SEQ_NUM,(PTR *) cfg))
439 RLOG1(L_ERROR,"TransId [%ld] not found",transId);
448 * @brief Handler to delete a transaction
451 * This function deletes a transaction
454 * @param[in] gCb RLC Instance Control Block
455 * @param[in] cfg Configuration information
462 S16 rlcDbmDelUlTransaction
469 if(cmHashListDelete(&(gCb->u.ulCb->transIdLstCp),(PTR) (cfg)) != ROK)
471 RLOG0(L_ERROR,"HashList Deletion failed");
480 * @brief Handler to delete all transaction
483 * This function deletes all transaction
485 * @param[in] gCb RLC Instance Control Block
492 S16 rlcDbmDelAllUlTransactions(RlcCb *gCb)
494 RlcUlCfgTmpData *cfg = NULL;
496 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
497 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->transIdLstCp),
501 if(rlcDbmDelUlTransaction(gCb, cfg) != ROK)
514 * @brief Handler to Fetch an UeCb
517 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
520 * @param[in] gCb RLC Instance Control Block
521 * @param[in] ueId UE Identifier
522 * @param[in] cellId Cell Identifier
523 * @param[out] ueCb UE Control Block
529 uint8_t rlcDbmFetchUlUeCb(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId, RlcUlUeCb **ueCb)
531 return (cmHashListFind(&(gCb->u.ulCb->ueLstCp),
532 (uint8_t *)&(ueId), sizeof(CmLteRnti),
539 * @brief Handler to delete an UeCb
542 * This function is invoked by CFG to delete UeCb from the Ue hashlist
546 * @param[in] gCb RLC Instance Control Block
547 * @param[in] ueCb UE Control Block
548 * @param[in] abrtFlag Abort Flag
561 #if (!defined(KW_PDCP) || !(defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)))
563 #endif /* (!defined(KW_PDCP) || ! (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)))*/
565 /* Delete all logical channels */
566 RLC_MEM_ZERO(ueCb->lCh,sizeof(RlcUlLch) * RLC_MAX_LCH_PER_UE);
568 /* Delete all SRB RbCbs in UeCb */
569 rlcDbmDelAllUlRb(gCb,ueCb->srbCb, RLC_MAX_SRB_PER_UE);
571 /* Delete all DRB RbCbs in UeCb */
572 rlcDbmDelAllUlRb(gCb,ueCb->drbCb, RLC_MAX_DRB_PER_UE);
574 /* Delete ueCb entry from ueLstCp */
575 if(ROK != cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb))
577 RLOG_ARG1(L_ERROR,DBG_UEID,ueCb->ueId,
578 "HashList Deletion Failed cellId(%d)",
581 /* kw005.201 ccpu00117318, updating the statistics */
583 /* Deallocate ueCb */
584 RLC_FREE(gCb,ueCb, sizeof(RlcUlUeCb));
590 * @brief Handler to delete all UeCbs
593 * This function is invoked by CFG to delete all UeCbs from the Ue
596 * @param[in] gCb RLC Instance Control Block
600 Void rlcDbmDelAllUlUe(RlcCb *gCb)
602 RlcUlUeCb *ueCb = NULLP; /* UE Control Block */
604 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
605 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->ueLstCp),
609 rlcDbmDelUlUeCb(gCb,ueCb, TRUE);
619 * @brief Handler to create CellCb
622 * This function is invoked by CFG to create CellCb and insert into
623 * the Cell hashlist of RlcCb.
625 * @param[in] gCb RLC Instance Control Block
626 * @param[in] cellId Cell Identifier
627 * @param[in] cellCb Cell Control Block
633 S16 rlcDbmAddUlCellCb
640 RlcUlCellCb *tCellCb;
643 tCellCb->cellId = cellId;
645 if(ROK != cmHashListInsert(&(gCb->u.ulCb->cellLstCp),
647 (uint8_t *)&(tCellCb->cellId),
648 (uint16_t) sizeof(CmLteCellId)))
650 RLOG_ARG0(L_ERROR,DBG_CELLID,tCellCb->cellId,
651 "HashList Insertion Failed");
660 * @brief Handler to Fetch an CellCb
663 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
666 * @param[in] gCb RLC Instance Control Block
667 * @param[in] cellId Cell Identifier
668 * @param[out] cellCb UE Control Block
675 void rlcDbmFetchUlCellCb(RlcCb *gCb, CmLteCellId cellId, RlcUlCellCb **cellCb)
678 if(ROK != cmHashListFind(&(gCb->u.ulCb->cellLstCp),
679 (uint8_t *)&(cellId),sizeof(CmLteCellId),
680 RLC_DEF_SEQ_NUM, (PTR*) cellCb))
682 DU_LOG("\nRLC : rlcDbmFetchUlCellCb : CellCb[%d] not found", cellId);
690 * @brief Handler to delete CellCb
693 * This function is invoked by CFG to delete CellCb from the Cell hashlist
696 * @param[in] gCb RLC Instance Control Block
697 * @param[in] cellCb Cell Control Block
701 Void rlcDbmDelUlCellCb(RlcCb *gCb,RlcUlCellCb *cellCb)
704 /* Delete all rbCbs in cellCb */
705 rlcDbmDelAllUlRb(gCb,cellCb->rbCb, RLC_MAX_RB_PER_CELL);
707 /* Delete cellCb entry in hash list cellLstCp */
708 if(ROK != cmHashListDelete(&(gCb->u.ulCb->cellLstCp), (PTR) cellCb))
710 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
711 "HashList Deletion Failed");
713 /* Deallocate cellCb */
714 RLC_FREE(gCb, cellCb, sizeof(RlcUlCellCb));
717 } /* kwDbmDelCellCb */
721 * @brief Handler to delete all UeCbs
724 * This function is invoked by CFG to delete all UeCbs from the Ue
726 * @param[in] gCb RLC Instance Control Block
730 Void rlcDbmDelAllUlCell(RlcCb *gCb)
732 RlcUlCellCb *cellCb = NULLP; /* Cell Control Block */
734 /* Until no more cellCb is ueLstCp hash list get and delete cellCb */
735 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->cellLstCp),
739 rlcDbmDelUlCellCb(gCb,cellCb);
749 * @brief Handler to delete all UeCbs and CellCbs
752 * This function is invoked by LMM to delete all UeCbs from the Ue
753 * hashlist of RlcCb and cellCbs from the Cell hashlist of rlcCb.
755 * @param[in] gCb RLC Instance Control Block
758 Void rlcDbmUlShutdown(RlcCb *gCb)
761 rlcDbmDelAllUlCell(gCb);
763 rlcDbmDelAllUlUe(gCb);
771 /********************************************************************30**
774 **********************************************************************/