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 /* Contains common utility definitions to be used at MAC */
21 #define MAX_SHORT_BSR_TABLE_ENTRIES 32
22 #define MAX_LONG_BSR_TABLE_ENTRIES 256
23 #define MAC_MEM_REGION 4
26 #ifdef ODU_MEMORY_DEBUG_LOG
27 #define MAC_MEM_LOG(_macro, _file, _line, _func, _size, _datPtr)\
29 printf("\n%s=== %s +%d, %s, %lu, %p", \
30 _macro, _file, _line, _func, (uint64_t)_size, _datPtr); \
33 #define MAC_MEM_LOG(_macro, _file, _line, _func, _size, _dataPtr){\
37 /* allocate and zero out a MAC static buffer */
38 #define MAC_ALLOC(_datPtr, _size) \
41 _ret = SGetSBuf(MAC_MEM_REGION, MAC_POOL, \
42 (Data **)&_datPtr, _size); \
45 memset(_datPtr, 0, _size); \
46 MAC_MEM_LOG("MAC_ALLOC", __FILE__, __LINE__, __FUNCTION__, _size, _datPtr);\
54 /* free a static buffer */
55 #define MAC_FREE(_datPtr, _size) \
59 MAC_MEM_LOG("MAC_FREE", __FILE__, __LINE__, __FUNCTION__, _size, _datPtr);\
60 SPutSBuf(MAC_MEM_REGION, MAC_POOL, \
61 (Data *)_datPtr, _size); \
66 /* Allocate shared memory to be used for LWLC
67 * during inter-layer communication */
68 #define MAC_ALLOC_SHRABL_BUF(_buf, _size) \
70 if(SGetStaticBuffer(MAC_MEM_REGION, MAC_POOL, \
71 (Data **)&_buf, (Size) _size, 0) == ROK) \
73 MAC_MEM_LOG("MAC_ALLOC_SHRABL_BUF", __FILE__, __LINE__, __FUNCTION__, _size, _buf);\
74 memset((_buf), 0, _size); \
82 /* Free shared memory, received through LWLC */
83 #define MAC_FREE_SHRABL_BUF(_region, _pool,_buf, _size) \
87 MAC_MEM_LOG("MAC_FREE_SHRABL_BUF", __FILE__, __LINE__, __FUNCTION__, _size, _buf);\
88 (Void) SPutStaticBuffer(_region, _pool, \
89 (Data *) _buf, (Size) _size, 0); \
94 /* Fill Pst structure for sending msg from MAC to DU APP */
95 #define FILL_PST_MAC_TO_DUAPP(_pst, _event) \
97 _pst.selector = ODU_SELECTOR_LWLC; \
98 _pst.srcEnt = ENTMAC; \
99 _pst.dstEnt = ENTDUAPP; \
101 _pst.srcInst = macCb.macInst; \
102 _pst.dstProcId = macCb.procId; \
103 _pst.srcProcId = macCb.procId; \
104 _pst.region = MAC_MEM_REGION; \
105 _pst.pool = MAC_POOL; \
106 _pst.event = _event; \
112 /* Fill Pst structure for sending msg from MAC to SCH */
113 #define FILL_PST_MAC_TO_SCH(_pst, _event) \
115 _pst.selector = ODU_SELECTOR_TC; \
116 _pst.srcEnt = ENTMAC; \
117 _pst.dstEnt = ENTMAC; \
119 _pst.srcInst = macCb.macInst; \
120 _pst.dstProcId = macCb.procId; \
121 _pst.srcProcId = macCb.procId; \
122 _pst.region = MAC_MEM_REGION; \
123 _pst.pool = MAC_POOL; \
124 _pst.event = _event; \
130 /* Fills Pst to send msg to RLC */
131 #define FILL_PST_MAC_TO_RLC(_pst, _dstInst, _event) \
133 pst.selector = ODU_SELECTOR_LWLC; \
134 pst.srcEnt = ENTMAC; \
135 pst.dstEnt = ENTRLC; \
136 pst.dstInst = _dstInst; \
137 pst.srcInst = macCb.macInst; \
138 pst.dstProcId = macCb.procId; \
139 pst.srcProcId = macCb.procId; \
140 pst.region = MAC_MEM_REGION; \
141 pst.pool = MAC_POOL; \
142 pst.event = _event; \
148 /* Function declaration */
149 uint32_t shortBsrBytesTable[MAX_SHORT_BSR_TABLE_ENTRIES];
150 uint32_t longBsrBytesTable[MAX_LONG_BSR_TABLE_ENTRIES];
152 /**********************************************************************
154 **********************************************************************/