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 code for packing/unpacking of cm_lte data structures.
29 **********************************************************************/
31 /* header include files (.h) */
33 #include "envopt.h" /* environment options */
34 #include "envdep.h" /* environment dependent */
35 #include "envind.h" /* environment independent */
37 /* header/extern include files (.x) */
39 #include "gen.h" /* general layer */
40 #include "ssi.h" /* system services */
41 #include "cm_lte.h" /* common lte header file */
42 #include "cm5.h" /* common timers */
43 #include "mt_ss.h" /* MTSS specific */
44 #include "mt_err.h" /* MTSS error defines */
45 #include "ss_queue.h" /* queues */
46 #include "ss_task.h" /* tasking */
47 #include "ss_msg.h" /* messaging */
48 #include "ss_mem.h" /* memory management interface */
49 #include "ss_gen.h" /* general */
50 /* mt003.301 Additions - Task deregistration */
51 #include "ss_err.h" /* error */
54 /* header/extern include files (.x) */
56 #include "gen.x" /* general layer */
57 #include "ssi.x" /* system services */
58 #include "cm_lte.x" /* common lte header file */
59 #include "cm5.x" /* common timers */
60 #include "mt_ss.x" /* MTSS specific */
61 #include "ss_queue.x" /* queues */
62 #include "ss_task.x" /* tasking */
63 #include "ss_timer.x" /* timers */
65 #include "ss_strm.x" /* STREAMS */
66 #include "ss_msg.x" /* messaging */
67 #include "ss_mem.x" /* memory management interface */
68 #include "ss_drvr.x" /* driver tasks */
69 #include "ss_gen.x" /* general */
72 /* public variable declarations */
76 /***********************************************************
81 * Desc : RLC Identifier
90 **********************************************************/
98 S16 cmPkLteRlcId(param, mBuf)
105 CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
106 CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
107 CMCHKPK(oduUnpackUInt8, param->rbType, mBuf);
108 CMCHKPK(cmPkLteRbId, param->rbId, mBuf);
114 /***********************************************************
116 * Func : cmUnpkLteRlcId
119 * Desc : RLC Identifier
128 **********************************************************/
136 S16 cmUnpkLteRlcId(param, mBuf)
143 CMCHKUNPK(cmUnpkLteRbId, ¶m->rbId, mBuf);
144 CMCHKUNPK(oduPackUInt8, ¶m->rbType, mBuf);
145 CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf);
146 CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf);
152 /***********************************************************
154 * Func : cmPkLteTimingInfo
157 * Desc : LTE Timing Info
166 **********************************************************/
168 S16 cmPkLteTimingInfo
170 CmLteTimingInfo *param,
174 S16 cmPkLteTimingInfo(param, mBuf)
175 CmLteTimingInfo *param;
181 CMCHKPK(oduUnpackUInt16, param->slot, mBuf);
182 CMCHKPK(oduUnpackUInt16, param->sfn, mBuf);
183 //CMCHKPK(oduUnpackUInt16, param->hSfn, mBuf);
189 /***********************************************************
191 * Func : cmUnpkLteTimingInfo
194 * Desc : LTE Timing Info
203 **********************************************************/
205 S16 cmUnpkLteTimingInfo
207 CmLteTimingInfo *param,
211 S16 cmUnpkLteTimingInfo(param, mBuf)
212 CmLteTimingInfo *param;
218 //CMCHKUNPK(oduPackUInt16, ¶m->hSfn, mBuf);
219 CMCHKUNPK(oduPackUInt16, ¶m->sfn, mBuf);
220 CMCHKUNPK(oduPackUInt16,¶m->slot, mBuf);
226 /***********************************************************
228 * Func : cmPkLtePdcpId
240 **********************************************************/
248 S16 cmPkLtePdcpId(param, mBuf)
255 CMCHKPK(oduUnpackUInt8, param->rbType, mBuf);
256 CMCHKPK(cmPkLteRbId, param->rbId, mBuf);
257 CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
258 CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
264 /***********************************************************
266 * Func : cmUnpkLtePdcpId
278 **********************************************************/
286 S16 cmUnpkLtePdcpId(param, mBuf)
293 CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf);
294 CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf);
295 CMCHKUNPK(cmUnpkLteRbId, ¶m->rbId, mBuf);
296 CMCHKUNPK(oduPackUInt8, ¶m->rbType, mBuf);
301 S16 cmUpdateSsiMemInfo
306 S16 cmUpdateSsiMemInfo(mInfo)
314 SsMemDbgInfo dbgInfo;
316 SGetRegPoolInfo(&numReg,&numPool);
317 mInfo->numRegions = numReg;
319 for(idxReg=0; idxReg< numReg; idxReg++)
321 SGetRegInfo(idxReg, &dbgInfo);
323 if(mInfo->regInfo[idxReg].isGenMemInfoUpdated == TRUE)
325 for(idxPool=0; idxPool<numPool; idxPool++)
327 mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed = dbgInfo.bktDbgTbl[idxPool].numAlloc;
328 if(mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed > mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed)
329 mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed = mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed;
334 mInfo->regInfo[idxReg].numPools = numPool;
335 mInfo->regInfo[idxReg].regionId = idxReg;
336 mInfo->regInfo[idxReg].regionType = 0;
338 for(idxPool=0; idxPool<numPool; idxPool++)
340 mInfo->regInfo[idxReg].poolInfo[idxPool].totAvailable = dbgInfo.bktDbgTbl[idxPool].numBlks;
341 mInfo->regInfo[idxReg].poolInfo[idxPool].poolSize = dbgInfo.bktDbgTbl[idxPool].size;
342 mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed = dbgInfo.bktDbgTbl[idxPool].numAlloc;
343 if(mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed > mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed)
344 mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed = mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed;
346 mInfo->regInfo[idxReg].isGenMemInfoUpdated = TRUE;
353 S16 cmFillMemUtilizationMeas
355 CmLteMemInfo *memoryInfo,
356 CmLteMemInfo *memInfo
359 S16 cmFillMemUtilizationMeas(memoryInfo,memInfo)
360 CmLteMemInfo *memoryInfo;
361 CmLteMemInfo *memInfo;
368 memoryInfo->numRegions = memInfo->numRegions;
369 for(idxReg=0; idxReg < memInfo->numRegions; idxReg++)
371 memoryInfo->regInfo[idxReg].regionId = memInfo->regInfo[idxReg].regionId;
372 memoryInfo->regInfo[idxReg].numPools = memInfo->regInfo[idxReg].numPools;
373 memoryInfo->regInfo[idxReg].regionType = memInfo->regInfo[idxReg].regionType;
374 numPool = memoryInfo->regInfo[idxReg].numPools;
376 for(idxPool=0; idxPool < numPool; idxPool++)
378 memoryInfo->regInfo[idxReg].poolInfo[idxPool].totAvailable = memInfo->regInfo[idxReg].poolInfo[idxPool].totAvailable;
379 memoryInfo->regInfo[idxReg].poolInfo[idxPool].poolSize = memInfo->regInfo[idxReg].poolInfo[idxPool].poolSize;
380 memoryInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed = memInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed;
381 memoryInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed = memInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed;
388 S16 cmClearMemUtilizationCounter
390 CmLteMemInfo *memInfo
393 S16 cmClearMemUtilizationCounter(memInfo)
394 CmLteMemInfo *memInfo;
400 for(idxReg=0; idxReg < memInfo->numRegions; idxReg++)
402 memInfo->regInfo[idxReg].regionId = 0;
403 memInfo->regInfo[idxReg].numPools = 0;
404 memInfo->regInfo[idxReg].regionType = 0;
405 memInfo->regInfo[idxReg].isGenMemInfoUpdated = FALSE;
406 numPool = memInfo->regInfo[idxReg].numPools;
408 for(idxPool=0; idxPool<numPool; idxPool++)
410 memInfo->regInfo[idxReg].poolInfo[idxPool].totAvailable = 0;
411 memInfo->regInfo[idxReg].poolInfo[idxPool].poolSize = 0;
412 memInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed = 0;
413 memInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed = 0;
420 S16 cmClearCpuUtilizationCounter
422 CmCpuStatsInfo *cpuInfo
425 S16 cmClearCpuUtilizationCounter(cpuInfo)
426 CmCpuStatsInfo *cpuInfo
430 for(idx=0; idx < cpuInfo->numCores; idx++)
432 cpuInfo->cpuUtil[idx].maxCpuUtil = 0;
433 cpuInfo->cpuUtil[idx].totCpuUtil = 0;
434 cpuInfo->cpuUtil[idx].numSamples = 0;
436 cpuInfo->numCores = 0;
441 S16 cmFillCpuUtilizationMeas
443 CmLteCpuInfo *cpuMeasInfo,
444 CmCpuStatsInfo *cpuInfo
447 S16 cmFillCpuUtilizationMeas(cpuMeasInfo,cpuInfo)
448 CmLteCpuInfo *cpuMeasInfo;
449 CmCpuStatsInfo *cpuInfo;
453 cpuMeasInfo->numCores = cpuInfo->numCores;
454 for(idx=0; idx < cpuInfo->numCores; idx++)
456 cpuMeasInfo->cpuUtil[idx].avgCpuUtil = cpuInfo->cpuUtil[idx].totCpuUtil/cpuInfo->cpuUtil[idx].numSamples;
457 cpuMeasInfo->cpuUtil[idx].maxCpuUtil = cpuInfo->cpuUtil[idx].maxCpuUtil;
468 Void cmUpdateTtiCounters(U32 ttiProcessingTime)
471 ttiProc.totTtiProcessingTime += ttiProcessingTime;
472 if(ttiProcessingTime > ttiProc.maxTtiProcessingTime)
474 ttiProc.maxTtiProcessingTime = ttiProcessingTime;
476 if(ttiProcessingTime > TTI_THRESHOLD_VALUE)
478 ttiProc.ttiThresholdExceedCount++;
480 if(ttiProcessingTime > TTI_1MS)
482 ttiProc.ttiStretchCount++;
487 Void cmResetTtiCounters(Void)
489 ttiProc.totTtiProcessingTime = 0;
490 ttiProc.numOfTti = 0;
491 ttiProc.maxTtiProcessingTime = 0;
492 ttiProc.ttiStretchCount = 0;
493 ttiProc.ttiThresholdExceedCount = 0;
494 ttiProc.phyReptTtiStretchCount = 0;
499 /**********************************************************************
501 **********************************************************************/