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 **********************************************************/
91 S16 cmPkLteRlcId(CmLteRlcId *param,Buffer *mBuf)
95 CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
96 CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
97 CMCHKPK(oduUnpackUInt8, param->rbType, mBuf);
98 CMCHKPK(cmPkLteRbId, param->rbId, mBuf);
104 /***********************************************************
106 * Func : cmUnpkLteRlcId
109 * Desc : RLC Identifier
118 **********************************************************/
119 S16 cmUnpkLteRlcId(CmLteRlcId *param,Buffer *mBuf)
123 CMCHKUNPK(cmUnpkLteRbId, ¶m->rbId, mBuf);
124 CMCHKUNPK(oduPackUInt8, ¶m->rbType, mBuf);
125 CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf);
126 CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf);
132 /***********************************************************
134 * Func : cmPkLteTimingInfo
137 * Desc : LTE Timing Info
146 **********************************************************/
147 S16 cmPkLteTimingInfo(CmLteTimingInfo *param,Buffer *mBuf)
151 CMCHKPK(oduUnpackUInt16, param->slot, mBuf);
152 CMCHKPK(oduUnpackUInt16, param->sfn, mBuf);
153 //CMCHKPK(oduUnpackUInt16, param->hSfn, mBuf);
159 /***********************************************************
161 * Func : cmUnpkLteTimingInfo
164 * Desc : LTE Timing Info
173 **********************************************************/
174 S16 cmUnpkLteTimingInfo(CmLteTimingInfo *param,Buffer *mBuf)
178 //CMCHKUNPK(oduPackUInt16, ¶m->hSfn, mBuf);
179 CMCHKUNPK(oduPackUInt16, ¶m->sfn, mBuf);
180 CMCHKUNPK(oduPackUInt16,¶m->slot, mBuf);
186 /***********************************************************
188 * Func : cmPkLtePdcpId
200 **********************************************************/
201 S16 cmPkLtePdcpId(CmLtePdcpId *param,Buffer *mBuf)
205 CMCHKPK(oduUnpackUInt8, param->rbType, mBuf);
206 CMCHKPK(cmPkLteRbId, param->rbId, mBuf);
207 CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
208 CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
214 /***********************************************************
216 * Func : cmUnpkLtePdcpId
228 **********************************************************/
229 S16 cmUnpkLtePdcpId(CmLtePdcpId *param,Buffer *mBuf)
233 CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf);
234 CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf);
235 CMCHKUNPK(cmUnpkLteRbId, ¶m->rbId, mBuf);
236 CMCHKUNPK(oduPackUInt8, ¶m->rbType, mBuf);
240 S16 cmUpdateSsiMemInfo(CmLteMemInfo *mInfo)
246 SsMemDbgInfo dbgInfo;
248 SGetRegPoolInfo(&numReg,&numPool);
249 mInfo->numRegions = numReg;
251 for(idxReg=0; idxReg< numReg; idxReg++)
253 SGetRegInfo(idxReg, &dbgInfo);
255 if(mInfo->regInfo[idxReg].isGenMemInfoUpdated == TRUE)
257 for(idxPool=0; idxPool<numPool; idxPool++)
259 mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed = dbgInfo.bktDbgTbl[idxPool].numAlloc;
260 if(mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed > mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed)
261 mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed = mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed;
266 mInfo->regInfo[idxReg].numPools = numPool;
267 mInfo->regInfo[idxReg].regionId = idxReg;
268 mInfo->regInfo[idxReg].regionType = 0;
270 for(idxPool=0; idxPool<numPool; idxPool++)
272 mInfo->regInfo[idxReg].poolInfo[idxPool].totAvailable = dbgInfo.bktDbgTbl[idxPool].numBlks;
273 mInfo->regInfo[idxReg].poolInfo[idxPool].poolSize = dbgInfo.bktDbgTbl[idxPool].size;
274 mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed = dbgInfo.bktDbgTbl[idxPool].numAlloc;
275 if(mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed > mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed)
276 mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed = mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed;
278 mInfo->regInfo[idxReg].isGenMemInfoUpdated = TRUE;
284 S16 cmFillMemUtilizationMeas( CmLteMemInfo *memoryInfo,CmLteMemInfo *memInfo)
290 memoryInfo->numRegions = memInfo->numRegions;
291 for(idxReg=0; idxReg < memInfo->numRegions; idxReg++)
293 memoryInfo->regInfo[idxReg].regionId = memInfo->regInfo[idxReg].regionId;
294 memoryInfo->regInfo[idxReg].numPools = memInfo->regInfo[idxReg].numPools;
295 memoryInfo->regInfo[idxReg].regionType = memInfo->regInfo[idxReg].regionType;
296 numPool = memoryInfo->regInfo[idxReg].numPools;
298 for(idxPool=0; idxPool < numPool; idxPool++)
300 memoryInfo->regInfo[idxReg].poolInfo[idxPool].totAvailable = memInfo->regInfo[idxReg].poolInfo[idxPool].totAvailable;
301 memoryInfo->regInfo[idxReg].poolInfo[idxPool].poolSize = memInfo->regInfo[idxReg].poolInfo[idxPool].poolSize;
302 memoryInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed = memInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed;
303 memoryInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed = memInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed;
309 S16 cmClearMemUtilizationCounter(CmLteMemInfo *memInfo)
314 for(idxReg=0; idxReg < memInfo->numRegions; idxReg++)
316 memInfo->regInfo[idxReg].regionId = 0;
317 memInfo->regInfo[idxReg].numPools = 0;
318 memInfo->regInfo[idxReg].regionType = 0;
319 memInfo->regInfo[idxReg].isGenMemInfoUpdated = FALSE;
320 numPool = memInfo->regInfo[idxReg].numPools;
322 for(idxPool=0; idxPool<numPool; idxPool++)
324 memInfo->regInfo[idxReg].poolInfo[idxPool].totAvailable = 0;
325 memInfo->regInfo[idxReg].poolInfo[idxPool].poolSize = 0;
326 memInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed = 0;
327 memInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed = 0;
333 S16 cmClearCpuUtilizationCounter(CmCpuStatsInfo *cpuInfo)
336 for(idx=0; idx < cpuInfo->numCores; idx++)
338 cpuInfo->cpuUtil[idx].maxCpuUtil = 0;
339 cpuInfo->cpuUtil[idx].totCpuUtil = 0;
340 cpuInfo->cpuUtil[idx].numSamples = 0;
342 cpuInfo->numCores = 0;
346 S16 cmFillCpuUtilizationMeas(CmLteCpuInfo *cpuMeasInfo,CmCpuStatsInfo *cpuInfo)
349 cpuMeasInfo->numCores = cpuInfo->numCores;
350 for(idx=0; idx < cpuInfo->numCores; idx++)
352 cpuMeasInfo->cpuUtil[idx].avgCpuUtil = cpuInfo->cpuUtil[idx].totCpuUtil/cpuInfo->cpuUtil[idx].numSamples;
353 cpuMeasInfo->cpuUtil[idx].maxCpuUtil = cpuInfo->cpuUtil[idx].maxCpuUtil;
364 Void cmUpdateTtiCounters(uint32_t ttiProcessingTime)
367 ttiProc.totTtiProcessingTime += ttiProcessingTime;
368 if(ttiProcessingTime > ttiProc.maxTtiProcessingTime)
370 ttiProc.maxTtiProcessingTime = ttiProcessingTime;
372 if(ttiProcessingTime > TTI_THRESHOLD_VALUE)
374 ttiProc.ttiThresholdExceedCount++;
376 if(ttiProcessingTime > TTI_1MS)
378 ttiProc.ttiStretchCount++;
383 Void cmResetTtiCounters(Void)
385 ttiProc.totTtiProcessingTime = 0;
386 ttiProc.numOfTti = 0;
387 ttiProc.maxTtiProcessingTime = 0;
388 ttiProc.ttiStretchCount = 0;
389 ttiProc.ttiThresholdExceedCount = 0;
390 ttiProc.phyReptTtiStretchCount = 0;
395 /**********************************************************************
397 **********************************************************************/