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 /********************************************************************20**
21 Name: System Services -- general
25 Desc: Data structure definitions that are used by all
26 implementations of system services.
30 *********************************************************************21*/
41 /* ss029.103: addition: multiple procIds related changes */
42 #ifdef SS_MULTIPLE_PROCS
45 ProcId procId[SS_MAX_PROCS];
47 #endif /* SS_MULTIPLE_PROCS */
49 /* multi-core enhancements */
50 /*ss013.301 : changes for SS_AFFINITY_SUPPORT*/
51 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
54 SCpuInfo cpuInfo; /* the info about the cores/threads per core */
57 /* the currently used core */
60 /*COMMENT: add the thread id for use on hyperthreading machines */
62 uint32_t thrs; /* available no. of threads per core */
63 S8 exclusive; /* exclusive flag */
64 SSTskId tskPerCoreLst[SS_MAX_THREADS_PER_CORE]; /* System tasks running on this core */
65 } coreInfo[SS_MAX_CORES];
67 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT */
69 /* ss001.301: additions */
70 /* ss002.301: Modifications */
71 #ifdef SS_THREAD_PROFILE
72 #ifdef SS_MULTIPLE_PROCS
73 S16 SGetThrdProf(SSTskId *sTskId,ProcId procId,Ent ent,Inst inst,Event *curEvent,uint32_t *curEvtTime,uint64_t *totTime);
75 S16 SGetThrdProf(SSTskId *sTskId,Ent ent,Inst inst,Event *curEvent,uint32_t *curEvtTime,uint64_t *totTime);
76 #endif /* SS_MULTIPLE_PROCS */
77 #endif /* SS_THERAD_PROFILE */
81 typedef void (*WdUserCallback)(void *);
84 #ifdef SS_WATCHDOG_IPV6
87 struct in_addr addr; /* configured node addr */
88 #endif /* SS_WATCHDOG_IPV6 */
89 uint16_t port; /* configured watchdog port */
90 uint8_t status; /* HB ACK status */
94 uint32_t timeout; /* configured HB timer */
95 uint8_t watchdogStop; /* watchdog stop flag */
96 int numNodes; /* configured nodes */
98 unsigned int sock; /* HB socket descriptor */
103 watchDogStatus wdsta[SS_MAX_WD_NODES]; /* node config or status */
104 WdUserCallback callback; /* user callback */
105 void *data; /* user callback data */
108 typedef struct ssWdCp{
109 SSTskId watchDgTskId;
110 SSTskId watchDgRcvrTskId;
112 CmTqCp watchDgTqCp; /* timing queue control point : WatchDog */
113 CmTqType watchDgTs[2]; /*timing queue */
114 CmTimer watchDgTmr[2];
115 ProcId watchDgprocId;
119 S16 SInitWatchdog(uint16_t port);
120 S16 SRegCfgWd(uint32_t numNodes, uint8_t *addr[], uint16_t port[], uint32_t timeout, WdUserCallback callback, void *data);
121 S16 SDeregCfgWd(void);
122 S16 SStartHrtBt(uint8_t timeInterval);
123 S16 SStopHrtBt(void);
124 #endif /* SS_WATCHDOG */
126 #ifdef SS_LOGGER_SUPPORT
128 typedef struct sloggerInfo
130 Bool started; /* flag to indicate logger status */
132 Bool configured; /* flag to indicate whether logger is configured */
134 Bool opt; /* write to file/socket based on the flags provided*/
137 S8 filePath[SS_MAX_PATH];
140 struct sockaddr_in remoteAddr;
142 uint16_t curNumFlush;
143 uint16_t maxNumFlush;
145 S8 buffer[SS_MAX_LOGBUF_SIZE];
146 uint32_t maxBufSiz; /*The size of this is determined by the
147 system on which its running.*/
149 SLockId bufLock; /* lock for global buffer access */
151 #endif /* SS_LOGGER_SUPPORT */
153 #if defined (INTEL_WLS) || defined (SS_USE_WLS_MEM)
154 typedef struct _MtWls
159 #endif /* INTEL_WLS */
163 typedef struct _MtNtl
171 /* SS control point */
175 SsdOs dep; /* implementation specific */
177 /* ss029.103: modification:
178 with multiple procId support, SSI shall keep list of registered procIds */
179 #ifndef SS_MULTIPLE_PROCS
180 ProcId procId; /* processor ID */
183 SsIdx tTskIds[SS_MAX_ENT][SS_MAX_INST];
185 ProcIdLst procLst; /* processor ID list */
186 SsIdx tTskIds[SS_MAX_PROCS][SS_MAX_ENT][SS_MAX_INST];
188 #endif /* SS_MULTIPLE_PROCS */
190 SsTTskEntry tTskTbl[SS_MAX_TTSKS]; /* task table */
191 SsCntr numTTsks; /* count of tasks */
192 SsIdx nxtTTskEntry; /* next available slot */
194 SsSemaId tTskTblSem; /* lock for table access */
197 /* system task info */
198 SsSTskEntry sTskTbl[SS_MAX_STSKS]; /* task table */
200 /* Thread to region mapping. The array is indexed with reminder
201 of thread ID after deviding it with SS_MAX_THREAD_REGION_MAP
203 #ifdef SS_THR_REG_MAP
204 Region threadMemoryRegionMap[SS_MAX_THREAD_REGION_MAP];
206 SsCntr numSTsks; /* count of tasks */
207 SsIdx nxtSTskEntry; /* next available slot */
209 SLockId sTskTblLock; /* lock for table access */
212 uint8_t dmndQLookupTbl[256]; /* demand queue lookup table */
215 #ifdef SS_DRVR_SUPPORT
217 /* driver task info */
218 SsDrvrTskEntry drvrTskTbl[SS_MAX_DRVRTSKS];
220 SsCntr numDrvrTsks; /* count of tasks */
222 #endif /* SS_DRVR_SUPPORT */
225 #ifdef SS_RTR_SUPPORT
227 /* router task info */
228 ActvTsk rtrTskTbl[SS_MAX_RTRTSKS];
229 SLockId rtrTskLocks[SS_MAX_RTRTSKS];
231 #endif /* SS_RTR_SUPPORT */
235 SsTmrEntry tmrTbl[SS_MAX_TMRS]; /* timer table */
236 SsCntr numTmrs; /* count of timers */
237 SsIdx nxtTmrEntry; /* next available slot */
239 SLockId tmrTblLock; /* lock for table access */
241 /* Pointer to global region */
242 struct cmMmGlobRegCb *globRegCb; /* Global Region Cb */
244 SsCntr numRegions; /* count of regions */
245 SsRegionEntry regionTbl[SS_MAX_REGS]; /* region table */
246 SsCntr numDynRegions; /* Number of dynamic regions */
247 SsRegionEntry dynRegionTbl[SS_MAX_REGS]; /* Dynamic Region Table */
249 SsSemaId regionTblSem; /* lock for table access */
251 /* ss028.103 - Addition of lock for mBuf reference count */
252 /* ss007.301 - moved the lock to RegionTbl */
253 /* SLockId mBufRefLock; */ /* lock for mBuf ref access */
255 /*ss013.301 : changes for SS_AFFINITY_SUPPORT*/
256 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
257 /* the Information about the CPU */
258 SMultiCoreInfo mCInfo;
260 SLockId mCILock; /* Lock for mCInfo access */
262 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT */
264 /* ss001.301: additions */
267 #endif /* SS_WATCHDOG */
269 #ifdef SS_HISTOGRAM_SUPPORT
270 uint8_t entId[26][26];
271 #endif /* SS_HISTOGRAM_SUPPORT */
273 #ifdef SS_LOGGER_SUPPORT
275 #endif /* SS_LOGGER_SUPPORT */
277 #if defined (INTEL_WLS) || defined (SS_USE_WLS_MEM)
289 /* configuration data structures */
291 /* pool configuration */
292 typedef struct ssPoolCfg
294 SsPoolType type; /* dynamic or static */
295 Size size; /* size to use (for dynamic pools) */
300 /* region content--pools in a region */
301 typedef struct ssRegCfg
303 Region region; /* region ID */
304 SsCntr numPools; /* count of pools */
305 SsPoolCfg pools[SS_MAX_POOLS_PER_REG]; /* pools configuration */
311 /* external variable declaration */
312 /*ss014.301 osCp as volatile for SSI-4GMX*/
321 S16 SInit ARGS((void));
323 S16 SFini ARGS((void));
325 S16 SDeInit ARGS((void));
327 /* implementation-specific functions */
328 S16 ssdInitGen ARGS((void));
329 S16 ssdInitMem ARGS((void));
330 S16 ssdInitTsk ARGS((void));
331 S16 ssdInitDrvr ARGS((void));
332 S16 ssdInitTmr ARGS((void));
333 S16 ssdReInitTmr ARGS((void));
334 /* ss005.301: ssdInitFinal changed to ssdInitLog */
335 S16 ssdInitLog ARGS((void));
337 Void ssdDeinitGen ARGS((void));
338 Void ssdDeinitMem ARGS((void));
339 Void ssdDeinitTsk ARGS((void));
340 Void ssdDeinitDrvr ARGS((void));
341 Void ssdDeinitTmr ARGS((void));
342 /* ss005.301: ssdDeinitFinal changed to ssdDeinitLog */
343 Void ssdDeinitLog ARGS((void));
345 Void ssdStart ARGS((void));
347 S16 ssdAttachTTsk ARGS((SsTTskEntry *));
348 S16 ssdDetachTTsk ARGS((SsTTskEntry *));
349 S16 ssdCreateSTsk ARGS((SsSTskEntry *));
350 S16 ssdDestroySTsk ARGS((SsSTskEntry *));
351 S16 ssdPstTsk ARGS((Pst *, Buffer *, SsTTskEntry *));
352 S16 ssdRegTmr ARGS((SsTmrEntry *));
353 S16 ssdDeregTmr ARGS((SsTmrEntry *));
354 S16 ssdError ARGS((Seq, Reason));
355 Void ssdLogError ARGS((Ent, Inst, ProcId, Txt *, S32, \
356 ErrCls, ErrCode, ErrVal, Txt *));
358 Void mtTmrHdlrPublic ARGS ((void));
363 /* for TTask Dereg */
364 #ifdef SS_MULTIPLE_PROCS
365 S16 ssdProcTTskTerm ARGS((ProcId proc, SsTTskEntry *tTsk, SsIdx idx));
367 S16 ssdProcTTskTerm ARGS((SsTTskEntry *tTsk, SsIdx idx));
368 #endif /* SS_MULTIPLE_PROCS */
370 #ifdef SS_DRVR_SUPPORT
371 S16 ssdRegDrvrTsk ARGS((SsDrvrTskEntry *));
372 /*ss001.301: Additions */
373 S16 ssdDeregDrvrTsk ARGS((SsDrvrTskEntry *));
376 /* ss029.103: addition: support function to implement multiple procIds */
377 #ifdef SS_MULTIPLE_PROCS
378 uint16_t SGetProcIdIdx ARGS((ProcId proc));
379 #endif /* SS_MULTIPLE_PROCS */
381 /* multi-core support */
382 /*ss013.301 : changes for SS_AFFINITY_SUPPORT*/
383 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
385 S16 ssdSetAffinity ARGS((SSTskId *tskId, uint32_t coreId));
386 S16 ssdGetAffinity ARGS((SSTskId *tskId, uint32_t *coreId));
387 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT */
389 /* ss001.301: additions */
390 #ifdef SS_LOGGER_SUPPORT
391 S16 ssdInitLogger ARGS((void));
392 S16 SFlushBufToLog ARGS (( S8 *logBuf));
393 /* ss02.301: additions */
394 S16 SCleanUp ARGS ((Void ));
395 Void SStartLogger ARGS ((Void ));
396 Void SStopLogger ARGS ((Void ));
397 #endif /* SS_LOGGER_SUPPORT */
398 /* ss02.301: additions */
400 #ifdef SS_MULTIPLE_PROCS
401 S16 ssdWatchDgActvTmr ARGS(( ProcId proc, Ent ent, Inst instVoid));
403 S16 ssdWatchDgActvTmr ARGS(( Void ));
404 #endif /* SS_MULTIPLE_PROCS */
405 Void ssdWatchDgTmrEvt ARGS(( PTR cb, S16 event ));
406 S16 watchDgActvTsk ARGS(( Pst *pst, Buffer *mBuf));
407 S16 watchDgRcvrActvTsk ARGS(( Pst *pst, Buffer *mBuf ));
408 S16 ssdSndHrtBtMsg ARGS(( Bool restart, uint32_t type));
409 Void ssdStartWatchDgTmr ARGS(( void *cb, S16 event, uint16_t wait));
410 Void ssdStopWatchDgTmr ARGS(( void *cb, S16 event));
411 S16 ssdInitWatchDgPst ARGS((Pst *pst));
412 S16 ssdInitWatchDog ARGS((uint16_t port));
415 #ifdef SS_FBSED_TSK_REG
416 S16 SRegTskInfo ARGS((uint8_t *cfgFile));
418 /* ss002.301 Readwrite lock additions */
419 #ifdef SS_LOCK_SUPPORT
420 S16 ssdLockNew ARGS((SLockInfo *LockId, uint8_t locktype));
421 S16 ssdInitLockNew ARGS((SLockInfo *LockId, uint8_t lockType));
422 S16 ssdUnlockNew ARGS((SLockInfo *LockId, uint8_t lockType));
423 S16 ssdDestroyLockNew ARGS((SLockInfo *LockId, uint8_t lockType));
424 #endif /* SS_LOCK_SUPPORT */
426 #ifdef SSI_STATIC_MEM_LEAK_DETECTION
427 /* For Static memory leak detection */
428 #define MAX_MEM_ALLOCATIONS 100000
430 typedef struct _listInfo
435 typedef struct _eachAllocInfo
438 /* other info should come here */
444 /* end of other info */
447 typedef struct _staticMemAllocationInfo
449 uint32_t nextFreeIdx;
450 EachAllocInfo allocations[MAX_MEM_ALLOCATIONS];
453 StaticMemAllocInfo SMemLeakInfo[4];
454 FILE* StaticMemLeakFileArr[4];
455 /* End Static Memory leak detection */
462 void DumpSSIDemandQDebugInformation ARGS((void));
463 void mtSigSegvHndlr ARGS((void));
464 void mtSigUsr2Hndlr ARGS((void));
465 #endif /* __SSGENX__ */
469 /********************************************************************30**
472 **********************************************************************/