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 "envopt.h" /* environment options */
33 #include "envdep.h" /* environment dependent */
34 #include "envind.h" /* environment independent */
36 #include "gen.h" /* general */
37 #include "ssi.h" /* system services */
38 #include "cm5.h" /* common timer defines */
39 #include "cm_tkns.h" /* common tokens defines */
40 #include "cm_mblk.h" /* common memory allocation library defines */
41 #include "cm_llist.h" /* common link list defines */
42 #include "cm_hash.h" /* common hash list defines */
43 #include "cm_lte.h" /* common LTE defines */
44 #include "lkw.h" /* LKW defines */
45 #include "ckw.h" /* CKW defines */
46 #include "kwu.h" /* KWU defines */
47 #include "rgu.h" /* RGU defines */
48 #include "kw_err.h" /* RLC error options */
49 #include "kw_env.h" /* RLC environment options */
50 #include "kw.h" /* RLC defines */
53 /* extern (.x) include files */
54 #include "gen.x" /* general */
55 #include "ssi.x" /* system services */
57 #include "cm5.x" /* common timer library */
58 #include "cm_tkns.x" /* common tokens */
59 #include "cm_mblk.x" /* common memory allocation */
60 #include "cm_llist.x" /* common link list */
61 #include "cm_hash.x" /* common hash list */
62 #include "cm_lte.x" /* common LTE includes */
63 #include "cm_lib.x" /* common memory allocation library */
64 #include "lkw.x" /* LKW */
65 #include "ckw.x" /* CKW */
66 #include "kwu.x" /* KWU */
67 #include "rgu.x" /* RGU */
72 #include "l2_tenb_stats.x" /* Total EnodeB Stats declarations */
76 PUBLIC TSL2CellStatsCb* l2CellStats[L2_STATS_MAX_CELLS];
77 PUBLIC TSL2UeStatsCb* l2UeStats[L2_STATS_MAX_UES];
78 PUBLIC CmLListCp freeL2UeStatsLst; /*!< Free Pool of UE stats Blocks */
79 PUBLIC CmLListCp inUseL2UeStatsLst;/*!< In Use Pool of UE stats Blocks */
83 * Fun: TSL2AllocStatsMem
85 * Desc: Pre-Allocate Memory for L2 stats BLOCKs
94 PUBLIC Void TSL2AllocStatsMem
100 PUBLIC Void TSL2AllocStatsMem(region, pool)
107 TRC2(TSL2AllocStatsMem)
109 cmLListInit(&inUseL2UeStatsLst);
110 cmLListInit(&freeL2UeStatsLst);
111 for (cnt=0; cnt < L2_STATS_MAX_CELLS; cnt++)
113 if(NULL == l2CellStats[cnt])
115 if (SGetSBuf(region, pool, (Data **)&l2CellStats[cnt],
116 (Size)sizeof (TSL2CellStatsCb)) != ROK)
118 printf("\n STATS Unexpected MEM Alloc Failure\n");
121 cmMemset((U8 *)l2CellStats[cnt], 0x00, (Size)sizeof(TSL2CellStatsCb));
124 for (cnt=0; cnt < L2_STATS_MAX_UES; cnt++)
126 TSL2UeStatsCb *statsCb = l2UeStats[cnt];
129 if (SGetSBuf(region, pool, (Data **)&statsCb,
130 (Size)sizeof (TSL2UeStatsCb)) != ROK)
132 printf("\n STATS Unexpected MEM Alloc Failure at %d\n", (int)cnt);
135 cmMemset((U8 *)statsCb, 0x00, (Size)sizeof(TSL2UeStatsCb));
136 statsCb->lnk.node = (PTR)statsCb;
137 cmLListAdd2Tail(&freeL2UeStatsLst, &statsCb->lnk);
138 l2UeStats[cnt] = statsCb;
146 * Fun: TSL2AllocUeStatsBlk
148 * Desc: Assign Stats Block for this UE[RNTI]
157 PUBLIC TSL2UeStatsCb* TSL2AllocUeStatsBlk
162 PUBLIC TSL2UeStatsCb* TSL2AllocUeStatsBlk(rnti)
166 CmLList *tmp = NULLP;
167 TSL2UeStatsCb *statsCb = NULLP;
169 TRC2(TSL2AllocUeStatsBlk)
171 tmp = freeL2UeStatsLst.first;
174 printf("\n STATS Unexpected Mem BLK unavailable for UE %d\n", rnti);
176 cmLListDelFrm(&freeL2UeStatsLst, tmp);
177 statsCb = (TSL2UeStatsCb *)(tmp->node);
178 cmLListAdd2Tail(&inUseL2UeStatsLst, tmp);
180 statsCb->stats.rnti = (U32)rnti;
181 statsCb->inUse = TRUE;
188 * Fun: TSL2DeallocUeStatsBlk
190 * Desc: Deassign Stats Block for this UE[RNTI]
199 PUBLIC Void TSL2DeallocUeStatsBlk
202 TSL2UeStatsCb *statsCb
205 PUBLIC Void TSL2DeallocUeStatsBlk(rnti, statsCb)
207 TSL2UeStatsCb *statsCb;
210 TRC2(TSL2DeallocUeStatsBlk)
212 statsCb->inUse = FALSE;
213 cmLListDelFrm(&inUseL2UeStatsLst, &statsCb->lnk);
214 freeL2UeStatsLst.crnt = freeL2UeStatsLst.first;
215 cmLListInsAfterCrnt(&freeL2UeStatsLst, &statsCb->lnk);
222 * Fun: TSL2AllocCellStatsBlk
224 * Desc: Assign Stats Block for this CELL[CELLID]
233 PUBLIC TSL2CellStatsCb* TSL2AllocCellStatsBlk
238 PUBLIC TSL2CellStatsCb* TSL2AllocCellStatsBlk(cellId)
242 TRC2(TSL2AllocCellStatsBlk)
246 printf("\n STATS Unexpected CellID = %d\n", (int)cellId);
249 RETVALUE(l2CellStats[cellId-1]);
254 * Fun: TSL2DeallocCellStatsBlk
256 * Desc: Deassign Stats Block for this CELL[CELLID]
265 PUBLIC Void TSL2DeallocCellStatsBlk
270 PUBLIC Void TSL2DeallocCellStatsBlk(cellId)
274 TRC2(TSL2DeallocCellStatsBlk)
281 * Fun: TSL2SendStatsToApp
283 * Desc: Collates and Sends STATS to Application
284 * Send UE STATS first. 10 UEs are grouped in one message.
285 * Followed by CELL Stats. All CELLS are grouped in one msg.
286 * At Reception of CELL stats APP assumes STATS reception cycle is complete.
295 PUBLIC Void TSL2SendStatsToApp
301 PUBLIC Void TSL2SendStatsToApp(pst, suId)
308 TRC2(TSL2SendStatsToApp)
310 for (idx = 0; idx < L2_STATS_MAX_UES; idx++)
312 TSL2UeStatsCb *statsCb = l2UeStats[idx];
314 if (statsCb->inUse != TRUE)
318 if (pst->selector == 0)
321 TSInfPkSndL2UeStats(pst, suId, &statsCb->stats);
327 TSInfHdlL2UeStatsInd(pst, suId, &statsCb->stats);
330 rnti = statsCb->stats.rnti;
331 cmMemset((U8 *)&statsCb->stats.nonPersistent, 0x00, (Size)sizeof(statsCb->stats.nonPersistent));
332 /* cmMemset((U8 *)&statsCb->stats, 0x00, (Size)sizeof(TSInfL2UeStats)); */
333 statsCb->stats.rnti = rnti;
336 /* Allocate mBuf for CELLSTATS */
337 for (idx = 0; idx < L2_STATS_MAX_CELLS; idx++)
339 TSL2CellStatsCb *statsCellCb = l2CellStats[idx];
341 if (pst->selector == 0)
344 TSInfPkSndL2CellStats(pst, suId, l2CellStats[idx]);
350 TSInfHdlL2CellStatsInd(pst, suId, l2CellStats[idx]);
353 cellId = statsCellCb->cellId;
354 cmMemset((U8 *)l2CellStats[idx], 0x00, (Size)sizeof(TSInfL2CellStats));
355 statsCellCb->cellId = cellId;
359 #endif /* TENB_STATS */
360 /**********************************************************************
362 **********************************************************************/