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*/
319 /* external variable declaration */
320 /*ss014.301 osCp as volatile for SSI-4GMX*/
322 extern volatile SsOs osCp;
331 S16 SInit ARGS((void));
333 S16 SFini ARGS((void));
335 S16 SDeInit ARGS((void));
337 /* implementation-specific functions */
338 S16 ssdInitGen ARGS((void));
339 S16 ssdInitMem ARGS((void));
340 S16 ssdInitTsk ARGS((void));
341 S16 ssdInitDrvr ARGS((void));
342 S16 ssdInitTmr ARGS((void));
343 S16 ssdReInitTmr ARGS((void));
344 /* ss005.301: ssdInitFinal changed to ssdInitLog */
345 S16 ssdInitLog ARGS((void));
347 Void ssdDeinitGen ARGS((void));
348 Void ssdDeinitMem ARGS((void));
349 Void ssdDeinitTsk ARGS((void));
350 Void ssdDeinitDrvr ARGS((void));
351 Void ssdDeinitTmr ARGS((void));
352 /* ss005.301: ssdDeinitFinal changed to ssdDeinitLog */
353 Void ssdDeinitLog ARGS((void));
355 Void ssdStart ARGS((void));
357 S16 ssdAttachTTsk ARGS((SsTTskEntry *));
358 S16 ssdDetachTTsk ARGS((SsTTskEntry *));
359 S16 ssdCreateSTsk ARGS((SsSTskEntry *));
360 S16 ssdDestroySTsk ARGS((SsSTskEntry *));
361 S16 ssdPstTsk ARGS((Pst *, Buffer *, SsTTskEntry *));
362 S16 ssdRegTmr ARGS((SsTmrEntry *));
363 S16 ssdDeregTmr ARGS((SsTmrEntry *));
364 S16 ssdError ARGS((Seq, Reason));
365 Void ssdLogError ARGS((Ent, Inst, ProcId, Txt *, S32, \
366 ErrCls, ErrCode, ErrVal, Txt *));
368 Void mtTmrHdlrPublic ARGS ((void));
373 /* for TTask Dereg */
374 #ifdef SS_MULTIPLE_PROCS
375 S16 ssdProcTTskTerm ARGS((ProcId proc, SsTTskEntry *tTsk, SsIdx idx));
377 S16 ssdProcTTskTerm ARGS((SsTTskEntry *tTsk, SsIdx idx));
378 #endif /* SS_MULTIPLE_PROCS */
380 #ifdef SS_DRVR_SUPPORT
381 S16 ssdRegDrvrTsk ARGS((SsDrvrTskEntry *));
382 /*ss001.301: Additions */
383 S16 ssdDeregDrvrTsk ARGS((SsDrvrTskEntry *));
386 /* ss029.103: addition: support function to implement multiple procIds */
387 #ifdef SS_MULTIPLE_PROCS
388 uint16_t SGetProcIdIdx ARGS((ProcId proc));
389 #endif /* SS_MULTIPLE_PROCS */
391 /* multi-core support */
392 /*ss013.301 : changes for SS_AFFINITY_SUPPORT*/
393 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
395 S16 ssdSetAffinity ARGS((SSTskId *tskId, uint32_t coreId));
396 S16 ssdGetAffinity ARGS((SSTskId *tskId, uint32_t *coreId));
397 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT */
399 /* ss001.301: additions */
400 #ifdef SS_LOGGER_SUPPORT
401 S16 ssdInitLogger ARGS((void));
402 S16 SFlushBufToLog ARGS (( S8 *logBuf));
403 /* ss02.301: additions */
404 S16 SCleanUp ARGS ((Void ));
405 Void SStartLogger ARGS ((Void ));
406 Void SStopLogger ARGS ((Void ));
407 #endif /* SS_LOGGER_SUPPORT */
408 /* ss02.301: additions */
410 #ifdef SS_MULTIPLE_PROCS
411 S16 ssdWatchDgActvTmr ARGS(( ProcId proc, Ent ent, Inst instVoid));
413 S16 ssdWatchDgActvTmr ARGS(( Void ));
414 #endif /* SS_MULTIPLE_PROCS */
415 Void ssdWatchDgTmrEvt ARGS(( PTR cb, S16 event ));
416 S16 watchDgActvTsk ARGS(( Pst *pst, Buffer *mBuf));
417 S16 watchDgRcvrActvTsk ARGS(( Pst *pst, Buffer *mBuf ));
418 S16 ssdSndHrtBtMsg ARGS(( Bool restart, uint32_t type));
419 Void ssdStartWatchDgTmr ARGS(( void *cb, S16 event, uint16_t wait));
420 Void ssdStopWatchDgTmr ARGS(( void *cb, S16 event));
421 S16 ssdInitWatchDgPst ARGS((Pst *pst));
422 S16 ssdInitWatchDog ARGS((uint16_t port));
425 #ifdef SS_FBSED_TSK_REG
426 S16 SRegTskInfo ARGS((uint8_t *cfgFile));
428 /* ss002.301 Readwrite lock additions */
429 #ifdef SS_LOCK_SUPPORT
430 S16 ssdLockNew ARGS((SLockInfo *LockId, uint8_t locktype));
431 S16 ssdInitLockNew ARGS((SLockInfo *LockId, uint8_t lockType));
432 S16 ssdUnlockNew ARGS((SLockInfo *LockId, uint8_t lockType));
433 S16 ssdDestroyLockNew ARGS((SLockInfo *LockId, uint8_t lockType));
434 #endif /* SS_LOCK_SUPPORT */
436 #ifdef SSI_STATIC_MEM_LEAK_DETECTION
437 /* For Static memory leak detection */
438 #define MAX_MEM_ALLOCATIONS 100000
440 typedef struct _listInfo
445 typedef struct _eachAllocInfo
448 /* other info should come here */
454 /* end of other info */
457 typedef struct _staticMemAllocationInfo
459 uint32_t nextFreeIdx;
460 EachAllocInfo allocations[MAX_MEM_ALLOCATIONS];
463 StaticMemAllocInfo SMemLeakInfo[4];
464 FILE* StaticMemLeakFileArr[4];
465 /* End Static Memory leak detection */
472 void DumpSSIDemandQDebugInformation ARGS((void));
473 void mtSigSegvHndlr ARGS((void));
474 void mtSigUsr2Hndlr ARGS((void));
475 #endif /* __SSGENX__ */
479 /********************************************************************30**
482 **********************************************************************/