Moving all common header file into common_def.h file
[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 #define DU_PROC  0
23
24 /* Memory related configs */
25 #define DU_APP_MEM_REGION    0
26 #define RLC_UL_MEM_REGION    1
27 #define RLC_DL_MEM_REGION    4
28 #define MAC_MEM_REGION       4
29
30 #define DU_POOL  1
31 #define RLC_POOL  1
32 #define RG_POOL 1
33
34 /* Events */
35 #define EVTCFG 0
36 #define EVTSCTPSTRT  1
37 #define EVENT_CU_DATA  2
38 #define EVENT_SCTP_NTFY  3
39 #define EVTSRVOPENREQ  4
40 #define EVTSRVOPENCFM  5
41 #define EVTTNLMGMTREQ  6
42 #define EVTTNLMGMTCFM  7
43 #define EVTSLOTIND    8
44 #define EVTSTARTPOLL  9
45 #define EVENT_RIC_DATA  10
46
47
48 /* SAP IDs */
49 #define DU_MAC_SUID 0
50 #define DU_MAC_SPID 0
51
52 /* Instance */
53 #define RLC_UL_INST 0
54 #define RLC_DL_INST 1
55
56 /* SAP state */
57 #define DU_SAP_UNBOUND 1
58 #define DU_SAP_BINDING 2
59 #define DU_SAP_BOUND   3
60
61 #define DU_ZERO_VAL 0
62
63 #define DU_UE_START_CRNTI 100
64
65 /* Macros */
66 #define ADD 0
67 #define DEL 1
68
69 #define RLC_GEN_CFG      1
70 #define RLC_MAC_SAP_CFG  2
71 #define RLC_UDX_SAP_CFG  4
72
73 #define MAC_GEN_CFG   1
74 #define MAC_SAP_CFG   2
75 #define MAX_MAC_SAP   2
76
77 #define DU_RLC_UL_CONFIGURED  (RLC_GEN_CFG |  \
78       RLC_MAC_SAP_CFG | RLC_UDX_SAP_CFG)
79 #define DU_RLC_DL_CONFIGURED DU_RLC_UL_CONFIGURED
80
81 #define MAC_CONFIGURED (MAC_GEN_CFG | MAC_SAP_CFG)
82
83 #define DU_SET_ZERO(_buf, _size)   \
84    cmMemset((U8 *)(_buf), 0, _size);
85
86 /* allocate and zero out a static buffer */
87 #define DU_ALLOC(_datPtr, _size)                                \
88 {                                                               \
89    S16 _ret;                                                    \
90    _ret = SGetSBuf(DU_APP_MEM_REGION, DU_POOL,                  \
91                     (Data **)&_datPtr, _size);                  \
92    if(_ret == ROK)                                              \
93       cmMemset((U8*)_datPtr, 0, _size);                         \
94    else                                                         \
95       _datPtr = NULLP;                                          \
96 }
97
98 /* free a static buffer */
99 #define DU_FREE(_datPtr, _size)                                 \
100    if(_datPtr)                                                  \
101       SPutSBuf(DU_APP_MEM_REGION, DU_POOL,                      \
102          (Data *)_datPtr, _size);
103
104 /* Allocate shared memory to be used for LWLC 
105  * during inter-layer communication */
106 #define DU_ALLOC_SHRABL_BUF(_buf, _size)                     \
107 {                                                            \
108    if(SGetStaticBuffer(DU_APP_MEM_REGION, DU_POOL,           \
109       (Data **)&_buf, (Size) _size, 0) == ROK)               \
110    {                                                         \
111       cmMemset((U8 *)(_buf), 0, _size);                      \
112    }                                                         \
113    else                                                      \
114    {                                                         \
115       (_buf) = NULLP;                                        \
116    }                                                         \
117 }
118
119 /* Free shared memory, received through LWLC */
120 #define DU_FREE_SHRABL_BUF(_region, _pool,_buf, _size)          \
121 {                                                               \
122    if (_buf != NULLP)                                           \
123    {                                                            \
124       (Void) SPutStaticBuffer(_region, _pool,                   \
125            (Data *) _buf, (Size) _size, 0);                     \
126        _buf = NULLP;                                            \
127    }                                                            \
128 }
129
130
131 typedef enum
132 {
133    CELL_OUT_OF_SERVICE,
134    ACTIVATION_IN_PROGRESS,
135    ACTIVATED,
136    DELETION_IN_PROGRESS
137 }CellStatus;
138
139 typedef enum
140 {
141    UE_INACTIVE,
142         UE_ACTIVE
143 }UeState;
144
145 typedef struct cellCfgParams
146 {
147    NrEcgi      nrEcgi;         /* ECGI */
148    U16         nrPci;          /* PCI */
149    U16         fiveGsTac;         /* 5gSTac */
150    Plmn      plmn[MAX_PLMN]; /* List of serving PLMN IDs */
151    U32         maxUe;          /* max UE per slot */
152 }CellCfgParams;
153
154 typedef struct duUeCb
155 {
156    uint32_t gnbDuUeF1apId; /* GNB DU UE F1AP ID */
157    uint32_t gnbCuUeF1apId; /* GNB CU UE F1AP ID */
158    UeState  ueState;
159    MacUeCfg macUeCfg;
160 }DuUeCb;
161
162 typedef struct duCellCb
163 {
164    uint16_t       cellId;           /* Internal cell Id */
165    CellCfgParams  cellInfo;         /* Cell info */
166    Bool           firstSlotIndRcvd;
167    CellStatus     cellStatus;       /* Cell status */
168         uint32_t       numActvUes;       /* Total Active UEs */
169    DuUeCb         ueCb[DU_MAX_UE];  /* UE CONTEXT */
170 }DuCellCb;
171
172 typedef struct duLSapCb
173 {
174    Pst pst;
175    SuId        suId;
176    SpId        spId;
177    State       sapState;
178    Mem         mem;
179    CmTimer     timer;
180    U8          bndRetryCnt;
181    U8          maxBndRetry;
182    TmrCfg      bndTmr;
183 }DuLSapCb;
184
185 typedef struct ueCcchCtxt
186 {
187    uint32_t gnbDuUeF1apId; /* GNB DU UE F1AP ID */
188    uint16_t crnti;         /* CRNTI */
189    uint16_t cellId;        /* Cell Id */
190 }UeCcchCtxt;
191
192
193 /* DU APP DB */
194 typedef struct duCb
195 {
196    Mem           mem;    /* Memory configs */
197    TskInit       init;   /* DU Init */
198    //DuLSapCb      **macSap;  /* MAC SAP */
199    Bool          f1Status; /* Status of F1 connection */
200    Bool          e2Status; /* Status of E2 connection */
201    DuCellCb*     cfgCellLst[DU_MAX_CELLS];     /* List of cells at DU APP of type DuCellCb */
202    DuCellCb*     actvCellLst[DU_MAX_CELLS];    /* List of cells activated/to be activated of type DuCellCb */
203    /* pointer to store the address of macCellCfg params used to send du-app to MAC */
204    MacCellCfg    *duMacCellCfg;         /* pointer to store params while sending DU-APP to MAC */
205    uint32_t       numUe;            /* current number of UEs */
206    UeCcchCtxt     ueCcchCtxt[DU_MAX_UE]; /* mapping of gnbDuUeF1apId to CRNTI required for CCCH processing*/
207 }DuCb;
208
209
210 typedef struct duLSapCfg
211 {
212    SuId        suId;
213    SpId        spId;
214    Ent         srcEnt;
215    Inst        srcInst;
216    ProcId      dstProcId;
217    Ent         dstEnt;
218    Inst        dstInst;
219    Priority    dstPrior;
220    Route       dstRoute;
221    Selector    dstSel;
222    Mem         mem;
223    U8          maxBndRetry;
224    TmrCfg      bndTmr;
225    TmrCfg      connTmr;
226 }DuLSapCfg;
227
228 /* global variables */
229 DuCb duCb;
230 //DuCfgParams duCfgParam;
231
232 /* DU Cell Functions */
233 S16 duActvInit(Ent entity, Inst inst, Region region, Reason reason);
234 S16 duActvTsk(Pst *pst, Buffer *mBuf);
235 S16 duSendRlcUlCfg();
236 S16 duSendRlcDlCfg();
237 S16 duBuildRlcCfg(Inst inst);
238 S16 duBuildRlcLsapCfg(Ent ent, Inst inst, U8 lsapInst);
239 S16 duBuildRlcUsapCfg(U8 elemId, Ent ent, Inst inst);
240 S16 duHdlRlcCfgComplete(Pst *pst, KwMngmt *cfm);
241 S16 duHdlRlcCntrlCfgComplete(Pst *pst, KwMngmt *cfm);
242 S16 duProcRlcUlCfgComplete(Pst *pst, KwMngmt *cfm);
243 S16 duProcRlcDlCfgComplete(Pst *pst, KwMngmt *cfm);
244 S16 duSendMacCfg();
245 S16 duBuildMacGenCfg();
246 S16 duBuildMacUsapCfg(SpId sapId);
247 S16 duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm);
248 S16 duBindUnbindRlcToMacSap(U8 inst, U8 action);
249 S16 duProcCfgComplete();
250 S16 duSendSchCfg();
251 S16 duSctpStartReq();
252 S16 duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy);
253
254 S16 duBuildEgtpCfgReq();
255 S16 duHdlEgtpCfgComplete(CmStatus cfm);
256 S16 duSendEgtpSrvOpenReq();
257 S16 duHdlEgtpSrvOpenComplete(CmStatus cfm);
258 S16 duSendEgtpTnlMgmtReq(U8 action, U32 lclTeid, U32 remTeid);
259 S16 duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm);
260 S16 duSendEgtpTestData();
261 S16 duSendEgtpDatInd(Buffer *mBuf);
262 S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm);
263 uint16_t duBuildAndSendMacCellStartReq();
264 uint16_t duBuildAndSendMacCellStopReq();
265
266 #endif
267
268 /**********************************************************************
269          End of file
270 **********************************************************************/