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*/
32 /* header (.h) include files */
33 #include "common_def.h"
34 #include "lkw.h" /* LKW defines */
35 #include "ckw.h" /* CKW defines */
36 #include "kwu.h" /* KWU defines */
37 #include "rgu.h" /* RGU defines */
38 #include "rlc_err.h" /* Err defines */
39 #include "rlc_env.h" /* RLC environment options */
42 /* extern (.x) include files */
43 #include "lkw.x" /* LKW */
44 #include "ckw.x" /* CKW */
45 #include "kwu.x" /* KWU */
46 #include "rgu.x" /* RGU */
48 #include "rlc_utils.h" /* RLC defines */
53 * @brief RLC Uplink database module
56 #define RLC_MODULE RLC_DBGMASK_DUT
60 * @brief Handler to initialize hash list
63 * This function initializes the UeCb, CellCb and transactions hash lists
65 * @param[in] gCb RLC instance control block
71 S16 rlcDbmUlInit(RlcCb *gCb)
73 /* Initialize ueCb Hash List */
74 if(ROK != cmHashListInit(&(gCb->u.ulCb->ueLstCp),
75 (uint16_t) RLC_UE_LIST_BUCKET_SIZE,
78 (uint16_t) CM_HASH_KEYTYPE_CONID,
79 RLC_GET_MEM_REGION(gCb),
80 RLC_GET_MEM_POOL(gCb)))
82 DU_LOG("\nERROR --> RLC_UL : UeLstCp Initialization Failed");
86 /* Initialize cellCb Hash List */
87 if(ROK != cmHashListInit(&(gCb->u.ulCb->cellLstCp),
88 (uint16_t) RLC_CELL_LIST_BUCKET_SIZE,
91 (uint16_t) CM_HASH_KEYTYPE_CONID,
92 RLC_GET_MEM_REGION(gCb),
93 RLC_GET_MEM_POOL(gCb)))
95 cmHashListDeinit(&gCb->u.ulCb->ueLstCp);
96 DU_LOG("\nERROR --> RLC_UL : CellLstCp Initialization Failed");
100 if(ROK != cmHashListInit(&(gCb->u.ulCb->transIdLstCp),
101 (uint16_t) RLC_TRANS_ID_LST_BKT_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 cmHashListDeinit(&gCb->u.ulCb->cellLstCp);
110 DU_LOG("\nERROR --> RLC_UL : transIdLstCp Initialization Failed");
114 /* kw005.201 added support for L2 Measurement */
116 /* Initialize qcI Hash List */
117 #endif /* LTE_L2_MEAS */
124 * @brief Handler to De initialize hash list
126 * @param[in] gCb RLC Instance Control Block
130 Void rlcDbmUlDeInit(RlcCb *gCb)
133 /* De Initialize ueCb Hash List */
134 cmHashListDeinit(&(gCb->u.ulCb->ueLstCp));
136 /* De Initialize cellCb Hash List */
137 cmHashListDeinit(&(gCb->u.ulCb->cellLstCp));
139 /* De Initialize transaction Hash List */
140 cmHashListDeinit(&(gCb->u.ulCb->transIdLstCp));
141 /* kw005.201 added support for L2 Measurement */
142 #ifdef LTE_L2_MEAS_RLC
143 /* De Initialize qciCb Hash List */
144 cmHashListDeinit(&(rlcCb.rlcL2Cb.qciHlCp));
145 #endif /* LTE_L2_MEAS */
152 * @brief Handler to fetch rbCb by the rlcId
155 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb in
156 * the upper interface (CKW/KWU).
158 * @param[in] gCb RLC Instance Control Block
159 * @param[in] rlcId RLC Identifier
160 * @param[out] rbCb RB Control Block
164 Void rlcDbmFetchUlRbCbByRbId
173 /* Check for UE CB or CELL CB */
174 if (rlcId->ueId == 0)
178 if(rlcId->rbId >= RLC_MAX_RB_PER_CELL)
180 DU_LOG("\nERROR --> RLC_UL : Invalid RbId, cellId:%d UEID:%d Max is [%d]",
181 rlcId->cellId, rlcId->ueId, RLC_MAX_RB_PER_CELL);
185 rlcDbmFetchUlCellCb(gCb,rlcId->cellId, &cellCb);
188 DU_LOG("\nERROR --> RLC_UL : CellCb not found RBID:%d UEID:%d",
194 *rbCb = cellCb->rbCb[rlcId->rbId];
200 if (!(RLC_VALIDATE_UE_RBID(rlcId->rbType, rlcId->rbId)))
202 DU_LOG("\nERROR --> RLC_UL : Invalid RbId for RbType[%d] CELLID:%d UEID:%d",
209 if (rlcDbmFetchUlUeCb(gCb,rlcId->ueId, rlcId->cellId, &ueCb) != ROK)
211 DU_LOG("\nERROR --> RLC_UL : UeId [%d]: UeCb not found RBID:%d",
217 RLC_DBM_GET_RBCB_FROM_UECB(rlcId->rbId, rlcId->rbType, ueCb, *rbCb);
220 } /* rlcDbmFetchUlRbCbByRbId */
224 * @brief Handler to fetch rbCb from Local Channel Id
227 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb
228 * from local Channel Id (CKW/KWU).
230 * @param[in] gCb - RLC Instance Control Block
231 * @param[in] cellId - CELL Identifier
232 * @param[in] ueId - UE Identifier
233 * @param[in] lcId - Logical Channel Identifier
234 * @param[out] rbCb - RB Control Block
239 void rlcDbmFetchUlRbCbFromLchId(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId,\
240 CmLteLcId lcId, RlcUlRbCb **rbCb)
246 /* Check for UE CB or CELL CB */
251 rlcDbmFetchUlCellCb(gCb,cellId, &cellCb);
254 DU_LOG("\nERROR --> RLC_UL : rlcDbmFetchUlRbCbFromLchId: CellCb[%d] not found UEID:%d",\
259 *rbCb = cellCb->lCh[lcId - 1].ulRbCb;
263 if (rlcDbmFetchUlUeCb(gCb,ueId, cellId, &ueCb) != ROK)
265 DU_LOG("\nERROR --> RLC_UL : rlcDbmFetchUlRbCbFromLchId: UeId [%d]: UeCb not found",ueId);
269 *rbCb = ueCb->lCh[lcId - 1].ulRbCb;
272 } /* kwDbmFetchRbCbFromLchId */
276 * @brief Handler to delete RbCb
279 * This function is invoked by CFG to remove RbCb from Ue/Cell hashlist
281 * @param[in] gCb - RLC Instance Control Block
282 * @param[in] rbCbLst - Rb Cb List
283 * @param[in] numRbCb - Number of rbCbs
288 Void rlcDbmDelAllUlRb
295 uint32_t idx; /* Index */
297 for (idx = 0; idx < numRbCb; idx++)
299 if (rbCbLst[idx] != NULLP)
301 /* Free the Buffers of RbCb */
302 if( RLC_MODE_UM == rbCbLst[idx]->mode )
304 rlcUmmFreeUlRbCb(gCb,rbCbLst[idx]);
306 else if(RLC_MODE_AM == rbCbLst[idx]->mode)
308 rlcAmmFreeUlRbCb(gCb,rbCbLst[idx]);
311 RLC_FREE(gCb,rbCbLst[idx], sizeof (RlcUlRbCb));
316 } /* kwDbmDelAllRb */
320 * @brief Handler to create an UeCb
323 * This function is invoked by CFG to create UeCb and insert into the
324 * Ue hashlist of RlcCb.
326 * @param[in] gCb RLC Instance Control Block
327 * @param[in] ueId UE Identifier
328 * @param[in] cellId Cell Identifier
329 * @param[in] ueCb UE Control Block
346 ueCb->cellId = cellId;
348 if(ROK != cmHashListInsert(&(gCb->u.ulCb->ueLstCp),
350 (uint8_t *)&(ueCb->ueId),
351 (uint16_t) sizeof(CmLteRnti)))
353 DU_LOG("\nERROR --> RLC_UL : UeId[%u] HashList Insertion Failed",
357 /* kw005.201 ccpu00117318, updating the statistics */
366 * @brief Handler to add a transaction
369 * This function adds a transaction.
371 * @param[in] gCb RLC Instance Control Block
372 * @param[in] cfg Configuration information
379 S16 rlcDbmAddUlTransaction
386 DU_LOG("\nDEBUG --> RLC_UL : (transId(%ld)", cfg->transId);
388 DU_LOG("\nDEBUG --> RLC_UL : (transId(%d))", cfg->transId);
391 return (cmHashListInsert(&(gCb->u.ulCb->transIdLstCp),
393 (uint8_t *)&(cfg->transId),
394 (uint16_t) sizeof(cfg->transId)));
399 * @brief Handler to find a transaction
402 * This function find transaction using transaction Id
405 * @param[in] gCb RLC Instance Control Block
406 * @param[in] transId Transaction Id
407 * @param[out] cfg Configuration information attached to this transaction
414 S16 rlcDbmFindUlTransaction
418 RlcUlCfgTmpData **cfg
422 if(ROK != cmHashListFind(&(gCb->u.ulCb->transIdLstCp),
423 (uint8_t *) &transId,
425 RLC_DEF_SEQ_NUM,(PTR *) cfg))
427 DU_LOG("\nERROR --> RLC_UL : TransId [%d] not found",transId);
436 * @brief Handler to delete a transaction
439 * This function deletes a transaction
442 * @param[in] gCb RLC Instance Control Block
443 * @param[in] cfg Configuration information
450 S16 rlcDbmDelUlTransaction
457 if(cmHashListDelete(&(gCb->u.ulCb->transIdLstCp),(PTR) (cfg)) != ROK)
459 DU_LOG("\nERROR --> RLC_UL : HashList Deletion failed");
468 * @brief Handler to delete all transaction
471 * This function deletes all transaction
473 * @param[in] gCb RLC Instance Control Block
480 S16 rlcDbmDelAllUlTransactions(RlcCb *gCb)
482 RlcUlCfgTmpData *cfg = NULL;
484 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
485 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->transIdLstCp),
489 if(rlcDbmDelUlTransaction(gCb, cfg) != ROK)
502 * @brief Handler to Fetch an UeCb
505 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
508 * @param[in] gCb RLC Instance Control Block
509 * @param[in] ueId UE Identifier
510 * @param[in] cellId Cell Identifier
511 * @param[out] ueCb UE Control Block
517 uint8_t rlcDbmFetchUlUeCb(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId, RlcUlUeCb **ueCb)
519 return (cmHashListFind(&(gCb->u.ulCb->ueLstCp),
520 (uint8_t *)&(ueId), sizeof(CmLteRnti),
527 * @brief Handler to delete an UeCb
530 * This function is invoked by CFG to delete UeCb from the Ue hashlist
534 * @param[in] gCb RLC Instance Control Block
535 * @param[in] ueCb UE Control Block
536 * @param[in] abrtFlag Abort Flag
549 #if (!defined(KW_PDCP) || !(defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)))
551 #endif /* (!defined(KW_PDCP) || ! (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)))*/
553 /* Delete all logical channels */
554 RLC_MEM_ZERO(ueCb->lCh,sizeof(RlcUlLch) * RLC_MAX_LCH_PER_UE);
556 /* Delete all SRB RbCbs in UeCb */
557 rlcDbmDelAllUlRb(gCb,ueCb->srbCb, RLC_MAX_SRB_PER_UE);
559 /* Delete all DRB RbCbs in UeCb */
560 rlcDbmDelAllUlRb(gCb,ueCb->drbCb, RLC_MAX_DRB_PER_UE);
562 /* Delete ueCb entry from ueLstCp */
563 if(ROK != cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb))
565 DU_LOG("\nERROR --> RLC_UL : HashList Deletion Failed cellId(%d)",
568 /* kw005.201 ccpu00117318, updating the statistics */
570 /* Deallocate ueCb */
571 RLC_FREE(gCb,ueCb, sizeof(RlcUlUeCb));
577 * @brief Handler to delete all UeCbs
580 * This function is invoked by CFG to delete all UeCbs from the Ue
583 * @param[in] gCb RLC Instance Control Block
587 Void rlcDbmDelAllUlUe(RlcCb *gCb)
589 RlcUlUeCb *ueCb = NULLP; /* UE Control Block */
591 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
592 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->ueLstCp),
596 rlcDbmDelUlUeCb(gCb,ueCb, TRUE);
606 * @brief Handler to create CellCb
609 * This function is invoked by CFG to create CellCb and insert into
610 * the Cell hashlist of RlcCb.
612 * @param[in] gCb RLC Instance Control Block
613 * @param[in] cellId Cell Identifier
614 * @param[in] cellCb Cell Control Block
620 S16 rlcDbmAddUlCellCb
627 RlcUlCellCb *tCellCb;
630 tCellCb->cellId = cellId;
632 if(ROK != cmHashListInsert(&(gCb->u.ulCb->cellLstCp),
634 (uint8_t *)&(tCellCb->cellId),
635 (uint16_t) sizeof(CmLteCellId)))
637 DU_LOG("\nERROR --> RLC_UL : HashList Insertion Failed");
646 * @brief Handler to Fetch an CellCb
649 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
652 * @param[in] gCb RLC Instance Control Block
653 * @param[in] cellId Cell Identifier
654 * @param[out] cellCb UE Control Block
661 void rlcDbmFetchUlCellCb(RlcCb *gCb, CmLteCellId cellId, RlcUlCellCb **cellCb)
664 if(ROK != cmHashListFind(&(gCb->u.ulCb->cellLstCp),
665 (uint8_t *)&(cellId),sizeof(CmLteCellId),
666 RLC_DEF_SEQ_NUM, (PTR*) cellCb))
668 DU_LOG("\nERROR --> RLC_UL : rlcDbmFetchUlCellCb : CellCb[%d] not found", cellId);
676 * @brief Handler to delete CellCb
679 * This function is invoked by CFG to delete CellCb from the Cell hashlist
682 * @param[in] gCb RLC Instance Control Block
683 * @param[in] cellCb Cell Control Block
687 Void rlcDbmDelUlCellCb(RlcCb *gCb,RlcUlCellCb *cellCb)
690 /* Delete all rbCbs in cellCb */
691 rlcDbmDelAllUlRb(gCb,cellCb->rbCb, RLC_MAX_RB_PER_CELL);
693 /* Delete cellCb entry in hash list cellLstCp */
694 if(ROK != cmHashListDelete(&(gCb->u.ulCb->cellLstCp), (PTR) cellCb))
696 DU_LOG("\nERROR --> RLC_UL : HashList Deletion Failed");
698 /* Deallocate cellCb */
699 RLC_FREE(gCb, cellCb, sizeof(RlcUlCellCb));
702 } /* kwDbmDelCellCb */
706 * @brief Handler to delete all UeCbs
709 * This function is invoked by CFG to delete all UeCbs from the Ue
711 * @param[in] gCb RLC Instance Control Block
715 Void rlcDbmDelAllUlCell(RlcCb *gCb)
717 RlcUlCellCb *cellCb = NULLP; /* Cell Control Block */
719 /* Until no more cellCb is ueLstCp hash list get and delete cellCb */
720 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->cellLstCp),
724 rlcDbmDelUlCellCb(gCb,cellCb);
734 * @brief Handler to delete all UeCbs and CellCbs
737 * This function is invoked by LMM to delete all UeCbs from the Ue
738 * hashlist of RlcCb and cellCbs from the Cell hashlist of rlcCb.
740 * @param[in] gCb RLC Instance Control Block
743 Void rlcDbmUlShutdown(RlcCb *gCb)
746 rlcDbmDelAllUlCell(gCb);
748 rlcDbmDelAllUlUe(gCb);
756 /********************************************************************30**
759 **********************************************************************/