Adding new commiter to ODU-High repo
[o-du/l2.git] / src / cm / cm_mem.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 \f
20 /********************************************************************20**
21  
22      Name:     Common Memory Manager 
23  
24      Type:     C include file
25  
26      Desc:     Defines that are required by the Common Memory Manager.
27  
28      File:     cm_mem.h
29  
30 *********************************************************************21*/
31
32 #ifndef __CMMEMH_
33 #define __CMMEMH_
34
35 /* cm_mem_h_001.103 - Addition */
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40
41 #ifdef XEON_MULTIPLE_CELL_CHANGES
42 #define MAX_WLS_DEVICE_NAME_LEN 16
43 #define DEFAULT_WLS_DEVICE_NAME "/dev/wls"
44 #endif
45
46 #define CMM_MINBUFSIZE   (PTRALIGN(sizeof(CmHEntry)))
47 #define CMM_DATALIGN(s, msz)  (((Size)(s) % msz) ? ((Size)(s) + ((msz - (Size)(s) % msz))): (Size)(s)) 
48
49 #define CMM_BUFSIZE(s, msz)   ((Size)(s) < (Size) msz ? \
50                                       (Size) msz : \
51                                       (Size) CMM_DATALIGN(s, msz))
52
53 /* defines */
54 /* cm_mem_h_001.103 - Addition for MEMCAL */
55 #ifndef CMM_MAX_BKT_ENT
56 #define  CMM_MAX_BKT_ENT    30  
57 #endif
58 #ifndef CMM_MAX_MAP_ENT
59 /* cm_mem_h_001.main_10: Modifications*/
60 #define  CMM_MAX_MAP_ENT    512
61 #endif
62
63 /* cm_mem_h_001.main_6 - addition for SSI enhancements */
64 #if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS))
65 /* 
66 * Memory block header signature length
67 * Customer might choose to modify this to set his desired trampling signature length
68 * Customer should choose a value between 1 byte to 4 bytes 
69 */
70 #define CMM_TRAMPLING_SIGNATURE_LEN   4
71
72 /* 
73 * Maximum number of trampling allowed
74 * Customer might choose to modify this, however too big a value is not suggestible
75 */
76 #define CMM_TRAMPLING_THRESHOLD   3
77
78 /* 
79 * Hash list size to mantain the statistics of size requested & the number of attempts for allocation
80 * Customer might choose to modify this to accomodate statistics for more sizes
81 * preferably choose a prime number for better performance
82 */
83 #define CMM_STAT_HASH_TBL_LEN   211 /* prime number */
84
85 /* values for memFlags in CmMmBlkHdr */
86 #define CMM_FREE_FLAG         0x01
87 #define CMM_DYNAMIC_MEM_FLAG  0x04
88 #define CMM_STATIC_MEM_FLAG   0x08
89
90 /* 
91 * MACROs for setting/resetting above flags
92 * FREE state related flags 
93 */
94 #define CMM_SET_FREE_FLAG(x) ((x) |= CMM_FREE_FLAG)
95 #define CMM_RESET_FREE_FLAG(x) ((x) &= (~(CMM_FREE_FLAG)))
96 #define CMM_IS_FREE(x) ((x) & CMM_FREE_FLAG)
97
98 /* DYNAMIC state related flags */
99 #define CMM_SET_DYNAMIC_FLAG(x) ((x) |= CMM_DYNAMIC_MEM_FLAG)
100 #define CMM_RESET_DYNAMIC_FLAG(x) ((x) &= (~(CMM_DYNAMIC_MEM_FLAG)))
101 #define CMM_IS_DYNAMIC(x) ((x) & CMM_DYNAMIC_MEM_FLAG)
102
103 /* STATIC state related flags */
104 #define CMM_SET_STATIC_FLAG(x) ((x) |= CMM_STATIC_MEM_FLAG)
105 #define CMM_RESET_STATIC_FLAG(x) ((x) &= (~(CMM_STATIC_MEM_FLAG)))
106 #define CMM_IS_STATIC(x) ((x) & CMM_STATIC_MEM_FLAG)
107 #endif /* SSI_DEBUG_LEVEL1 */
108
109 /* Valid Physical Bit */
110 #define  CMM_REG_PHY_VALID  0x01 
111 #define  CMM_REG_OUTBOARD   0x02 
112 /* cm_mem_h_001.main_7 : Additions */ 
113 #if (defined(SS_MEM_LEAK_STS) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1))
114 #ifndef CM_MEM_USR_MDL
115 #define CM_MEM_USR_MDL 10
116 #ifndef CM_MAX_STACK_TRACE
117 #define CM_MAX_STACK_TRACE 20
118 #endif /* if CM_MAX_STACK_TRACE is not defined in Makefile */
119 #endif
120 #define MEMRAW2STR(x,y)   {#x, #y}
121 #define CM_MAX_HASH_PER_TSK 4
122 #ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2
123 #define BRDCM_MEM_LEAK_BTRACE  6 /* Back trace */
124 #endif
125 #endif /* SS_MEM_LEAK_STS */ 
126
127 #ifdef SS_HISTOGRAM_SUPPORT
128 #define CMM_HIST_MAX_FILENAME 100
129 #define CMM_HIST_MAX_MEM_ENTRY_PER_BIN 25
130 #define CMM_HIST_MAX_MEM_BIN 25
131 #endif /* SS_HISTOGRAM_SUPPORT */
132
133 #ifdef SS_LOCKLESS_MEMORY
134 #define CMM_MAX_NUMBER_BKT_NODE   2
135 #endif
136
137 #ifdef SS_LIGHT_MEM_LEAK_STS
138 #define CM_MAX_ALLOC_ENTERIES 100000
139 #endif
140 /* cm_mem_h_001.103 */
141 #ifdef __cplusplus
142 }
143 #endif
144
145 #endif /* __CMMEMH_ */
146
147 /**********************************************************************
148          End of file
149  **********************************************************************/
150