Renaming UE IDX to UE ID in DU APP and its interfaces [Issue-ID: ODUHIGH-401]
[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    SLICE_INFO_NOT_AVAILABLE,
63    SLICE_CONFIGURED,
64    SLICE_RECONFIGURED
65 }SliceCfgState;
66
67 typedef enum
68 {
69    CELL_OUT_OF_SERVICE,
70    ACTIVATION_IN_PROGRESS,
71    ACTIVATED,
72    DELETION_IN_PROGRESS
73 }CellStatus;
74
75 typedef enum
76 {
77    UE_INACTIVE,
78    UE_ACTIVE,
79    UE_DELETION_IN_PROGRESS
80 }UeState;
81
82 typedef enum
83 {
84    UE_CTXT_UNKNOWN,
85    UE_CTXT_SETUP,
86    UE_CTXT_MOD,
87    UE_CTXT_RELEASE
88 }UeCtxtActionType;
89
90 /** F1AP Msg IE **/
91 typedef struct f1setupRsp
92 {
93    uint32_t transId; /* Uniquely identify transaction */
94    char     cuName[CU_DU_NAME_LEN_MAX];   /* CU Name */
95    F1RrcVersion    rrcVersion;  /* RRC version */
96 }F1SetupRsp;
97
98 typedef struct f1DlRrcMsg 
99 {
100    uint32_t gnbDuUeF1apId;
101    uint32_t gnbCuUeF1apId;
102    uint8_t  srbId;
103    bool     execDup;
104    bool     deliveryStatRpt;
105    uint16_t rrcMsgSize;
106    uint8_t  *rrcMsgPdu;
107 }F1DlRrcMsg;
108
109 typedef struct gtpTnlCfg
110 {
111    uint32_t ulTnlAddress;  /* remote Address */
112    uint32_t dlTnlAddress;  /* local Address */
113    uint32_t teId;
114 }GtpTnlCfg;
115
116 typedef struct upTnlCfg
117 {
118    ConfigType configType;
119    uint8_t cellId;
120    uint8_t ueId;
121    uint8_t drbId;
122    GtpTnlCfg *tnlCfg1; /* Tunnel 1 */
123    GtpTnlCfg *tnlCfg2; /* Tunnel 2 */
124 }UpTnlCfg;
125
126 typedef struct duUeCfg
127 {
128    void *cellGrpCfg;
129    void *ueNrCapability;
130    uint8_t numRlcLcs;        /* Rlc Ue Cfg */
131    RlcBearerCfg rlcLcCfg[MAX_NUM_LC];
132    uint8_t numMacLcs;        /* Mac Ue Cfg */
133    LcCfg   macLcCfg[MAX_NUM_LC];
134    AmbrCfg *ambrCfg;
135    uint8_t numDrb;
136    UpTnlCfg upTnlInfo[MAX_NUM_DRB];  /* User plane TNL Info*/
137    uint8_t numDrbSetupMod;        /*No. of DRB Added during Modification*/
138    MacUeCfg copyOfmacUeCfg;
139 }DuUeCfg;
140
141 typedef struct f1UeContextSetup
142 {
143    UeCtxtActionType actionType;
144    uint8_t cellIdx;
145    DuUeCfg  duUeCfg;        
146    bool     dlRrcMsgPres;
147    F1DlRrcMsg  *dlRrcMsg;
148 }F1UeContextSetupDb;
149
150 typedef struct cellCfgParams
151 {
152    NrEcgi      nrEcgi;         /* ECGI */
153    uint16_t    nrPci;          /* PCI */
154    uint16_t    fiveGsTac;         /* 5gSTac */
155    Plmn        plmn[MAX_PLMN]; /* List of serving PLMN IDs */
156    uint32_t    maxUe;          /* max UE per slot */
157 }CellCfgParams;
158
159 typedef struct duUeCb
160 {
161    F1UeContextSetupDb *f1UeDb;
162    uint16_t crnti;
163    uint32_t gnbDuUeF1apId;   /* GNB DU UE F1AP ID */
164    uint32_t gnbCuUeF1apId;   /* GNB CU UE F1AP ID */
165    uint32_t drbBitMap;       /* Drb Bit Map */
166    UeState  ueState;         /* UE Active/ Ue Inactive state */
167    MacUeCfg macUeCfg;        /* Mac Ue Cfg */
168    RlcUeCfg rlcUeCfg;        /* Rlc Ue Cfg */
169 }DuUeCb;
170
171 typedef struct duCellCb
172 {
173    uint16_t       cellId;                 /* Internal cell Id */
174    CellCfgParams  cellInfo;               /* Cell info */
175    /* pointer to store the address of macCellCfg params used to send du-app to MAC */
176    MacCellCfg     *duMacCellCfg;
177    CellStatus     cellStatus;             /* Cell status */
178    uint32_t       gnbDuUeF1apIdGenerator; /* Generating Du Ue F1ap Id */
179    uint32_t       numActvUes;             /* Total Active UEs */
180    DuUeCb         ueCb[MAX_NUM_UE];       /* UE CONTEXT */
181 }DuCellCb;
182
183 typedef struct duLSapCb
184 {
185    Pst pst;
186    SuId        suId;
187    SpId        spId;
188    State       sapState;
189    Mem         mem;
190    CmTimer     timer;
191    uint8_t     bndRetryCnt;
192    uint8_t     maxBndRetry;
193    TmrCfg      bndTmr;
194 }DuLSapCb;
195
196 typedef struct ueCcchCtxt
197 {
198    uint32_t gnbDuUeF1apId; /* GNB DU UE F1AP ID */
199    uint16_t crnti;         /* CRNTI */
200    uint16_t cellId;        /* Cell Id */
201 }UeCcchCtxt;
202
203 /* This structure is added to store the information about the F1AP pdu and
204  * transId so that It can be used in future */
205 typedef struct reservedF1apPduInfo
206 {
207    uint8_t transId;               /* trans Id */
208    void *f1apMsg;              /* msg structure */
209 }ReservedF1apPduInfo;
210
211 /* DU APP DB */
212 typedef struct duCb
213 {
214    Mem           mem;                       /* Memory configs */
215    TskInit       init;                      /* DU Init */
216    bool          f1Status;                  /* Status of F1 connection */
217    bool          e2Status;                  /* Status of E2 connection */
218    uint8_t       numCfgCells;               /* number of configured cells */ 
219    DuCellCb*     cfgCellLst[MAX_NUM_CELL];  /* List of cells at DU APP of type DuCellCb */
220    uint8_t       numActvCells;              /* Number of active cells */
221    DuCellCb*     actvCellLst[MAX_NUM_CELL]; /* List of cells activated/to be activated of type DuCellCb */
222    uint32_t      numUe;                     /* current number of UEs */
223    UeCcchCtxt    ueCcchCtxt[MAX_NUM_UE];    /* mapping of gnbDuUeF1apId to CRNTI required for CCCH processing*/
224    uint8_t       numTeId;                    /* current number of TEIDs configured in the system*/
225    UpTnlCfg*     upTnlCfg[MAX_TEID];     /* tunnel info for every Drb */
226    CmLListCp     reservedF1apPduList;       /*storing F1AP pdu infomation and transId */
227    SliceCfgState sliceState;
228 }DuCb;
229
230
231 typedef struct duLSapCfg
232 {
233    SuId        suId;
234    SpId        spId;
235    Ent         srcEnt;
236    Inst        srcInst;
237    ProcId      dstProcId;
238    Ent         dstEnt;
239    Inst        dstInst;
240    Priority    dstPrior;
241    Route       dstRoute;
242    Selector    dstSel;
243    Mem         mem;
244    uint8_t          maxBndRetry;
245    TmrCfg      bndTmr;
246    TmrCfg      connTmr;
247 }DuLSapCfg;
248
249 /* global variables */
250 DuCb duCb;
251 //DuCfgParams duCfgParam;
252
253 /* DU Cell Functions */
254 uint8_t duActvInit(Ent entity, Inst inst, Region region, Reason reason);
255 uint8_t duActvTsk(Pst *pst, Buffer *mBuf);
256 uint8_t duSendRlcUlCfg();
257 uint8_t duSendRlcDlCfg();
258 uint8_t duBuildRlcCfg(Inst inst);
259 uint8_t duBuildRlcLsapCfg(Ent ent, Inst inst, uint8_t lsapInst);
260 uint8_t duBuildRlcUsapCfg(uint8_t elemId, Ent ent, Inst inst);
261 uint8_t DuHdlRlcCfgComplete(Pst *pst, RlcMngmt *cfm);
262 uint8_t duHdlRlcCntrlCfgComplete(Pst *pst, RlcMngmt *cfm);
263 uint8_t duProcRlcUlCfgComplete(Pst *pst, RlcMngmt *cfm);
264 uint8_t duProcRlcDlCfgComplete(Pst *pst, RlcMngmt *cfm);
265 uint8_t duSendMacCfg();
266 uint8_t duBuildMacGenCfg();
267 uint8_t duBuildMacUsapCfg(SpId sapId);
268 uint8_t duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm);
269 uint8_t duBindUnbindRlcToMacSap(uint8_t inst, uint8_t action);
270 uint8_t duProcCfgComplete();
271 uint8_t duSendSchCfg();
272 uint8_t duSctpStartReq();
273 uint8_t duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy);
274
275 uint8_t duBuildEgtpCfgReq();
276 uint8_t duHdlEgtpCfgComplete(CmStatus cfm);
277 uint8_t duSendEgtpSrvOpenReq();
278 uint8_t duHdlEgtpSrvOpenComplete(CmStatus cfm);
279 uint8_t duSendEgtpTnlMgmtReq(uint8_t action, uint32_t teIdMod, GtpTnlCfg *tnlInfo);
280 uint8_t duSendEgtpDatInd(Buffer *mBuf);
281 uint8_t duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm);
282 uint8_t duBuildAndSendMacCellStart();
283 uint8_t duBuildAndSendMacCellStop(uint16_t cellId);
284 #endif
285
286 /**********************************************************************
287   End of file
288  **********************************************************************/