Initial commit for Bronze release
[o-du/l2.git] / src / du_app / du_mgr.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 /* This file contains message handling functionality for DU cell management */
20 #ifndef __DU_MGR_H__
21 #define __DU_MGR_H__
22
23 #include "stdio.h"
24 #include "ctype.h"
25 #include "envopt.h"        /* Environment options */
26 #include "envdep.h"        /* Environment dependent */
27 #include "envind.h"        /* Environment independent */
28 #include "gen.h"           /* General */
29 #include "ssi.h"           /* System services */
30 #include "cm5.h"           /* Common timer defines */
31 #include "cm_tkns.h"       /* Common tokens defines */
32 #include "cm_mblk.h"       /* Common memory allocation library defines */
33 #include "cm_llist.h"      /* Common link list  defines  */
34 #include "cm_hash.h"       /* Common hashlist  defines */
35 #include "cm_lte.h"
36 #include "cm_inet.h"
37 #include "lkw.h"
38 #include "lrg.h"
39 #include "legtp.h"
40
41 /*#include "du_cfg_hdl.h"*/
42
43 #include "gen.x"           /* General */
44 #include "ssi.x"           /* System services */
45
46 #include "cm5.x"           /* Common timer library */
47 #include "cm_tkns.x"       /* Common tokens */
48 #include "cm_mblk.x"       /* Common memory allocation */
49 #include "cm_llist.x"      /* Common link list */
50 #include "cm_hash.x"       /* Common hashlist */
51 #include "cm_lte.x"
52 #include "cm_inet.x"
53 #include "cm_lib.x"
54 #include "lkw.x"
55 #include "lrg.x"
56
57 #define DU_PROC  0
58 /* Memory related configs */
59 #define DU_APP_MEM_REGION    0
60 #define RLC_UL_MEM_REGION     1
61 #define RLC_DL_MEM_REGION     4
62 #define RG_MEM_REGION     4
63
64 #define DU_POOL  1
65 #define RLC_POOL  1
66 #define RG_POOL 1
67
68 /* Events */
69 #define EVTCFG 0
70 #define EVTSCTPSTRT  1
71 #define EVTSCTPDATA  2
72 #define EVTSCTPNTFY  3
73 #define EVTSRVOPENREQ  4
74 #define EVTSRVOPENCFM  5
75 #define EVTTNLMGMTREQ  6
76 #define EVTTNLMGMTCFM  7
77 #define EVTTTIIND    8
78
79 /* Selector */
80 #define DU_SELECTOR_LC   0
81 #define DU_SELECTOR_TC   1
82 #define DU_SELECTOR_LWLC 2
83
84 /* SAP IDs */
85 #define DU_MAC_SUID 0
86 #define DU_MAC_SPID 0
87
88 /* Instance */
89 #define RLC_UL_INST 0
90 #define RLC_DL_INST 1
91
92 /* SAP state */
93 #define DU_SAP_UNBOUND 1
94 #define DU_SAP_BINDING 2
95 #define DU_SAP_BOUND   3
96
97 #define DU_ZERO_VAL 0
98
99 /* Macros */
100 #define DEFAULT_CELLS    1
101 #define NR_RANAC 150
102
103 #define ADD 0
104 #define DEL 1
105
106 #define RLC_GEN_CFG      1
107 #define RLC_MAC_SAP_CFG  2
108 #define RLC_UDX_SAP_CFG  4
109
110 #define MAC_GEN_CFG   1
111 #define MAC_SAP_CFG   2
112 #define MAX_MAC_SAP   2
113
114 #define DU_RLC_UL_CONFIGURED  (RLC_GEN_CFG |  \
115       RLC_MAC_SAP_CFG | RLC_UDX_SAP_CFG)
116 #define DU_RLC_DL_CONFIGURED DU_RLC_UL_CONFIGURED
117
118 #define MAC_CONFIGURED (MAC_GEN_CFG | MAC_SAP_CFG)
119
120 #define DU_SET_ZERO(_buf, _size)   \
121    cmMemset((U8 *)(_buf), 0, _size);
122
123 /* allocate and zero out a static buffer */
124 #define DU_ALLOC(_datPtr, _size)                                \
125 {                                                               \
126    S16 _ret;                                                    \
127    _ret = SGetSBuf(DU_APP_MEM_REGION, DU_POOL,                  \
128                     (Data **)&_datPtr, _size);                  \
129    if(_ret == ROK)                                              \
130       cmMemset((U8*)_datPtr, 0, _size);                         \
131    else                                                         \
132       _datPtr = NULLP;                                          \
133 }
134
135 /* free a static buffer */
136 #define DU_FREE(_datPtr, _size)                                 \
137    if(_datPtr)                                                  \
138       SPutSBuf(DU_APP_MEM_REGION, DU_POOL,                      \
139          (Data *)_datPtr, _size);
140
141 typedef enum
142 {
143    OOS,
144    ACTIVATION_IN_PROGRESS,
145    ACTIVATED,
146    DELETION_IN_PROGRESS
147 }CellStatus;
148
149 #if 0
150 typedef struct duCellCb
151 {
152    U32            cellId;      /* Internal cell Id */
153    CellCfgParams  cellInfo;    /* Cell info */
154    CellStatus     cellStatus;  /*Cell status */
155 }DuCellCb;
156 #endif
157
158 typedef struct duLSapCb
159 {
160    Pst pst;
161    SuId        suId;
162    SpId        spId;
163    State       sapState;
164    Mem         mem;
165    CmTimer     timer;
166    U8                        bndRetryCnt;
167    U8                        maxBndRetry;
168    TmrCfg                    bndTmr;
169 }DuLSapCb;
170
171 /* DU APP DB */
172 typedef struct duCb
173 {
174    Mem           mem;    /* Memory configs */
175    TskInit       init;   /* DU Init */
176    //DuLSapCb      **macSap;  /* MAC SAP */
177    Bool          f1Status; /* Status of F1 connection */
178    CmHashListCp  cellLst;     /* List of cells at DU APP of type DuCellCb */
179    CmHashListCp  actvCellLst; /* List of cells activated/to be activated of type DuCellCb */
180 }DuCb;
181
182
183 typedef struct duLSapCfg
184 {
185    SuId        suId;
186    SpId        spId;
187    Ent         srcEnt;
188    Inst        srcInst;
189    ProcId      dstProcId;
190    Ent         dstEnt;
191    Inst        dstInst;
192    Priority    dstPrior;
193    Route       dstRoute;
194    Selector    dstSel;
195    Mem         mem;
196    U8          maxBndRetry;
197    TmrCfg      bndTmr;
198    TmrCfg      connTmr;
199 }DuLSapCfg;
200
201 /* global variables */
202 DuCb duCb;
203 //DuCfgParams duCfgParam;
204
205 /* DU Cell Functions */
206 S16 duActvInit(Ent entity, Inst inst, Region region, Reason reason);
207 S16 duActvTsk(Pst *pst, Buffer *mBuf);
208 S16 duSendRlcUlCfg();
209 S16 duSendRlcDlCfg();
210 S16 duBuildRlcCfg(Inst inst);
211 S16 duBuildRlcLsapCfg(Ent ent, Inst inst, U8 lsapInst);
212 S16 duBuildRlcUsapCfg(U8 elemId, Ent ent, Inst inst);
213 S16 duHdlRlcCfgComplete(Pst *pst, KwMngmt *cfm);
214 S16 duHdlRlcCntrlCfgComplete(Pst *pst, KwMngmt *cfm);
215 S16 duProcRlcUlCfgComplete(Pst *pst, KwMngmt *cfm);
216 S16 duProcRlcDlCfgComplete(Pst *pst, KwMngmt *cfm);
217 S16 duSendMacCfg();
218 S16 duBuildMacGenCfg();
219 S16 duBuildMacUsapCfg(SpId sapId);
220 S16 duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm);
221 S16 duBindUnbindRlcToMacSap(U8 inst, U8 action);
222 S16 duProcCfgComplete();
223 S16 duSendSchCfg();
224 S16 duSctpStartReq();
225 S16 duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy);
226
227 S16 duBuildEgtpCfgReq();
228 S16 duHdlEgtpCfgComplete(CmStatus cfm);
229 S16 duSendEgtpSrvOpenReq();
230 S16 duHdlEgtpSrvOpenComplete(CmStatus cfm);
231 S16 duSendEgtpTnlMgmtReq(U8 action, U32 lclTeid, U32 remTeid);
232 S16 duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm);
233 S16 duSendEgtpDatInd();
234 S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm);
235
236 #endif
237
238 /**********************************************************************
239          End of file
240 **********************************************************************/