RLC UeCb Changes
[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 /* Events */
32 #define EVTCFG 0
33 #define EVTSCTPSTRT  1
34 #define EVENT_CU_DATA  2
35 #define EVENT_SCTP_NTFY  3
36 #define EVTSRVOPENREQ  4
37 #define EVTSRVOPENCFM  5
38 #define EVTTNLMGMTREQ  6
39 #define EVTTNLMGMTCFM  7
40 #define EVTSLOTIND    8
41 #define EVTSTARTPOLL  9
42 #define EVENT_RIC_DATA  10
43
44 /* allocate and zero out a static buffer */
45 #define DU_ALLOC(_datPtr, _size)                                \
46 {                                                               \
47    int _ret;                                                    \
48    _ret = SGetSBuf(DU_APP_MEM_REGION, DU_POOL,                  \
49                     (Data **)&_datPtr, _size);                  \
50    if(_ret == ROK)                                              \
51       cmMemset((U8*)_datPtr, 0, _size);                         \
52    else                                                         \
53       _datPtr = NULLP;                                          \
54 }
55
56 /* free a static buffer */
57 #define DU_FREE(_datPtr, _size)                                 \
58    if(_datPtr)                                                  \
59       SPutSBuf(DU_APP_MEM_REGION, DU_POOL,                      \
60          (Data *)_datPtr, _size);
61
62 /* Allocate shared memory to be used for LWLC
63  * during inter-layer communication */
64 #define DU_ALLOC_SHRABL_BUF(_buf, _size)                     \
65 {                                                            \
66    if(SGetStaticBuffer(DU_APP_MEM_REGION, DU_POOL,           \
67       (Data **)&_buf, (Size) _size, 0) == ROK)               \
68    {                                                         \
69       cmMemset((U8 *)(_buf), 0, _size);                      \
70    }                                                         \
71    else                                                      \
72    {                                                         \
73       (_buf) = NULLP;                                        \
74    }                                                         \
75 }
76
77 /* Free shared memory, received through LWLC */
78 #define DU_FREE_SHRABL_BUF(_region, _pool,_buf, _size)          \
79 {                                                               \
80    if (_buf != NULLP)                                           \
81    {                                                            \
82       (Void) SPutStaticBuffer(_region, _pool,                   \
83            (Data *) _buf, (Size) _size, 0);                     \
84        _buf = NULLP;                                            \
85    }                                                            \
86 }
87
88 /* Fill Pst structure for sending msg from DU APP to MAC */
89 #define FILL_PST_DUAPP_TO_MAC(_pst, _event)                 \
90 {                                                           \
91    _pst.selector  = ODU_SELECTOR_LWLC;                      \
92    _pst.srcEnt    = ENTDUAPP;                               \
93    _pst.dstEnt    = ENTRG;                                  \
94    _pst.dstInst   = 0;                                      \
95    _pst.srcInst   = 0;                                      \
96    _pst.dstProcId = DU_PROC;                                \
97    _pst.srcProcId = DU_PROC;                                \
98    _pst.region = DU_APP_MEM_REGION;                         \
99    _pst.pool = DU_POOL;                                     \
100    _pst.event = _event;                                     \
101    _pst.route = 0;                                          \
102    _pst.prior = 0;                                          \
103    _pst.intfVer = 0;                                        \
104 }
105
106 /* Fill Pst structure for sending msg from DU_APP to RLC */
107 #define FILL_PST_DUAPP_TO_RLC(_pst, _dstInst, _event)       \
108 {                                                           \
109    _pst.selector  = ODU_SELECTOR_LWLC;                      \
110    _pst.srcEnt    = ENTDUAPP;                               \
111    _pst.dstEnt    = ENTKW;                                  \
112    _pst.dstInst   = _dstInst;                               \
113    _pst.srcInst   = DU_INST;                                \
114    _pst.dstProcId = DU_PROC;                                \
115    _pst.srcProcId = DU_PROC;                                \
116    _pst.region = DU_APP_MEM_REGION;                         \
117    _pst.pool = DU_POOL;                                     \
118    _pst.event = _event;                                     \
119    _pst.route = 0;                                          \
120    _pst.prior = 0;                                          \
121    _pst.intfVer = 0;                                        \
122 }
123
124 /**********************************************************************
125          End of file
126 **********************************************************************/