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 /**********************************************************************
29 **********************************************************************/
31 /* header (.h) include files */
32 #include "common_def.h"
33 #include "lkw.h" /* LKW defines */
34 #include "ckw.h" /* CKW defines */
35 #include "kwu.h" /* KWU defines */
36 #include "rgu.h" /* RGU defines */
37 #include "kw_err.h" /* RLC error options */
38 #include "kw_env.h" /* RLC environment options */
39 #include "kw.h" /* RLC defines */
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 */
51 #include "l2_tenb_stats.x" /* Total EnodeB Stats declarations */
55 TSL2CellStatsCb* l2CellStats[L2_STATS_MAX_CELLS];
56 TSL2UeStatsCb* l2UeStats[L2_STATS_MAX_UES];
57 CmLListCp freeL2UeStatsLst; /*!< Free Pool of UE stats Blocks */
58 CmLListCp inUseL2UeStatsLst;/*!< In Use Pool of UE stats Blocks */
62 * Fun: TSL2AllocStatsMem
64 * Desc: Pre-Allocate Memory for L2 stats BLOCKs
73 Void TSL2AllocStatsMem
79 Void TSL2AllocStatsMem(region, pool)
86 cmLListInit(&inUseL2UeStatsLst);
87 cmLListInit(&freeL2UeStatsLst);
88 for (cnt=0; cnt < L2_STATS_MAX_CELLS; cnt++)
90 if(NULL == l2CellStats[cnt])
92 if (SGetSBuf(region, pool, (Data **)&l2CellStats[cnt],
93 (Size)sizeof (TSL2CellStatsCb)) != ROK)
95 printf("\n STATS Unexpected MEM Alloc Failure\n");
98 memset(l2CellStats[cnt], 0x00, sizeof(TSL2CellStatsCb));
101 for (cnt=0; cnt < L2_STATS_MAX_UES; cnt++)
103 TSL2UeStatsCb *statsCb = l2UeStats[cnt];
106 if (SGetSBuf(region, pool, (Data **)&statsCb,
107 (Size)sizeof (TSL2UeStatsCb)) != ROK)
109 printf("\n STATS Unexpected MEM Alloc Failure at %d\n", (int)cnt);
112 memset(statsCb, 0x00, sizeof(TSL2UeStatsCb));
113 statsCb->lnk.node = (PTR)statsCb;
114 cmLListAdd2Tail(&freeL2UeStatsLst, &statsCb->lnk);
115 l2UeStats[cnt] = statsCb;
123 * Fun: TSL2AllocUeStatsBlk
125 * Desc: Assign Stats Block for this UE[RNTI]
134 TSL2UeStatsCb* TSL2AllocUeStatsBlk
139 TSL2UeStatsCb* TSL2AllocUeStatsBlk(rnti)
143 CmLList *tmp = NULLP;
144 TSL2UeStatsCb *statsCb = NULLP;
146 tmp = freeL2UeStatsLst.first;
149 printf("\n STATS Unexpected Mem BLK unavailable for UE %d\n", rnti);
151 cmLListDelFrm(&freeL2UeStatsLst, tmp);
152 statsCb = (TSL2UeStatsCb *)(tmp->node);
153 cmLListAdd2Tail(&inUseL2UeStatsLst, tmp);
155 statsCb->stats.rnti = (uint32_t)rnti;
156 statsCb->inUse = TRUE;
163 * Fun: TSL2DeallocUeStatsBlk
165 * Desc: Deassign Stats Block for this UE[RNTI]
174 Void TSL2DeallocUeStatsBlk
177 TSL2UeStatsCb *statsCb
180 Void TSL2DeallocUeStatsBlk(rnti, statsCb)
182 TSL2UeStatsCb *statsCb;
185 statsCb->inUse = FALSE;
186 cmLListDelFrm(&inUseL2UeStatsLst, &statsCb->lnk);
187 freeL2UeStatsLst.crnt = freeL2UeStatsLst.first;
188 cmLListInsAfterCrnt(&freeL2UeStatsLst, &statsCb->lnk);
195 * Fun: TSL2AllocCellStatsBlk
197 * Desc: Assign Stats Block for this CELL[CELLID]
206 TSL2CellStatsCb* TSL2AllocCellStatsBlk
211 TSL2CellStatsCb* TSL2AllocCellStatsBlk(cellId)
217 printf("\n STATS Unexpected CellID = %d\n", (int)cellId);
220 return (l2CellStats[cellId-1]);
225 * Fun: TSL2DeallocCellStatsBlk
227 * Desc: Deassign Stats Block for this CELL[CELLID]
236 Void TSL2DeallocCellStatsBlk
241 Void TSL2DeallocCellStatsBlk(cellId)
251 * Fun: TSL2SendStatsToApp
253 * Desc: Collates and Sends STATS to Application
254 * Send UE STATS first. 10 UEs are grouped in one message.
255 * Followed by CELL Stats. All CELLS are grouped in one msg.
256 * At Reception of CELL stats APP assumes STATS reception cycle is complete.
265 Void TSL2SendStatsToApp
271 Void TSL2SendStatsToApp(pst, suId)
278 for (idx = 0; idx < L2_STATS_MAX_UES; idx++)
280 TSL2UeStatsCb *statsCb = l2UeStats[idx];
282 if (statsCb->inUse != TRUE)
286 if (pst->selector == 0)
289 TSInfPkSndL2UeStats(pst, suId, &statsCb->stats);
295 TSInfHdlL2UeStatsInd(pst, suId, &statsCb->stats);
298 rnti = statsCb->stats.rnti;
299 memset(&statsCb->stats.nonPersistent, 0x00, sizeof(statsCb->stats.nonPersistent));
300 /* memset(&statsCb->stats, 0x00, sizeof(TSInfL2UeStats)); */
301 statsCb->stats.rnti = rnti;
304 /* Allocate mBuf for CELLSTATS */
305 for (idx = 0; idx < L2_STATS_MAX_CELLS; idx++)
307 TSL2CellStatsCb *statsCellCb = l2CellStats[idx];
309 if (pst->selector == 0)
312 TSInfPkSndL2CellStats(pst, suId, l2CellStats[idx]);
318 TSInfHdlL2CellStatsInd(pst, suId, l2CellStats[idx]);
321 cellId = statsCellCb->cellId;
322 memset(l2CellStats[idx], 0x00, sizeof(TSInfL2CellStats));
323 statsCellCb->cellId = cellId;
327 #endif /* TENB_STATS */
328 /**********************************************************************
330 **********************************************************************/