JIRA ID ODUHIGH193: Allocation and deallocation of MaceCellCfg sharable buffer
[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 /* Macros */
64 #define ADD 0
65 #define DEL 1
66
67 #define RLC_GEN_CFG      1
68 #define RLC_MAC_SAP_CFG  2
69 #define RLC_UDX_SAP_CFG  4
70
71 #define MAC_GEN_CFG   1
72 #define MAC_SAP_CFG   2
73 #define MAX_MAC_SAP   2
74
75 #define DU_RLC_UL_CONFIGURED  (RLC_GEN_CFG |  \
76       RLC_MAC_SAP_CFG | RLC_UDX_SAP_CFG)
77 #define DU_RLC_DL_CONFIGURED DU_RLC_UL_CONFIGURED
78
79 #define MAC_CONFIGURED (MAC_GEN_CFG | MAC_SAP_CFG)
80
81 #define DU_SET_ZERO(_buf, _size)   \
82    cmMemset((U8 *)(_buf), 0, _size);
83
84 /* allocate and zero out a static buffer */
85 #define DU_ALLOC(_datPtr, _size)                                \
86 {                                                               \
87    S16 _ret;                                                    \
88    _ret = SGetSBuf(DU_APP_MEM_REGION, DU_POOL,                  \
89                     (Data **)&_datPtr, _size);                  \
90    if(_ret == ROK)                                              \
91       cmMemset((U8*)_datPtr, 0, _size);                         \
92    else                                                         \
93       _datPtr = NULLP;                                          \
94 }
95
96 /* free a static buffer */
97 #define DU_FREE(_datPtr, _size)                                 \
98    if(_datPtr)                                                  \
99       SPutSBuf(DU_APP_MEM_REGION, DU_POOL,                      \
100          (Data *)_datPtr, _size);
101
102 /* Allocate shared memory to be used for LWLC 
103  * during inter-layer communication */
104 #define DU_ALLOC_SHRABL_BUF(_buf, _size)                     \
105 {                                                            \
106    if(SGetStaticBuffer(DU_APP_MEM_REGION, DU_POOL,           \
107       (Data **)&_buf, (Size) _size, 0) == ROK)               \
108    {                                                         \
109       cmMemset((U8 *)(_buf), 0, _size);                      \
110    }                                                         \
111    else                                                      \
112    {                                                         \
113       (_buf) = NULLP;                                        \
114    }                                                         \
115 }
116
117 /* Free shared memory, received through LWLC */
118 #define DU_FREE_SHRABL_BUF(_region, _pool,_buf, _size)          \
119 {                                                               \
120    if (_buf != NULLP)                                           \
121    {                                                            \
122       (Void) SPutStaticBuffer(_region, _pool,                   \
123            (Data *) _buf, (Size) _size, 0);                     \
124        _buf = NULLP;                                            \
125    }                                                            \
126 }
127
128
129 typedef enum
130 {
131    CELL_OUT_OF_SERVICE,
132    ACTIVATION_IN_PROGRESS,
133    ACTIVATED,
134    DELETION_IN_PROGRESS
135 }CellStatus;
136
137 typedef enum
138 {
139    UE_INACTIVE,
140         UE_ACTIVE
141 }UeState;
142
143 typedef struct cellCfgParams
144 {
145    NrEcgi      nrEcgi;         /* ECGI */
146    U16         nrPci;          /* PCI */
147    U16         fiveGsTac;         /* 5gSTac */
148    Plmn      plmn[MAX_PLMN]; /* List of serving PLMN IDs */
149    U32         maxUe;          /* max UE per slot */
150 }CellCfgParams;
151
152 typedef struct duUeCb
153 {
154    uint32_t gnbDuUeF1apId; /* GNB DU UE F1AP ID */
155    uint32_t gnbCuUeF1apId; /* GNB CU UE F1AP ID */
156    UeState  ueState;
157    MacUeCfg macUeCfg;
158 }DuUeCb;
159
160 typedef struct duCellCb
161 {
162    uint16_t       cellId;           /* Internal cell Id */
163    CellCfgParams  cellInfo;         /* Cell info */
164    Bool           firstSlotIndRcvd;
165    CellStatus     cellStatus;       /* Cell status */
166    uint32_t       numActvUes;       /* Total Active UEs */
167    DuUeCb         ueCb[DU_MAX_UE];  /* UE CONTEXT */
168 }DuCellCb;
169
170 typedef struct duLSapCb
171 {
172    Pst pst;
173    SuId        suId;
174    SpId        spId;
175    State       sapState;
176    Mem         mem;
177    CmTimer     timer;
178    U8          bndRetryCnt;
179    U8          maxBndRetry;
180    TmrCfg      bndTmr;
181 }DuLSapCb;
182
183 typedef struct ueCcchCtxt
184 {
185    uint32_t gnbDuUeF1apId; /* GNB DU UE F1AP ID */
186    uint16_t crnti;         /* CRNTI */
187    uint16_t cellId;        /* Cell Id */
188 }UeCcchCtxt;
189
190
191 /* DU APP DB */
192 typedef struct duCb
193 {
194    Mem           mem;    /* Memory configs */
195    TskInit       init;   /* DU Init */
196    //DuLSapCb      **macSap;  /* MAC SAP */
197    Bool          f1Status; /* Status of F1 connection */
198    Bool          e2Status; /* Status of E2 connection */
199    uint8_t       numCfgCells; 
200    DuCellCb*     cfgCellLst[DU_MAX_CELLS];     /* List of cells at DU APP of type DuCellCb */
201    uint8_t       numActvCells;
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 **********************************************************************/