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