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