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