remove/replaced PRIVATE and EXTERN keywords
[o-du/l2.git] / src / mt / mt_ss.h
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
19 /********************************************************************20**
20
21      Name:     MTSS -- implementation specific definitions
22
23      Type:     C include file
24
25      Desc:     Various macro definitions demanded by systems services.
26                The contents of these are for the MTSS implementation.
27
28      File:     mt_ss.h
29
30 *********************************************************************21*/
31
32
33 #ifndef __MTSSH__
34 #define __MTSSH__
35
36
37 /* --- interface to SS --- */
38
39 /* general */
40 #define SS_PROC_ID                      PID_STK(1)
41
42 /* task related */
43 /* mt028.201: addition: multiple procs support related changes */
44 #ifdef SS_MULTIPLE_PROCS
45 #define SS_MAX_PROCS                    100 /* max entries for proc list */
46 #endif /* SS_MULTIPLE_PROCS */
47
48 #define SS_MAX_ENT                      255
49 #define SS_MAX_INST                     8
50
51 /* mt028.201: modification: multiple procs support related changes */
52 #ifndef SS_MULTIPLE_PROCS
53 #define SS_MAX_TTSKS                    100
54
55 #ifndef SS_MULTICORE_SUPPORT
56 #define SS_MAX_STSKS                    7
57 #else
58 /* mt001.301 : Additions */
59 #ifdef  SPLIT_RLC_DL_TASK
60 #ifdef L2_L3_SPLIT
61 #define SS_MAX_STSKS                    4 
62 #else
63 #define SS_MAX_STSKS                    5 
64 #endif
65 #else 
66 #define SS_MAX_STSKS                    5 
67 #endif 
68 #endif /* SS_MULTICORE_SUPPORT */
69
70 #else /* SS_MULTIPLE_PROCS */
71 #define SS_MAX_TTSKS                    1000 
72 #define SS_MAX_STSKS                    7
73 #endif /* SS_MULTIPLE_PROCS */
74
75 #ifdef SS_DRVR_SUPPORT
76 #define SS_MAX_DRVRTSKS                 70
77 #endif
78
79 #ifdef SS_RTR_SUPPORT
80    /* mt0012.21 : Addition */
81 #define SS_MAX_RTRTSKS                  255
82 #endif
83
84
85 /* timer related */
86 #define SS_MAX_TMRS                     45
87
88 /* memory related */
89 /* mt022.201 - Modification for shared memory relay and memcal regions */
90 #ifdef SS_MULTICORE_SUPPORT
91 #define SS_MAX_REGS SS_MAX_STSKS
92 #else
93 #define SS_MAX_REGS 5
94 #endif
95
96 #ifdef CMM_MAX_BKT_ENT
97 #define SS_MAX_POOLS_PER_REG            CMM_MAX_BKT_ENT
98 #else
99 #define SS_MAX_POOLS_PER_REG            5
100 #endif
101 /* mt001.301 : Additions */
102 #ifdef SS_WATCHDOG
103 #define ENTDW                           0xcd
104 #define ENTHB                           0xce
105 #define INST0                           0x00
106 #define SS_TMR_HRTBT                    0x00
107 #define EVTSSHRTBTREQ                   0x00
108 #define EVTSSHRTBTRSP                   0x01
109 #define SS_LOOSE_COUPLING               0x00
110 #endif /* SS_WATCHDOG */
111
112 /* locks */
113 #define SS_STSKTBL_LOCK                 SS_LOCK_MUTEX
114 #define SS_STSKENTRY_LOCK               SS_LOCK_MUTEX
115 #define SS_TMRTBL_LOCK                  SS_LOCK_MUTEX
116 #define SS_DMNDQ_LOCK                   SS_LOCK_MUTEX
117 #define SS_DRVRENTRY_LOCK               SS_LOCK_MUTEX
118 #define SS_RTRENTRY_LOCK                SS_LOCK_MUTEX
119
120 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
121 #define MIPS_FILE "/sys/devices/virtual/mmonitor/mmonitor/mips_stat"
122 #define GET_CPU_MAX(x, y) ((x) >= (y) ? (x) : (y))
123 #define MIPS_STRING_LEN    24
124 #endif
125
126
127 /* types needed by common SSI code */
128 #define SsSemaId                        sem_t
129 #define SLockId                         pthread_mutex_t
130
131
132 /* calls needed by common SSI code */
133 #ifndef TENB_RTLIN_CHANGES
134 #define SInitLock(l, t)                 pthread_mutex_init(l, NULL)
135 #endif
136 /*uint32_t gt[128]; */
137 /*#define SLock(l)                        (((gt[0x000000FF
138  * &((uint32_t)pthread_self())]=MacGetTick())&&pthread_mutex_lock(l)&&MLogTask(30340, RESOURCE_LINL2, gt[0x000000FF
139  * &((uint32_t)pthread_self())], MacGetTick()))?0:0)*/
140 #define SLock(l)                        pthread_mutex_lock(l)
141 #define SUnlock(l)                      pthread_mutex_unlock(l)
142 #define SDestroyLock(l)                 pthread_mutex_destroy(l)
143
144 #define ssInitSema(s, c)                sem_init(s, 0, c)
145 #define ssWaitSema(s)                   sem_wait(s)
146 #define ssPostSema(s)                   sem_post(s)
147 #define ssDestroySema(s)                sem_destroy(s)
148
149 #define SS_CHECK_CUR_STSK(t)            (pthread_equal(pthread_self(), \
150                                           (t)->dep.tId))
151  /* mt013.21: Addition */
152 #define SInitSemaphore(s, c)            sem_init(s, 0, c)
153 #define SWaitSemaphore(s)               sem_wait(s)
154 #define SPostSemaphore(s)               sem_post(s)
155 #define SDestroySemaphore(s)            sem_destroy(s)
156
157 #define ssdPstTsk(p, m, t)
158
159 /* added SExit() for exiting process : mt017.21 */
160 /* mt001.301 : Additions */
161 #ifndef SS_LOGGER_SUPPORT
162 #define SExit()                         exit(0)
163 #else
164 #define SExit()  \
165 { \
166 SCleanUp(); \
167 exit(0); \
168 }
169 #endif /* SS_LOGGER_SUPPORT  */
170
171   /* mt007.21 addition */
172 /* calls needed by Message Functions */
173 #define SMemCpy(d,s,c)  memcpy(d,s,c)
174 #define SMemSet(s,c,n)  memset(s,c,n)
175 /* --- internal to MTSS-Solaris --- */
176
177
178 /*mt041.201 Value of MT_TICK_CNT changed*/
179 /*mt004.301- defining the MT_TICK_CNT in Micro seconds (usecs) */
180 /* mt010.301  Removed #ifdef SS_FAP portion and enabled oroginal code */
181 #define MT_TICK_CNT             (((uint32_t)0x0F4240)/SS_TICKS_SEC)
182
183 #define MT_MAX_TICK_CNT_VAL     35
184 #define MT_MIN_TICK_CNT_VAL     1
185
186
187 /* interrupt service flags */
188 #define MT_IS_SET               0
189 #define MT_IS_UNSET             1
190 #define MT_IS_RESET             2
191
192 /******************************************************************
193  mt018.201 - Memory Configuration.
194
195 Memory block sizes and counts for memory manager configuration
196 There is no restriction in the size of each block for the bucket.
197 However, it is recommended that the bucket size should be word aligned.
198 The CMM (Common Memory Manager) also create a look up table which map
199 the size to the bucket index.
200 The number of entry in the lookup table  (CMM_MAX_MAP_ENT, defined in
201 cm_mem.h) = ((maximum bucket size)/(bucket quantum size)) + 1.
202 The CMM_MAX_MAP_ENT should be changed depending on the bucket sizes
203 that are configured below.
204 *******************************************************************/
205
206 /* Bucket 0 configuration */
207 /* mt032.201 changed  MT_BKT_0_DSIZE from 120 to 128 for 64k compilation */
208 #define MT_BKT_0_DSIZE          256
209 /*mt004.301-changed for FAP*/
210 #ifndef SS_FAP
211 #ifdef XEON_SPECIFIC_CHANGES
212 #define MT_BKT_0_NUMBLKS        5248 /* 10500 Modified from 3500 to 10500 */
213 #else
214 #define MT_BKT_0_NUMBLKS        10000 /* 10500 Modified from 3500 to 10500 */
215 #endif
216 #else
217 #define MT_BKT_0_NUMBLKS        10000
218 #endif
219
220 /* Bucket 1 configuration */
221 /*mt004.301-changed for FAP*/
222 #ifndef SS_FAP
223 #ifdef XEON_SPECIFIC_CHANGES
224 #define MT_BKT_1_DSIZE          1024  /* Modified from 256 to 4096 */
225 #else
226 #define MT_BKT_1_DSIZE          1280  /* Modified from 256 to 4096 */
227 #endif
228 #define MT_BKT_1_NUMBLKS        10496 /* 1000*/
229 #else
230 /*mt010.301*/
231 #define MT_BKT_1_DSIZE          256
232 #define MT_BKT_1_NUMBLKS        2000
233 #endif
234
235 /* Bucket 2 configuration */
236 /*mt010.301*/
237 #ifdef SS_FAP
238 #define MT_BKT_2_DSIZE      1376      /* Fill in this value as required */
239 #define MT_BKT_2_NUMBLKS    4000        /* Fill in this value as required */
240 #else
241 #ifdef XEON_SPECIFIC_CHANGES
242 #define MT_BKT_2_DSIZE   1768 /* 1664 2048 */
243 #define MT_BKT_2_NUMBLKS 5248 /* 10496 */
244 #else
245 #define MT_BKT_2_DSIZE   2048 /* 1664 2048 */
246 #define MT_BKT_2_NUMBLKS 2000 /* 10496 */
247 #endif
248 #endif
249
250
251 /* Bucket 3 configuration */
252 /*mt010.301*/
253 #ifdef SS_FAP
254 #define MT_BKT_3_DSIZE     2592      /* Fill in this value as required */
255 #define MT_BKT_3_NUMBLKS   1500     /* Fill in this value as required */
256 #else
257 #ifdef XEON_SPECIFIC_CHANGES
258 #define MT_BKT_3_DSIZE     4224      /* Fill in this value as required */
259 #define MT_BKT_3_NUMBLKS   5248 /*10496 */       /* Fill in this value as required */
260 #else
261 #define MT_BKT_3_DSIZE     12000      /* Fill in this value as required */
262 #define MT_BKT_3_NUMBLKS   1000 /*10496 */       /* Fill in this value as required */
263 #endif
264 #endif
265
266 /* For Non-Sharable regions/static regions */
267 #ifdef XEON_SPECIFIC_CHANGES
268 #define MT_BKT_0_STATIC_NUMBLKS   500000     /* Fill in this value as required */
269 #define MT_BKT_1_STATIC_NUMBLKS   500000     /* Fill in this value as required */
270 #define MT_BKT_2_STATIC_NUMBLKS   200000     /* Fill in this value as required */
271 #define MT_BKT_3_STATIC_NUMBLKS   40960     /* Fill in this value as required */
272 #define MT_BKT_4_STATIC_NUMBLKS   4096     /* Fill in this value as required */
273 #else
274 #define MT_BKT_0_STATIC_NUMBLKS   75000     /* Fill in this value as required */
275 #define MT_BKT_1_STATIC_NUMBLKS   15000     /* Fill in this value as required */
276 #define MT_BKT_2_STATIC_NUMBLKS   500     /* Fill in this value as required */
277 #define MT_BKT_3_STATIC_NUMBLKS   1600     /* Fill in this value as required */
278 #endif
279 /*mt010.301*/
280 #ifdef RGL_SPECIFIC_CHANGES
281 #define MT_MAX_BKTS             5
282 #else
283 #define MT_MAX_BKTS             4
284 #endif
285
286 /* mt029.201 corrected typos */
287 /* memory pool data size definitions for pool-to-size mapping table */
288 #define MT_POOL_3_DSIZE        (MT_BKT_3_DSIZE-(sizeof(SsMblk)+sizeof(SsDblk)))
289 #define MT_POOL_2_DSIZE        (MT_BKT_2_DSIZE-(sizeof(SsMblk)+sizeof(SsDblk)))
290 #define MT_POOL_1_DSIZE        (MT_BKT_1_DSIZE-(sizeof(SsMblk)+sizeof(SsDblk)))
291 #define MT_POOL_0_DSIZE        (MT_BKT_0_DSIZE-(sizeof(SsMblk)+sizeof(SsDblk)))
292
293
294
295 /* mt026.201 - Modification to increase default heap size */
296 /* memory size used for heap by the memory manager (2MB) */
297 /* mt001.301 : Additions */
298 /*mt004.301- changed heap size for FAP */
299 #ifdef SS_FAP
300 #define MT_HEAP_SIZE            5242880U
301 #else
302 #ifdef XEON_SPECIFIC_CHANGES
303 #define MT_HEAP_SIZE            6194304U
304 #else
305 #define MT_HEAP_SIZE            1004800U /*PAL FIX: 4MB to 6MB flexran */
306 #endif
307 #endif
308
309 #ifndef USE_MEMCAL
310 #define STATIC_MEM_CFG
311 #endif
312
313 /* mt022.201 - definition of MT_BKTQNSIZE */
314 /*mt010.301*/
315 #define MT_BKTQNSIZE 128
316
317
318 /* mt021.201 - Addition for setting stack size for threads */
319 /* Configuration for stack size (in bytes) of spawned threads
320  * Size of zero gives default of 1 MB or 2 MB for 32 bit or 64 bit
321  * compilers, respectively */
322 #define MT_TASK_STACK           NULLD   /* stack size for task handler */
323 #define MT_ISTASK_STACK         NULLD   /* stack size for IS task handler */
324 #define MT_TMRTASK_STACK        NULLD   /* stack size for timer handler */
325 #define MT_CONSOLE_STACK        NULLD   /* stack size for console handler */
326
327 /* mt001.301 : Additions Logger support */
328 #ifdef SS_LOGGER_SUPPORT
329 #ifndef SS_MAX_LOGBUF_SIZE
330 #define SS_MAX_LOGBUF_SIZE 8192
331 #endif
332 #ifndef SS_MAX_PATH
333 #define SS_MAX_PATH 1024
334 #endif
335 #endif /* SS_LOGGER_SUPPORT */
336 /* mt005.301: Cavium changes: */
337 #ifdef SS_SEUM_CAVIUM
338 /* Cavium related hashdefines */
339 #define SS_CVMX_GRP_MASK   (1 << osCp.procId)
340
341 #define SS_CVMX_NUM_PKT_BUFFERS   0
342 #define SS_CVMX_NUM_WQE_BUFFERS   100
343 #define SS_CVMX_NUM_PKO_BUFFERS   0
344 #define SS_CVMX_NUM_TIM_BUFFERS   1000
345 #define SS_CVMX_NUM_DFA_BUFFERS   0
346
347 /* fpa pool 0 configuration */
348 #define SS_CVMX_POOL_0_NUMBLKS        3000
349
350 /* fpa pool 1 configuration */
351 #define SS_CVMX_POOL_1_NUMBLKS        100
352
353 /* fpa pool 2 configuration */
354 #define SS_CVMX_POOL_2_NUMBLKS        10        /* Fill in this value as required */
355
356 /* fpa pool 3 configuration */
357 #define SS_CVMX_POOL_3_NUMBLKS        2500      /* Fill in this value as required */
358
359 #define SS_CVMX_TICK_TIME   1000  /* the value is in micorsec */
360 #define SS_CVMX_MAX_TICKS   1000
361 #define SS_CVMX_TICKS       500
362
363 #define SS_CVMX_TMR_TAG     1000
364 #define SS_CVMX_MBUF_TAG    1001
365 #endif /* SS_SEUM_CAVIUM */
366
367 /* mt011.301: Pool definition for both 64 bit and 32 bit Cavium */
368 #ifndef SS_CVMX_WQE_POOL
369 #ifdef BIT_64
370 #define SS_CVMX_WQE_POOL CVMX_FPA_WQE_POOL
371 #else
372 #define SS_CVMX_WQE_POOL SS_CVMX_POOL_0
373 #endif
374 #endif
375
376
377 #endif  /*  __MTSSH__  */
378
379
380 \f
381 /********************************************************************30**
382
383          End of file
384 **********************************************************************/