MAC Clean-up [Issue-ID: ODUHIGH-212]
[o-du/l2.git] / src / du_app / du_utils.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 /* Utility definitions to be used in du app */
20
21 /* Memory related configs */
22 #define DU_APP_MEM_REGION    0
23 #define RLC_UL_MEM_REGION    1
24 #define RLC_DL_MEM_REGION    4
25 #define MAC_MEM_REGION       4
26
27 #define DU_POOL  1
28 #define RLC_POOL  1
29 #define MAC_POOL 1
30
31 /* allocate and zero out a static buffer */
32 #define DU_ALLOC(_datPtr, _size)                                \
33 {                                                               \
34    int _ret;                                                    \
35    _ret = SGetSBuf(DU_APP_MEM_REGION, DU_POOL,                  \
36                     (Data **)&_datPtr, _size);                  \
37    if(_ret == ROK)                                              \
38       cmMemset((U8*)_datPtr, 0, _size);                         \
39    else                                                         \
40       _datPtr = NULLP;                                          \
41 }
42
43 /* free a static buffer */
44 #define DU_FREE(_datPtr, _size)                                 \
45    if(_datPtr)                                                  \
46       SPutSBuf(DU_APP_MEM_REGION, DU_POOL,                      \
47          (Data *)_datPtr, _size);
48
49 /* Allocate shared memory to be used for LWLC
50  * during inter-layer communication */
51 #define DU_ALLOC_SHRABL_BUF(_buf, _size)                     \
52 {                                                            \
53    if(SGetStaticBuffer(DU_APP_MEM_REGION, DU_POOL,           \
54       (Data **)&_buf, (Size) _size, 0) == ROK)               \
55    {                                                         \
56       cmMemset((U8 *)(_buf), 0, _size);                      \
57    }                                                         \
58    else                                                      \
59    {                                                         \
60       (_buf) = NULLP;                                        \
61    }                                                         \
62 }
63
64 /* Free shared memory, received through LWLC */
65 #define DU_FREE_SHRABL_BUF(_region, _pool,_buf, _size)          \
66 {                                                               \
67    if (_buf != NULLP)                                           \
68    {                                                            \
69       (Void) SPutStaticBuffer(_region, _pool,                   \
70            (Data *) _buf, (Size) _size, 0);                     \
71        _buf = NULLP;                                            \
72    }                                                            \
73 }
74
75 /* Fill Pst structure for sending msg from DU APP to MAC */
76 #define FILL_PST_DUAPP_TO_MAC(_pst, _event)                 \
77 {                                                           \
78    _pst.selector  = ODU_SELECTOR_LWLC;                      \
79    _pst.srcEnt    = ENTDUAPP;                               \
80    _pst.dstEnt    = ENTRG;                                  \
81    _pst.dstInst   = 0;                                      \
82    _pst.srcInst   = 0;                                      \
83    _pst.dstProcId = DU_PROC;                                \
84    _pst.srcProcId = DU_PROC;                                \
85    _pst.region = DU_APP_MEM_REGION;                         \
86    _pst.pool = DU_POOL;                                     \
87    _pst.event = _event;                                     \
88    _pst.route = 0;                                          \
89    _pst.prior = 0;                                          \
90    _pst.intfVer = 0;                                        \
91 }
92
93 /**********************************************************************
94          End of file
95 **********************************************************************/