code changes in Gnb-DU config update for CLA [Issue Id - ODUHIGH-335]
[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 /* SAP IDs */
25 #define DU_MAC_SUID 0
26 #define DU_MAC_SPID 0
27
28 /* Instance */
29 #define RLC_UL_INST 0
30 #define RLC_DL_INST 1
31
32 /* SAP state */
33 #define DU_SAP_UNBOUND 1
34 #define DU_SAP_BINDING 2
35 #define DU_SAP_BOUND   3
36
37 #define DU_ZERO_VAL 0
38
39 /* Macros */
40 #define ADD 0
41 #define DEL 1
42
43 #define RLC_GEN_CFG      1
44 #define RLC_MAC_SAP_CFG  2
45 #define RLC_UDX_SAP_CFG  4
46
47 #define MAC_GEN_CFG   1
48 #define MAC_SAP_CFG   2
49 #define MAX_MAC_SAP   2
50
51 #define DU_RLC_UL_CONFIGURED  (RLC_GEN_CFG |  \
52       RLC_MAC_SAP_CFG | RLC_UDX_SAP_CFG)
53 #define DU_RLC_DL_CONFIGURED DU_RLC_UL_CONFIGURED
54
55 #define MAC_CONFIGURED (MAC_GEN_CFG | MAC_SAP_CFG)
56
57 #define DU_SET_ZERO(_buf, _size)   \
58    memset((_buf), 0, _size);
59
60 typedef enum
61 {
62    CELL_OUT_OF_SERVICE,
63    ACTIVATION_IN_PROGRESS,
64    ACTIVATED,
65    DELETION_IN_PROGRESS
66 }CellStatus;
67
68 typedef enum
69 {
70    UE_INACTIVE,
71    UE_ACTIVE
72 }UeState;
73
74 typedef enum
75 {
76    UE_CTXT_UNKNOWN,
77    UE_CTXT_SETUP,
78    UE_CTXT_MOD,
79    UE_CTXT_RELEASE
80 }UeCtxtActionType;
81
82 /** F1AP Msg IE **/
83 typedef struct f1setupRsp
84 {
85    uint32_t transId; /* Uniquely identify transaction */
86    char     cuName[CU_DU_NAME_LEN_MAX];   /* CU Name */
87    F1RrcVersion    rrcVersion;  /* RRC version */
88 }F1SetupRsp;
89
90 typedef struct f1DlRrcMsg 
91 {
92    uint32_t gnbDuUeF1apId;
93    uint32_t gnbCuUeF1apId;
94    uint8_t  srbId;
95    bool     execDup;
96    bool     deliveryStatRpt;
97    uint16_t rrcMsgSize;
98    uint8_t  *rrcMsgPdu;
99 }F1DlRrcMsg;
100
101 typedef struct gtpTnlCfg
102 {
103    uint32_t ulTnlAddress;  /* remote Address */
104    uint32_t dlTnlAddress;  /* local Address */
105    uint32_t teId;
106 }GtpTnlCfg;
107
108 typedef struct upTnlCfg
109 {
110    ConfigType configType;
111    uint8_t cellId;
112    uint8_t ueIdx;
113    uint8_t drbId;
114    GtpTnlCfg *tnlCfg1; /* Tunnel 1 */
115    GtpTnlCfg *tnlCfg2; /* Tunnel 2 */
116 }UpTnlCfg;
117
118 typedef struct duUeCfg
119 {
120    void *cellGrpCfg;
121    void *ueNrCapability;
122    uint8_t numRlcLcs;        /* Rlc Ue Cfg */
123    RlcBearerCfg rlcLcCfg[MAX_NUM_LC];
124    uint8_t numMacLcs;        /* Mac Ue Cfg */
125    LcCfg   macLcCfg[MAX_NUM_LC];
126    AmbrCfg *ambrCfg;
127    uint8_t numDrb;
128    UpTnlCfg upTnlInfo[MAX_NUM_DRB];  /* User plane TNL Info*/
129 }DuUeCfg;
130
131 typedef struct f1UeContextSetup
132 {
133    UeCtxtActionType actionType;
134    uint8_t cellIdx;
135    DuUeCfg  duUeCfg;        
136    bool     dlRrcMsgPres;
137    F1DlRrcMsg  *dlRrcMsg;
138 }F1UeContextSetupDb;
139
140 typedef struct cellCfgParams
141 {
142    NrEcgi      nrEcgi;         /* ECGI */
143    uint16_t    nrPci;          /* PCI */
144    uint16_t    fiveGsTac;         /* 5gSTac */
145    Plmn        plmn[MAX_PLMN]; /* List of serving PLMN IDs */
146    uint32_t    maxUe;          /* max UE per slot */
147 }CellCfgParams;
148
149 typedef struct duUeCb
150 {
151    F1UeContextSetupDb *f1UeDb;
152    uint16_t crnti;
153    uint32_t gnbDuUeF1apId;   /* GNB DU UE F1AP ID */
154    uint32_t gnbCuUeF1apId;   /* GNB CU UE F1AP ID */
155    uint32_t drbBitMap;       /* Drb Bit Map */
156    UeState  ueState;         /* UE Active/ Ue Inactive state */
157    MacUeCfg macUeCfg;        /* Mac Ue Cfg */
158    RlcUeCfg rlcUeCfg;        /* Rlc Ue Cfg */
159 }DuUeCb;
160
161 typedef struct duCellCb
162 {
163    uint16_t       cellId;           /* Internal cell Id */
164    CellCfgParams  cellInfo;         /* Cell info */
165    /* pointer to store the address of macCellCfg params used to send du-app to MAC */
166    MacCellCfg    *duMacCellCfg;
167    CellStatus     cellStatus;       /* Cell status */
168    uint32_t       numActvUes;       /* Total Active UEs */
169    DuUeCb         ueCb[MAX_NUM_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    uint8_t     bndRetryCnt;
181    uint8_t     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 /* This structure is added to store the information about the F1AP pdu and
193  * transId so that It can be used in future */
194 typedef struct reservedF1apPduInfo
195 {
196    uint8_t transId;               /* trans Id */
197    void *f1apMsg;              /* msg structure */
198 }ReservedF1apPduInfo;
199
200 /* DU APP DB */
201 typedef struct duCb
202 {
203    Mem           mem;    /* Memory configs */
204    TskInit       init;   /* DU Init */
205    //DuLSapCb      **macSap;  /* MAC SAP */
206    bool          f1Status; /* Status of F1 connection */
207    bool          e2Status; /* Status of E2 connection */
208    uint8_t       numCfgCells; 
209    DuCellCb*     cfgCellLst[MAX_NUM_CELL];     /* List of cells at DU APP of type DuCellCb */
210    uint8_t       numActvCells;
211    DuCellCb*     actvCellLst[MAX_NUM_CELL];    /* List of cells activated/to be activated of type DuCellCb */
212    uint32_t       numUe;            /* current number of UEs */
213    UeCcchCtxt     ueCcchCtxt[MAX_NUM_UE]; /* mapping of gnbDuUeF1apId to CRNTI required for CCCH processing*/
214    uint8_t       numDrb;           /* current number of DRbs*/
215    UpTnlCfg*     upTnlCfg[MAX_NUM_DRB]; /* tunnel info for every Drb */
216    CmLListCp     reservedF1apPduList; /*storing F1AP pdu infomation and transId */
217 }DuCb;
218
219
220 typedef struct duLSapCfg
221 {
222    SuId        suId;
223    SpId        spId;
224    Ent         srcEnt;
225    Inst        srcInst;
226    ProcId      dstProcId;
227    Ent         dstEnt;
228    Inst        dstInst;
229    Priority    dstPrior;
230    Route       dstRoute;
231    Selector    dstSel;
232    Mem         mem;
233    uint8_t          maxBndRetry;
234    TmrCfg      bndTmr;
235    TmrCfg      connTmr;
236 }DuLSapCfg;
237
238 /* global variables */
239 DuCb duCb;
240 //DuCfgParams duCfgParam;
241
242 /* DU Cell Functions */
243 uint8_t duActvInit(Ent entity, Inst inst, Region region, Reason reason);
244 uint8_t duActvTsk(Pst *pst, Buffer *mBuf);
245 uint8_t duSendRlcUlCfg();
246 uint8_t duSendRlcDlCfg();
247 uint8_t duBuildRlcCfg(Inst inst);
248 uint8_t duBuildRlcLsapCfg(Ent ent, Inst inst, uint8_t lsapInst);
249 uint8_t duBuildRlcUsapCfg(uint8_t elemId, Ent ent, Inst inst);
250 uint8_t DuHdlRlcCfgComplete(Pst *pst, RlcMngmt *cfm);
251 uint8_t duHdlRlcCntrlCfgComplete(Pst *pst, RlcMngmt *cfm);
252 uint8_t duProcRlcUlCfgComplete(Pst *pst, RlcMngmt *cfm);
253 uint8_t duProcRlcDlCfgComplete(Pst *pst, RlcMngmt *cfm);
254 uint8_t duSendMacCfg();
255 uint8_t duBuildMacGenCfg();
256 uint8_t duBuildMacUsapCfg(SpId sapId);
257 uint8_t duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm);
258 uint8_t duBindUnbindRlcToMacSap(uint8_t inst, uint8_t action);
259 uint8_t duProcCfgComplete();
260 uint8_t duSendSchCfg();
261 uint8_t duSctpStartReq();
262 uint8_t duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy);
263
264 uint8_t duBuildEgtpCfgReq();
265 uint8_t duHdlEgtpCfgComplete(CmStatus cfm);
266 uint8_t duSendEgtpSrvOpenReq();
267 uint8_t duHdlEgtpSrvOpenComplete(CmStatus cfm);
268 uint8_t duSendEgtpTnlMgmtReq(uint8_t action, uint32_t teIdMod, GtpTnlCfg *tnlInfo);
269 uint8_t duSendEgtpDatInd(Buffer *mBuf);
270 uint8_t duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm);
271 uint8_t duBuildAndSendMacCellStart();
272 uint8_t duBuildAndSendMacCellStop(uint16_t cellId);
273 #endif
274
275 /**********************************************************************
276   End of file
277  **********************************************************************/