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 U32 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 EXTERN S16 SGetThrdProf(SSTskId *sTskId,ProcId procId,Ent ent,Inst inst,Event *curEvent,U32 *curEvtTime,U64 *totTime);
75 EXTERN S16 SGetThrdProf(SSTskId *sTskId,Ent ent,Inst inst,Event *curEvent,U32 *curEvtTime,U64 *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 U16 port; /* configured watchdog port */
90 U8 status; /* HB ACK status */
94 U32 timeout; /* configured HB timer */
95 U8 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 EXTERN S16 SInitWatchdog(U16 port);
120 EXTERN S16 SRegCfgWd(U32 numNodes, U8 *addr[], U16 port[], U32 timeout, WdUserCallback callback, void *data);
121 EXTERN S16 SDeregCfgWd(void);
122 EXTERN S16 SStartHrtBt(U8 timeInterval);
123 EXTERN 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;
145 S8 buffer[SS_MAX_LOGBUF_SIZE];
146 U32 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 */
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 U8 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
271 #endif /* SS_HISTOGRAM_SUPPORT */
273 #ifdef SS_LOGGER_SUPPORT
275 #endif /* SS_LOGGER_SUPPORT */
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 EXTERN osCp as VOLATILE for SSI-4GMX*/
314 EXTERN VOLATILE SsOs osCp;
321 EXTERN S16 SInit ARGS((void));
323 EXTERN S16 SFini ARGS((void));
325 EXTERN S16 SDeInit ARGS((void));
327 /* implementation-specific functions */
328 EXTERN S16 ssdInitGen ARGS((void));
329 EXTERN S16 ssdInitMem ARGS((void));
330 EXTERN S16 ssdInitTsk ARGS((void));
331 EXTERN S16 ssdInitDrvr ARGS((void));
332 EXTERN S16 ssdInitTmr ARGS((void));
333 EXTERN S16 ssdReInitTmr ARGS((void));
334 /* ss005.301: ssdInitFinal changed to ssdInitLog */
335 EXTERN S16 ssdInitLog ARGS((void));
337 EXTERN Void ssdDeinitGen ARGS((void));
338 EXTERN Void ssdDeinitMem ARGS((void));
339 EXTERN Void ssdDeinitTsk ARGS((void));
340 EXTERN Void ssdDeinitDrvr ARGS((void));
341 EXTERN Void ssdDeinitTmr ARGS((void));
342 /* ss005.301: ssdDeinitFinal changed to ssdDeinitLog */
343 EXTERN Void ssdDeinitLog ARGS((void));
345 EXTERN Void ssdStart ARGS((void));
347 EXTERN S16 ssdAttachTTsk ARGS((SsTTskEntry *));
348 EXTERN S16 ssdDetachTTsk ARGS((SsTTskEntry *));
349 EXTERN S16 ssdCreateSTsk ARGS((SsSTskEntry *));
350 EXTERN S16 ssdDestroySTsk ARGS((SsSTskEntry *));
351 EXTERN S16 ssdPstTsk ARGS((Pst *, Buffer *, SsTTskEntry *));
352 EXTERN S16 ssdRegTmr ARGS((SsTmrEntry *));
353 EXTERN S16 ssdDeregTmr ARGS((SsTmrEntry *));
354 EXTERN S16 ssdError ARGS((Seq, Reason));
355 EXTERN Void ssdLogError ARGS((Ent, Inst, ProcId, Txt *, S32, \
356 ErrCls, ErrCode, ErrVal, Txt *));
358 EXTERN Void mtTmrHdlrPublic ARGS ((void));
363 /* for TTask Dereg */
364 #ifdef SS_MULTIPLE_PROCS
365 EXTERN S16 ssdProcTTskTerm ARGS((ProcId proc, SsTTskEntry *tTsk, SsIdx idx));
367 EXTERN S16 ssdProcTTskTerm ARGS((SsTTskEntry *tTsk, SsIdx idx));
368 #endif /* SS_MULTIPLE_PROCS */
370 #ifdef SS_DRVR_SUPPORT
371 EXTERN S16 ssdRegDrvrTsk ARGS((SsDrvrTskEntry *));
372 /*ss001.301: Additions */
373 EXTERN S16 ssdDeregDrvrTsk ARGS((SsDrvrTskEntry *));
376 /* ss029.103: addition: support function to implement multiple procIds */
377 #ifdef SS_MULTIPLE_PROCS
378 EXTERN U16 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 EXTERN S16 ssdSetAffinity ARGS((SSTskId *tskId, U32 coreId));
386 EXTERN S16 ssdGetAffinity ARGS((SSTskId *tskId, U32 *coreId));
387 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT */
389 /* ss001.301: additions */
390 #ifdef SS_LOGGER_SUPPORT
391 EXTERN S16 ssdInitLogger ARGS((void));
392 EXTERN S16 SFlushBufToLog ARGS (( S8 *logBuf));
393 /* ss02.301: additions */
394 EXTERN S16 SCleanUp ARGS ((Void ));
395 EXTERN Void SStartLogger ARGS ((Void ));
396 EXTERN Void SStopLogger ARGS ((Void ));
397 #endif /* SS_LOGGER_SUPPORT */
398 /* ss02.301: additions */
400 #ifdef SS_MULTIPLE_PROCS
401 EXTERN S16 ssdWatchDgActvTmr ARGS(( ProcId proc, Ent ent, Inst instVoid));
403 EXTERN S16 ssdWatchDgActvTmr ARGS(( Void ));
404 #endif /* SS_MULTIPLE_PROCS */
405 EXTERN Void ssdWatchDgTmrEvt ARGS(( PTR cb, S16 event ));
406 EXTERN S16 watchDgActvTsk ARGS(( Pst *pst, Buffer *mBuf));
407 EXTERN S16 watchDgRcvrActvTsk ARGS(( Pst *pst, Buffer *mBuf ));
408 EXTERN S16 ssdSndHrtBtMsg ARGS(( Bool restart, U32 type));
409 EXTERN Void ssdStartWatchDgTmr ARGS(( void *cb, S16 event, U16 wait));
410 EXTERN Void ssdStopWatchDgTmr ARGS(( void *cb, S16 event));
411 EXTERN S16 ssdInitWatchDgPst ARGS((Pst *pst));
412 EXTERN S16 ssdInitWatchDog ARGS((U16 port));
415 #ifdef SS_FBSED_TSK_REG
416 EXTERN S16 SRegTskInfo ARGS((U8 *cfgFile));
418 /* ss002.301 Readwrite lock additions */
419 #ifdef SS_LOCK_SUPPORT
420 EXTERN S16 ssdLockNew ARGS((SLockInfo *LockId, U8 locktype));
421 EXTERN S16 ssdInitLockNew ARGS((SLockInfo *LockId, U8 lockType));
422 EXTERN S16 ssdUnlockNew ARGS((SLockInfo *LockId, U8 lockType));
423 EXTERN S16 ssdDestroyLockNew ARGS((SLockInfo *LockId, U8 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
450 EachAllocInfo allocations[MAX_MEM_ALLOCATIONS];
453 StaticMemAllocInfo SMemLeakInfo[4];
454 FILE* StaticMemLeakFileArr[4];
455 /* End Static Memory leak detection */
462 EXTERN void DumpSSIDemandQDebugInformation ARGS((void));
463 EXTERN void mtSigSegvHndlr ARGS((void));
464 EXTERN void mtSigUsr2Hndlr ARGS((void));
465 #endif /* __SSGENX__ */
469 /********************************************************************30**
472 **********************************************************************/