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 "kw_err.h" /* Err defines */
39 #include "kw_env.h" /* RLC environment options */
41 #include "kw.h" /* RLC defines */
44 /* extern (.x) include files */
45 #include "lkw.x" /* LKW */
46 #include "ckw.x" /* CKW */
47 #include "kwu.x" /* KWU */
48 #include "rgu.x" /* RGU */
55 * @brief RLC Uplink database module
58 #define RLC_MODULE RLC_DBGMASK_DUT
62 * @brief Handler to initialize hash list
65 * This function initializes the UeCb, CellCb and transactions hash lists
67 * @param[in] gCb RLC instance control block
73 S16 rlcDbmUlInit(RlcCb *gCb)
75 /* Initialize ueCb Hash List */
76 if(ROK != cmHashListInit(&(gCb->u.ulCb->ueLstCp),
77 (uint16_t) RLC_UE_LIST_BUCKET_SIZE,
80 (uint16_t) CM_HASH_KEYTYPE_CONID,
81 RLC_GET_MEM_REGION(gCb),
82 RLC_GET_MEM_POOL(gCb)))
84 DU_LOG("\nERROR --> RLC_UL : UeLstCp Initialization Failed");
88 /* Initialize cellCb Hash List */
89 if(ROK != cmHashListInit(&(gCb->u.ulCb->cellLstCp),
90 (uint16_t) RLC_CELL_LIST_BUCKET_SIZE,
93 (uint16_t) CM_HASH_KEYTYPE_CONID,
94 RLC_GET_MEM_REGION(gCb),
95 RLC_GET_MEM_POOL(gCb)))
97 cmHashListDeinit(&gCb->u.ulCb->ueLstCp);
98 DU_LOG("\nERROR --> RLC_UL : CellLstCp Initialization Failed");
102 if(ROK != cmHashListInit(&(gCb->u.ulCb->transIdLstCp),
103 (uint16_t) RLC_TRANS_ID_LST_BKT_SIZE,
106 (uint16_t) CM_HASH_KEYTYPE_CONID,
107 RLC_GET_MEM_REGION(gCb),
108 RLC_GET_MEM_POOL(gCb)))
110 cmHashListDeinit(&gCb->u.ulCb->ueLstCp);
111 cmHashListDeinit(&gCb->u.ulCb->cellLstCp);
112 DU_LOG("\nERROR --> RLC_UL : transIdLstCp Initialization Failed");
116 /* kw005.201 added support for L2 Measurement */
118 /* Initialize qcI Hash List */
119 #endif /* LTE_L2_MEAS */
126 * @brief Handler to De initialize hash list
128 * @param[in] gCb RLC Instance Control Block
132 Void rlcDbmUlDeInit(RlcCb *gCb)
135 /* De Initialize ueCb Hash List */
136 cmHashListDeinit(&(gCb->u.ulCb->ueLstCp));
138 /* De Initialize cellCb Hash List */
139 cmHashListDeinit(&(gCb->u.ulCb->cellLstCp));
141 /* De Initialize transaction Hash List */
142 cmHashListDeinit(&(gCb->u.ulCb->transIdLstCp));
143 /* kw005.201 added support for L2 Measurement */
144 #ifdef LTE_L2_MEAS_RLC
145 /* De Initialize qciCb Hash List */
146 cmHashListDeinit(&(rlcCb.rlcL2Cb.qciHlCp));
147 #endif /* LTE_L2_MEAS */
154 * @brief Handler to fetch rbCb by the rlcId
157 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb in
158 * the upper interface (CKW/KWU).
160 * @param[in] gCb RLC Instance Control Block
161 * @param[in] rlcId RLC Identifier
162 * @param[out] rbCb RB Control Block
166 Void rlcDbmFetchUlRbCbByRbId
175 /* Check for UE CB or CELL CB */
176 if (rlcId->ueId == 0)
180 if(rlcId->rbId >= RLC_MAX_RB_PER_CELL)
182 DU_LOG("\nERROR --> RLC_UL : Invalid RbId, cellId:%d UEID:%d Max is [%d]",
183 rlcId->cellId, rlcId->ueId, RLC_MAX_RB_PER_CELL);
187 rlcDbmFetchUlCellCb(gCb,rlcId->cellId, &cellCb);
190 DU_LOG("\nERROR --> RLC_UL : CellCb not found RBID:%d UEID:%d",
196 *rbCb = cellCb->rbCb[rlcId->rbId];
202 if (!(RLC_VALIDATE_UE_RBID(rlcId->rbType, rlcId->rbId)))
204 DU_LOG("\nERROR --> RLC_UL : Invalid RbId for RbType[%d] CELLID:%d UEID:%d",
211 if (rlcDbmFetchUlUeCb(gCb,rlcId->ueId, rlcId->cellId, &ueCb) != ROK)
213 DU_LOG("\nERROR --> RLC_UL : UeId [%d]: UeCb not found RBID:%d",
219 RLC_DBM_GET_RBCB_FROM_UECB(rlcId->rbId, rlcId->rbType, ueCb, *rbCb);
222 } /* rlcDbmFetchUlRbCbByRbId */
226 * @brief Handler to fetch rbCb from Local Channel Id
229 * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb
230 * from local Channel Id (CKW/KWU).
232 * @param[in] gCb - RLC Instance Control Block
233 * @param[in] cellId - CELL Identifier
234 * @param[in] ueId - UE Identifier
235 * @param[in] lcId - Logical Channel Identifier
236 * @param[out] rbCb - RB Control Block
241 void rlcDbmFetchUlRbCbFromLchId(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId,\
242 CmLteLcId lcId, RlcUlRbCb **rbCb)
248 /* Check for UE CB or CELL CB */
253 rlcDbmFetchUlCellCb(gCb,cellId, &cellCb);
256 DU_LOG("\nERROR --> RLC_UL : rlcDbmFetchUlRbCbFromLchId: CellCb[%d] not found UEID:%d",\
261 *rbCb = cellCb->lCh[lcId - 1].ulRbCb;
265 if (rlcDbmFetchUlUeCb(gCb,ueId, cellId, &ueCb) != ROK)
267 DU_LOG("\nERROR --> RLC_UL : rlcDbmFetchUlRbCbFromLchId: UeId [%d]: UeCb not found",ueId);
271 *rbCb = ueCb->lCh[lcId - 1].ulRbCb;
274 } /* kwDbmFetchRbCbFromLchId */
278 * @brief Handler to delete RbCb
281 * This function is invoked by CFG to remove RbCb from Ue/Cell hashlist
283 * @param[in] gCb - RLC Instance Control Block
284 * @param[in] rbCbLst - Rb Cb List
285 * @param[in] numRbCb - Number of rbCbs
290 Void rlcDbmDelAllUlRb
297 uint32_t idx; /* Index */
299 for (idx = 0; idx < numRbCb; idx++)
301 if (rbCbLst[idx] != NULLP)
303 /* Free the Buffers of RbCb */
304 if( RLC_MODE_UM == rbCbLst[idx]->mode )
306 rlcUmmFreeUlRbCb(gCb,rbCbLst[idx]);
308 else if(RLC_MODE_AM == rbCbLst[idx]->mode)
310 rlcAmmFreeUlRbCb(gCb,rbCbLst[idx]);
313 RLC_FREE (gCb,rbCbLst[idx], sizeof (RlcUlRbCb));
318 } /* kwDbmDelAllRb */
322 * @brief Handler to create an UeCb
325 * This function is invoked by CFG to create UeCb and insert into the
326 * Ue hashlist of RlcCb.
328 * @param[in] gCb RLC Instance Control Block
329 * @param[in] ueId UE Identifier
330 * @param[in] cellId Cell Identifier
331 * @param[in] ueCb UE Control Block
348 ueCb->cellId = cellId;
350 if(ROK != cmHashListInsert(&(gCb->u.ulCb->ueLstCp),
352 (uint8_t *)&(ueCb->ueId),
353 (uint16_t) sizeof(CmLteRnti)))
355 DU_LOG("\nERROR --> RLC_UL : UeId[%u] HashList Insertion Failed",
359 /* kw005.201 ccpu00117318, updating the statistics */
368 * @brief Handler to add a transaction
371 * This function adds a transaction.
373 * @param[in] gCb RLC Instance Control Block
374 * @param[in] cfg Configuration information
381 S16 rlcDbmAddUlTransaction
388 DU_LOG("\nDEBUG --> RLC_UL : (transId(%ld)", cfg->transId);
390 DU_LOG("\nDEBUG --> RLC_UL : (transId(%d))", cfg->transId);
393 return (cmHashListInsert(&(gCb->u.ulCb->transIdLstCp),
395 (uint8_t *)&(cfg->transId),
396 (uint16_t) sizeof(cfg->transId)));
401 * @brief Handler to find a transaction
404 * This function find transaction using transaction Id
407 * @param[in] gCb RLC Instance Control Block
408 * @param[in] transId Transaction Id
409 * @param[out] cfg Configuration information attached to this transaction
416 S16 rlcDbmFindUlTransaction
420 RlcUlCfgTmpData **cfg
424 if(ROK != cmHashListFind(&(gCb->u.ulCb->transIdLstCp),
425 (uint8_t *) &transId,
427 RLC_DEF_SEQ_NUM,(PTR *) cfg))
429 DU_LOG("\nERROR --> RLC_UL : TransId [%d] not found",transId);
438 * @brief Handler to delete a transaction
441 * This function deletes a transaction
444 * @param[in] gCb RLC Instance Control Block
445 * @param[in] cfg Configuration information
452 S16 rlcDbmDelUlTransaction
459 if(cmHashListDelete(&(gCb->u.ulCb->transIdLstCp),(PTR) (cfg)) != ROK)
461 DU_LOG("\nERROR --> RLC_UL : HashList Deletion failed");
470 * @brief Handler to delete all transaction
473 * This function deletes all transaction
475 * @param[in] gCb RLC Instance Control Block
482 S16 rlcDbmDelAllUlTransactions(RlcCb *gCb)
484 RlcUlCfgTmpData *cfg = NULL;
486 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
487 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->transIdLstCp),
491 if(rlcDbmDelUlTransaction(gCb, cfg) != ROK)
504 * @brief Handler to Fetch an UeCb
507 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
510 * @param[in] gCb RLC Instance Control Block
511 * @param[in] ueId UE Identifier
512 * @param[in] cellId Cell Identifier
513 * @param[out] ueCb UE Control Block
519 uint8_t rlcDbmFetchUlUeCb(RlcCb *gCb, CmLteRnti ueId, CmLteCellId cellId, RlcUlUeCb **ueCb)
521 return (cmHashListFind(&(gCb->u.ulCb->ueLstCp),
522 (uint8_t *)&(ueId), sizeof(CmLteRnti),
529 * @brief Handler to delete an UeCb
532 * This function is invoked by CFG to delete UeCb from the Ue hashlist
536 * @param[in] gCb RLC Instance Control Block
537 * @param[in] ueCb UE Control Block
538 * @param[in] abrtFlag Abort Flag
551 #if (!defined(KW_PDCP) || !(defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)))
553 #endif /* (!defined(KW_PDCP) || ! (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)))*/
555 /* Delete all logical channels */
556 RLC_MEM_ZERO(ueCb->lCh,sizeof(RlcUlLch) * RLC_MAX_LCH_PER_UE);
558 /* Delete all SRB RbCbs in UeCb */
559 rlcDbmDelAllUlRb(gCb,ueCb->srbCb, RLC_MAX_SRB_PER_UE);
561 /* Delete all DRB RbCbs in UeCb */
562 rlcDbmDelAllUlRb(gCb,ueCb->drbCb, RLC_MAX_DRB_PER_UE);
564 /* Delete ueCb entry from ueLstCp */
565 if(ROK != cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb))
567 DU_LOG("\nERROR --> RLC_UL : HashList Deletion Failed cellId(%d)",
570 /* kw005.201 ccpu00117318, updating the statistics */
572 /* Deallocate ueCb */
573 RLC_FREE(gCb,ueCb, sizeof(RlcUlUeCb));
579 * @brief Handler to delete all UeCbs
582 * This function is invoked by CFG to delete all UeCbs from the Ue
585 * @param[in] gCb RLC Instance Control Block
589 Void rlcDbmDelAllUlUe(RlcCb *gCb)
591 RlcUlUeCb *ueCb = NULLP; /* UE Control Block */
593 /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
594 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->ueLstCp),
598 rlcDbmDelUlUeCb(gCb,ueCb, TRUE);
608 * @brief Handler to create CellCb
611 * This function is invoked by CFG to create CellCb and insert into
612 * the Cell hashlist of RlcCb.
614 * @param[in] gCb RLC Instance Control Block
615 * @param[in] cellId Cell Identifier
616 * @param[in] cellCb Cell Control Block
622 S16 rlcDbmAddUlCellCb
629 RlcUlCellCb *tCellCb;
632 tCellCb->cellId = cellId;
634 if(ROK != cmHashListInsert(&(gCb->u.ulCb->cellLstCp),
636 (uint8_t *)&(tCellCb->cellId),
637 (uint16_t) sizeof(CmLteCellId)))
639 DU_LOG("\nERROR --> RLC_UL : HashList Insertion Failed");
648 * @brief Handler to Fetch an CellCb
651 * This function is invoked by CFG to fetch UeCb from the Ue hashlist
654 * @param[in] gCb RLC Instance Control Block
655 * @param[in] cellId Cell Identifier
656 * @param[out] cellCb UE Control Block
663 void rlcDbmFetchUlCellCb(RlcCb *gCb, CmLteCellId cellId, RlcUlCellCb **cellCb)
666 if(ROK != cmHashListFind(&(gCb->u.ulCb->cellLstCp),
667 (uint8_t *)&(cellId),sizeof(CmLteCellId),
668 RLC_DEF_SEQ_NUM, (PTR*) cellCb))
670 DU_LOG("\nERROR --> RLC_UL : rlcDbmFetchUlCellCb : CellCb[%d] not found", cellId);
678 * @brief Handler to delete CellCb
681 * This function is invoked by CFG to delete CellCb from the Cell hashlist
684 * @param[in] gCb RLC Instance Control Block
685 * @param[in] cellCb Cell Control Block
689 Void rlcDbmDelUlCellCb(RlcCb *gCb,RlcUlCellCb *cellCb)
692 /* Delete all rbCbs in cellCb */
693 rlcDbmDelAllUlRb(gCb,cellCb->rbCb, RLC_MAX_RB_PER_CELL);
695 /* Delete cellCb entry in hash list cellLstCp */
696 if(ROK != cmHashListDelete(&(gCb->u.ulCb->cellLstCp), (PTR) cellCb))
698 DU_LOG("\nERROR --> RLC_UL : HashList Deletion Failed");
700 /* Deallocate cellCb */
701 RLC_FREE(gCb, cellCb, sizeof(RlcUlCellCb));
704 } /* kwDbmDelCellCb */
708 * @brief Handler to delete all UeCbs
711 * This function is invoked by CFG to delete all UeCbs from the Ue
713 * @param[in] gCb RLC Instance Control Block
717 Void rlcDbmDelAllUlCell(RlcCb *gCb)
719 RlcUlCellCb *cellCb = NULLP; /* Cell Control Block */
721 /* Until no more cellCb is ueLstCp hash list get and delete cellCb */
722 while (ROK == cmHashListGetNext(&(gCb->u.ulCb->cellLstCp),
726 rlcDbmDelUlCellCb(gCb,cellCb);
736 * @brief Handler to delete all UeCbs and CellCbs
739 * This function is invoked by LMM to delete all UeCbs from the Ue
740 * hashlist of RlcCb and cellCbs from the Cell hashlist of rlcCb.
742 * @param[in] gCb RLC Instance Control Block
745 Void rlcDbmUlShutdown(RlcCb *gCb)
748 rlcDbmDelAllUlCell(gCb);
750 rlcDbmDelAllUlUe(gCb);
758 /********************************************************************30**
761 **********************************************************************/