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 /************************************************************************
25 Desc: C source code for Entry point fucntions
29 **********************************************************************/
32 @brief This file contains the APIs exposed for the insertion/fetching/deletion of cellCb/ueCb and traversal of LcCbLst.
35 /* header include files -- defines (.h) */
36 #include "common_def.h"
38 #include "du_app_mac_inf.h"
42 #include "rg_sch_inf.h"
46 /* header/extern include files (.x) */
51 #include "rg_sch_inf.x"
52 #include "rg_prg.x" /* PRG interface typedefs*/
56 static S16 rgDBMInitUeCbLst ARGS(( RgCellCb *cellCb, uint16_t numBins));
57 static Void rgDBMInitDedLcLst ARGS((RgUeCb *ueCb));
58 static Void rgDBMInitCmnLcLst ARGS((RgCellCb *cellCb));
59 static Void rgDBMInitRachLst ARGS((RgCellCb *cellCb));
61 static S16 rgDBMInitSpsUeCbLst ARGS((
71 /* forward references */
74 * @brief Handler for Initializing the cell.
78 * Function : rgDBMInitCell
80 * Initializes the lists belonging to the cell.
83 * @param[in] RgCellCb *cellCb
95 /* Initialize ue list */
96 if ((ret = rgDBMInitUeCbLst(cellCb, RG_MAX_UE_BIN_PER_CELL)) != ROK)
100 /* Initialize SPS Ue list */
101 if ((ret = rgDBMInitSpsUeCbLst(cellCb, RG_MAX_UE_BIN_PER_CELL)) != ROK)
103 #endif /* LTEMAC_SPS */
105 /* Initialize BCCH/PCCH logical channels */
106 rgDBMInitCmnLcLst(cellCb);
109 /* Initialize rach ue list */
110 rgDBMInitRachLst(cellCb);
114 } /* rgDBMInitCell */
117 * @brief Handler for initializing the ueCbLst under the cellCb.
121 * Function : rgDBMInitUeCbLst
130 static S16 rgDBMInitUeCbLst
136 Inst inst = cellCb->macInst - RG_INST_START;
139 return (cmHashListInit(&cellCb->ueLst, numBins, (uint16_t)((PTR)&(ue.ueLstEnt) - (PTR)&ue), FALSE,
140 CM_HASH_KEYTYPE_CONID, rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool));
142 } /* rgDBMInitUeCbLst */
145 * @brief Handler for de-initializing the ueCbLst under the cellCb.
149 * Function : rgDBMDeInitUeCbLst
157 S16 rgDBMDeInitUeCbLst(RgCellCb *cellCb)
160 return (cmHashListDeinit(&cellCb->ueLst));
162 } /* rgDBMDeInitUeCbLst */
166 * @brief Handler for initializing the spsUeCbLst under the cellCb.
170 * Function : rgDBMInitSpsUeCbLst
179 static S16 rgDBMInitSpsUeCbLst(RgCellCb *cellCb,uint16_t numBins)
181 Inst inst = cellCb->macInst - RG_INST_START;
184 return (cmHashListInit(&cellCb->spsUeLst, numBins, (uint16_t) ((PTR) &(ue.spsUeLstEnt) - (PTR) &ue), FALSE,
185 CM_HASH_KEYTYPE_CONID, rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool));
187 } /* rgDBMInitSpsUeCbLst */
190 * @brief Handler for de-initializing the spsUeCbLst under the cellCb.
194 * Function : rgDBMDeInitSpsUeCbLst
202 S16 rgDBMDeInitSpsUeCbLst(RgCellCb *cellCb)
205 return (cmHashListDeinit(&cellCb->spsUeLst));
207 } /* rgDBMDeInitSpsUeCbLst */
209 #endif /* LTEMAC_SPS */
212 * @brief Handler for inserting the ueCb in to the ueCbLst under the cellCb.
216 * Function : rgDBMInsUeCb
225 S16 rgDBMInsUeCb(RgCellCb *cellCb,RgUeCb *ueCb)
227 return (cmHashListInsert(&cellCb->ueLst, (PTR)ueCb,
228 (uint8_t *)&ueCb->ueId, (uint16_t)sizeof(ueCb->ueId)));
234 * @brief Handler for inserting the ueCb in to the spsUeCbLst under the cellCb.
238 * Function : rgDBMInsSpsUeCb
247 S16 rgDBMInsSpsUeCb(RgCellCb *cellCb,RgUeCb *ueCb)
250 return (cmHashListInsert(&cellCb->spsUeLst, (PTR)ueCb,
251 (uint8_t *)&ueCb->spsRnti, (uint16_t)sizeof(ueCb->spsRnti)));
253 } /* end of rgDBMInsSpsUeCb */
255 #endif /* LTEMAC_SPS */
258 * @brief Handler for accessing the existing ueCb identified by the key ueId
259 * in the ueCbLst under the cellCb.
263 * Function : rgDBMGetUeCb
270 RgUeCb* rgDBMGetUeCb(RgCellCb *cellCb, CmLteRnti ueId)
272 RgUeCb *ueCb = NULLP;
274 cmHashListFind(&cellCb->ueLst, (uint8_t *)&ueId,
275 sizeof(ueId), 0, (PTR *)&ueCb);
281 * @brief Handler for accessing the ueCb identified by the key sps-rnti
282 * in the spsUeLst under the cellCb.
286 * Function : rgDBMGetSpsUeCb
293 RgUeCb* rgDBMGetSpsUeCb(RgCellCb *cellCb, CmLteRnti spsRnti)
295 RgUeCb *ueCb = NULLP;
297 cmHashListFind(&cellCb->spsUeLst, (uint8_t *)&spsRnti,
298 sizeof(spsRnti), 0, (PTR *)&ueCb);
300 } /* rgDBMGetSpsUeCb */
302 #endif /* LTEMAC_SPS */
305 * @brief Handler for accessing the existing next ueCb in the ueCbLst under the
310 * Function : rgDBMGetNextUeCb
317 RgUeCb* rgDBMGetNextUeCb(RgCellCb *cellCb, RgUeCb *ueCb)
319 RgUeCb *nextUeCb = NULLP;
321 cmHashListGetNext(&cellCb->ueLst, (PTR) ueCb, (PTR *)&nextUeCb);
323 } /* rgDBMGetNextUeCb */
327 * @brief Handler for accessing the existing next ueCb stored in the spsUeCbLst
328 * using SPS-Rnti under the cellCb.
332 * Function : rgDBMGetNextSpsUeCb
339 RgUeCb* rgDBMGetNextSpsUeCb(RgCellCb *cellCb, RgUeCb *ueCb)
341 RgUeCb *nextUeCb = NULLP;
343 cmHashListGetNext(&cellCb->spsUeLst, (PTR) ueCb, (PTR *)&nextUeCb);
345 } /* end of rgDBMGetNextSpsUeCb */
347 #endif /* LTEMAC_SPS */
351 * @brief Handler for deleting the existing ueCb from the ueCbLst under the
356 * Function : rgDBMDelUeCb
365 S16 rgDBMDelUeCb(RgCellCb *cellCb, RgUeCb *ueCb)
367 return (cmHashListDelete(&cellCb->ueLst, (PTR)ueCb));
372 * @brief Handler for deleting the existing ueCb from the spsUeCbLst under the
377 * Function : rgDBMDelSpsUeCb
386 S16 rgDBMDelSpsUeCb(RgCellCb *cellCb, RgUeCb *ueCb)
389 return (cmHashListDelete(&cellCb->spsUeLst, (PTR)ueCb));
390 } /* end of rgDBMDelSpsUeCb */
392 #endif /* LTEMAC_SPS */
395 * @brief Handler for Initializing the UE.
399 * Function : rgDBMInitUe
401 * Initializes the lists belonging to the UE.
404 * @param[in] RgUeCb *ueCb
409 Void rgDBMInitUe(RgUeCb *ueCb)
415 /* Initialize Dedicated logical channels */
416 rgDBMInitDedLcLst(ueCb);
419 /* Initialize the SPS LC Ids */
420 for (idx=0; idx < RG_MAX_LC_PER_UE; idx++)
422 ueCb->ul.spsLcId[idx] = FALSE;
431 * @brief Handler for Initializing the dedicated logical channels.
435 * Function : rgDBMInitDedLcLst
437 * Initializes dedicated logical channels.
439 * @param[in] RgUeCb *ueCb
442 static Void rgDBMInitDedLcLst(RgUeCb *ueCb)
446 for (idx = 0; idx < RG_MAX_LC_PER_UE; ++idx)
448 /* Set Dedicated LCs as not configured */
449 ueCb->ul.lcCb[idx].lcId = RG_INVALID_LC_ID;
450 ueCb->ul.lcCb[idx].lcgId = RG_INVALID_LCG_ID;
451 ueCb->dl.lcCb[idx].lcId = RG_INVALID_LC_ID;
454 for (idx = 0; idx < RG_MAX_LCG_PER_UE; ++idx)
456 /* Set LCGs as not configured */
457 ueCb->ul.lcgArr[idx].lcgId = RG_INVALID_LCG_ID;
458 ueCb->ul.lcgArr[idx].lcCount = 0;
461 /* Stack Crash problem for TRACE5 Changes. Added the return below */
463 } /* rgDBMInitDedLcLst */
466 * @brief Handler for Initializing the common logical channel list of the cell.
470 * Function : rgDBMInitCmnLcLst
472 * Initializes following common logical channels belonging to the cell.
477 * @param[in] RgCellCb *cellCb
480 static Void rgDBMInitCmnLcLst(RgCellCb *cellCb)
484 cellCb->bcchBchInfo.lcId = RG_INVALID_LC_ID;
485 cellCb->pcchInfo.lcId = RG_INVALID_LC_ID;
487 cellCb->numBcchDlschInfo = 0;
488 for (idx = 0; idx < RG_MAX_BCCH_DLSCH; idx++)
490 cellCb->bcchDlschInfo[idx].lcId = RG_INVALID_LC_ID;
491 cellCb->bcchDlschInfo[idx].tb = NULLP;
494 /* Stack Crash problem for TRACE5 Changes. Added the return below */
496 } /* rgDBMInitCmnLcLst */
499 * @brief Handler for Initializing the common logical channel list of the cell.
503 * Function : rgDBMFreeCmnLcLst
505 * Initializes following common logical channels belonging to the cell.
510 * @param[in] RgCellCb *cellCb
513 Void rgDBMFreeCmnLcLst(RgCellCb *cellCb)
517 cellCb->bcchBchInfo.lcId = RG_INVALID_LC_ID;
518 cellCb->pcchInfo.lcId = RG_INVALID_LC_ID;
520 for (idx = 0; idx < cellCb->numBcchDlschInfo; idx++)
522 cellCb->bcchDlschInfo[idx].lcId = RG_INVALID_LC_ID;
523 RG_FREE_MSG(cellCb->bcchDlschInfo[idx].tb);
525 cellCb->numBcchDlschInfo = 0;
527 /* Stack Crash problem for TRACE5 Changes. Added the return below */
529 } /* rgDBMFreeCmnLcLst */
532 * @brief Handler for inserting dedicated DL logical channel.
536 * Function : rgDBMInsDlDedLcCb
538 * @param[in] RgUeCb *ueCb
539 * @param[in] RgDlLcCb* dlLcCb
542 Void rgDBMInsDlDedLcCb(RgUeCb *ueCb, CmLteLcId idx)
544 if( idx >= RG_DEDLC_MIN_LCID )
546 ueCb->dl.lcCb[idx-1].lcId = idx;
548 /* Stack Crash problem for TRACE5 Changes. Added the return below */
550 } /* rgDBMInsDlDedLcCb */
553 * @brief Handler for deleting dedicated DL logical channel.
557 * Function : rgDBMDelDlDedLcCb
559 * @param[in] RgUeCb *ueCb
560 * @param[in] RgDlLcCb* dlLcCb
563 Void rgDBMDelDlDedLcCb(RgUeCb *ueCb, RgDlLcCb *dlLcCb)
565 ueCb->dl.lcCb[dlLcCb->lcId - 1].lcId = RG_INVALID_LC_ID;
567 /* Stack Crash problem for TRACE5 Changes. Added the return below */
570 } /* rgDBMDelDlDedLcCb */
573 * @brief Handler for accessing the existing DL dedicated lcCb at idx in the
574 * lcCbLst of the ueCb.
578 * Function : rgDBMGetDlDedLcCb
584 RgDlLcCb* rgDBMGetDlDedLcCb(RgUeCb *ueCb, CmLteLcId idx)
586 if (idx > RG_DEDLC_MAX_LCID || idx <= 0)
590 if(ueCb->dl.lcCb[idx-1].lcId == RG_INVALID_LC_ID)
595 return (&ueCb->dl.lcCb[idx-1]);
597 } /* rgDBMGetDlDedLcCb */
600 * @brief Handler for inserting dedicated UL logical channel.
604 * Function : rgDBMInsUlDedLcCb
607 * @param[in] RgUeCb *ueCb
608 * @param[in] CmLteLcId idx
609 * @param[in] LteLcgId gId
613 Void rgDBMInsUlDedLcCb
621 Void rgDBMInsUlDedLcCb
629 if ( idx >= RG_DEDLC_MIN_LCID)
631 ueCb->ul.lcCb[idx - 1].lcId = idx;
632 ueCb->ul.lcCb[idx - 1].lcgId = gId;
634 ueCb->ul.lcCb[idx - 1].qci = qci;
637 if(ueCb->ul.lcgArr[gId].lcgId == RG_INVALID_LCG_ID)
639 ueCb->ul.lcgArr[gId].lcgId = gId;
641 ueCb->ul.lcgArr[gId].lcCount = ueCb->ul.lcgArr[gId].lcCount + 1;
644 /* Stack Crash problem for TRACE5 Changes. Added the return below */
647 } /* rgDBMInsUlDedLcCb */
650 * @brief Handler for deleting the dedicated UL logical channel.
654 * Function : rgDBMUpdUlDedLcCb
657 * @param[in] RgUeCb *ueCb
658 * @param[in] RgUlLcCb* ulLcCb
659 * @param[in] LteLcgId gId
662 Void rgDBMUpdUlDedLcCb
669 ueCb->ul.lcgArr[ulLcCb->lcgId].lcCount =
670 ueCb->ul.lcgArr[ulLcCb->lcgId].lcCount - 1;
671 if(ueCb->ul.lcgArr[ulLcCb->lcgId].lcCount == 0)
673 ueCb->ul.lcgArr[ulLcCb->lcgId].lcgId = RG_INVALID_LCG_ID;
675 ueCb->ul.lcCb[ulLcCb->lcId - 1].lcgId = gId;
677 if(ueCb->ul.lcgArr[gId].lcgId == RG_INVALID_LCG_ID)
679 ueCb->ul.lcgArr[gId].lcgId = gId;
681 ueCb->ul.lcgArr[gId].lcCount = ueCb->ul.lcgArr[gId].lcCount + 1;
683 /* Stack Crash problem for TRACE5 Changes. Added the return below */
685 } /* rgDBMUpdUlDedLcCb */
688 * @brief Handler for updating the dedicated UL logical channel.
692 * Function : rgDBMDelUlDedLcCb
695 * @param[in] RgUeCb *ueCb
696 * @param[in] RgUlLcCb* ulLcCb
699 Void rgDBMDelUlDedLcCb(RgUeCb *ueCb, RgUlLcCb *ulLcCb)
702 ueCb->ul.lcgArr[ulLcCb->lcgId].lcCount =
703 ueCb->ul.lcgArr[ulLcCb->lcgId].lcCount - 1;
704 if(ueCb->ul.lcgArr[ulLcCb->lcgId].lcCount == 0)
706 ueCb->ul.lcgArr[ulLcCb->lcgId].lcgId = RG_INVALID_LCG_ID;
708 ueCb->ul.lcCb[ulLcCb->lcId - 1].lcgId = RG_INVALID_LCG_ID;
709 ueCb->ul.lcCb[ulLcCb->lcId - 1].lcId = RG_INVALID_LC_ID;
711 /* Stack Crash problem for TRACE5 Changes. Added the return below */
713 } /* rgDBMDelUlDedLcCb */
716 * @brief Handler for accessing the existing UL dedicated lcCb at idx in the
717 * lcCbLst of the ueCb.
721 * Function : rgDBMGetUlDedLcCb
728 RgUlLcCb* rgDBMGetUlDedLcCb(RgUeCb *ueCb, CmLteLcId idx)
731 if (idx > RG_DEDLC_MAX_LCID || idx < RG_DEDLC_MIN_LCID)
735 if(ueCb->ul.lcCb[idx-1].lcId == RG_INVALID_LC_ID)
740 return (&ueCb->ul.lcCb[idx-1]);
741 } /* rgDBMGetDlDedLcCb */
744 * @brief Handler for accessing the existing DL common lcCb identified by the key lcId
745 * in the lcCbLst of the ueCb.
749 * Function : rgDBMChkCmnLcCb
758 S16 rgDBMChkCmnLcCb(RgCellCb *cellCb, CmLteLcId lcId)
762 if(cellCb->bcchBchInfo.lcId == lcId)
766 if(cellCb->pcchInfo.lcId == lcId)
771 for (idx = 0; idx < cellCb->numBcchDlschInfo; idx++)
773 if(cellCb->bcchDlschInfo[idx].lcId == lcId)
779 } /* rgDBMChkCmnLcCb */
782 * @brief Handler for accessing the existing BCCH mapped on to BCH in the
783 * lcCbLst of the ueCb.
787 * Function : rgDBMGetBcchOnBch
791 * @return RgBcchBchLcCb*
793 RgBcchBchLcCb* rgDBMGetBcchOnBch(RgCellCb *cellCb)
796 if(cellCb->bcchBchInfo.lcId != RG_INVALID_LC_ID)
798 return (&(cellCb->bcchBchInfo));
801 } /* rgDBMGetBcchOnBch */
804 * @brief Handler for accessing the existing BCCH mapped on to DLSCH in the
805 * lcCbLst of the ueCb.
809 * Function : rgDBMGetBcchOnDlsch
814 * @return RgBcchDlschLcCb*
816 RgBcchDlschLcCb* rgDBMGetBcchOnDlsch(RgCellCb *cellCb,CmLteLcId lcId)
820 for (idx = 0; idx < RG_MAX_BCCH_DLSCH; idx++)
822 if(cellCb->bcchDlschInfo[idx].lcId == lcId)
824 return (&(cellCb->bcchDlschInfo[idx]));
828 } /* rgDBMGetBcchOnDlsch */
831 * @brief Handler for accessing the existing PCCH in the lcCbLst of the ueCb.
835 * Function : rgDBMGetPcch
839 * @return RgPcchLcCb*
841 RgPcchLcCb* rgDBMGetPcch(RgCellCb *cellCb)
844 if(cellCb->pcchInfo.lcId != RG_INVALID_LC_ID)
846 return (&(cellCb->pcchInfo));
852 * @brief Handler for inserting the BCCH mapped on to BCH in the
853 * lcCbLst of the ueCb.
857 * Function : rgDBMInsBcchOnBch
863 Void rgDBMInsBcchOnBch(RgCellCb *cellCb, CmLteLcId idx)
866 cellCb->bcchBchInfo.lcId = idx;
868 /* Stack Crash problem for TRACE5 Changes. Added the return below */
870 } /* rgDBMInsBcchOnBch */
873 * @brief Handler for inserting the BCCH mapped on to DLSCH in the
874 * lcCbLst of the ueCb.
878 * Function : rgDBMInsBcchOnDlsch
884 Void rgDBMInsBcchOnDlsch(RgCellCb *cellCb, CmLteLcId idx)
887 cellCb->bcchDlschInfo[cellCb->numBcchDlschInfo].lcId = idx;
888 cellCb->numBcchDlschInfo++;
890 /* Stack Crash problem for TRACE5 Changes. Added the return below */
892 } /* rgDBMInsBcchOnDlsch */
896 * @brief Handler for inserting the PCCH in the lcCbLst of the ueCb.
900 * Function : rgDBMInsPcch
906 Void rgDBMInsPcch(RgCellCb *cellCb, CmLteLcId idx)
909 cellCb->pcchInfo.lcId = idx;
911 /* Stack Crash problem for TRACE5 Changes. Added the return below */
916 * @brief Handler for initializing the rachLst
920 * Function : rgDBMInitRachLst
926 static Void rgDBMInitRachLst(RgCellCb *cellCb)
929 cmLListInit(&cellCb->raInfo.ueRachLst);
931 } /* rgDBMInitRachLst */
934 * @brief Handler for inserting the ueCb in the rachLst.
938 * Function : rgDBMInsUeCbInRachLst
945 Void rgDBMInsUeCbInRachLst(RgCellCb *cellCb, RgUeCb *ueCb)
948 cmLListAdd2Tail(&cellCb->raInfo.ueRachLst,&ueCb->rachLstEnt);
951 } /* rgDBMInsUeCbInRachLst */
954 * @brief Handler for accessing the existing raCb in the rachLst.
958 * Function : rgDBMGetUeCbFromRachLst
965 RgUeCb* rgDBMGetUeCbFromRachLst(RgCellCb *cellCb, CmLteRnti key)
969 CM_LLIST_FIRST_NODE(&cellCb->raInfo.ueRachLst,tmpNode);
972 if(((RgUeCb *)tmpNode->node)->ueId == key)
974 return ((RgUeCb *)(tmpNode->node));
976 CM_LLIST_NEXT_NODE(&cellCb->raInfo.ueRachLst,tmpNode);
979 } /* rgDBMGetUeCbFromRachLst */
982 * @brief Handler for accessing the existing ueCb from rachLst.
986 * Function : rgDBMGetNextUeCbFromRachLst
993 RgUeCb* rgDBMGetNextUeCbFromRachLst(RgCellCb *cellCb,RgUeCb *ueCb)
998 return ( cellCb->raInfo.ueRachLst.first ?
999 (RgUeCb *)(cellCb->raInfo.ueRachLst.first->node) : NULLP );
1001 return ( ueCb->rachLstEnt.next ?
1002 (RgUeCb *)(ueCb->rachLstEnt.next->node) : NULLP );
1003 } /* rgDBMGetNextUeCbFromRachLst */
1006 * @brief Handler for deleting the existing ueCb in the rachLst.
1010 * Function : rgDBMDelUeCbFromRachLst
1013 * @param[in] *cellCb
1017 Void rgDBMDelUeCbFromRachLst(RgCellCb *cellCb, RgUeCb *ueCb)
1020 cmLListDelFrm(&cellCb->raInfo.ueRachLst, &ueCb->rachLstEnt);
1022 } /* rgDBMDelUeCbFromRachLst */
1024 /**********************************************************************
1027 **********************************************************************/