[Epic-ID: ODUHIGH-406][Task-ID: ODUHIGH-422]F1AP Paging Message Handling at DUAPP
[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 #define MAX_PAGING_UE_RECORDS 32
61
62 typedef enum
63 {
64    SLICE_INFO_NOT_AVAILABLE,
65    SLICE_CONFIGURED,
66    SLICE_RECONFIGURED
67 }SliceCfgState;
68
69 typedef enum
70 {
71    CELL_OUT_OF_SERVICE,
72    ACTIVATION_IN_PROGRESS,
73    ACTIVATED,
74    DELETION_IN_PROGRESS
75 }CellStatus;
76
77 typedef enum
78 {
79    UE_INACTIVE,
80    UE_ACTIVE,
81    UE_HANDIN_IN_PROGRESS,
82    UE_DELETION_IN_PROGRESS
83 }UeState;
84
85 typedef enum
86 {
87    UE_CTXT_UNKNOWN,
88    UE_CTXT_SETUP,
89    UE_CTXT_MOD,
90    UE_CTXT_RRC_RECFG_COMPLETE,
91    UE_CTXT_CFG_QUERY,
92    UE_CTXT_RELEASE
93 }UeCtxtActionType;
94
95 /** F1AP Msg IE **/
96 typedef struct f1setupRsp
97 {
98    uint32_t transId; /* Uniquely identify transaction */
99    char     cuName[CU_DU_NAME_LEN_MAX];   /* CU Name */
100    F1RrcVersion    rrcVersion;  /* RRC version */
101 }F1SetupRsp;
102
103 typedef struct f1DlRrcMsg 
104 {
105    uint32_t gnbDuUeF1apId;
106    uint32_t gnbCuUeF1apId;
107    uint8_t  srbId;
108    bool     execDup;
109    bool     deliveryStatRpt;
110    uint16_t rrcMsgSize;
111    uint8_t  *rrcMsgPdu;
112 }F1DlRrcMsg;
113
114 typedef struct gtpTnlCfg
115 {
116    uint32_t ulTnlAddress;  /* remote Address */
117    uint32_t dlTnlAddress;  /* local Address */
118    uint32_t teId;
119 }GtpTnlCfg;
120
121 typedef struct upTnlCfg
122 {
123    ConfigType configType;
124    uint8_t cellId;
125    uint8_t ueId;
126    uint8_t drbId;
127    GtpTnlCfg *tnlCfg1; /* Tunnel 1 */
128    GtpTnlCfg *tnlCfg2; /* Tunnel 2 */
129 }UpTnlCfg;
130
131 typedef struct duUeCfg
132 {
133    void *cellGrpCfg;
134    void *ueNrCapability;
135    uint8_t numRlcLcs;        /* Rlc Ue Cfg */
136    RlcBearerCfg rlcLcCfg[MAX_NUM_LC];
137    uint8_t numMacLcs;        /* Mac Ue Cfg */
138    LcCfg   macLcCfg[MAX_NUM_LC];
139    AmbrCfg *ambrCfg;
140    uint8_t numDrb;
141    UpTnlCfg upTnlInfo[MAX_NUM_DRB];  /* User plane TNL Info*/
142    uint8_t numDrbSetupMod;        /*No. of DRB Added during Modification*/
143    MacUeCfg copyOfmacUeCfg;
144    DataTransmissionAction dataTransmissionAction; 
145 }DuUeCfg;
146
147 typedef struct f1UeContextSetup
148 {
149    UeCtxtActionType actionType;
150    uint8_t cellIdx;
151    DuUeCfg  duUeCfg;        
152    bool     dlRrcMsgPres;
153    F1DlRrcMsg  *dlRrcMsg;
154 }F1UeContextSetupDb;
155
156 typedef struct cellCfgParams
157 {
158    NrEcgi      nrEcgi;         /* ECGI */
159    uint16_t    nrPci;          /* PCI */
160    uint16_t    fiveGsTac;         /* 5gSTac */
161    Plmn        plmn[MAX_PLMN]; /* List of serving PLMN IDs */
162    uint32_t    maxUe;          /* max UE per slot */
163 }CellCfgParams;
164
165 typedef struct duUeCb
166 {
167    F1UeContextSetupDb *f1UeDb;
168    uint16_t crnti;
169    uint32_t gnbDuUeF1apId;   /* GNB DU UE F1AP ID */
170    uint32_t gnbCuUeF1apId;   /* GNB CU UE F1AP ID */
171    uint32_t drbBitMap;       /* Drb Bit Map */
172    UeState  ueState;         /* UE Active/ Ue Inactive state */
173    MacUeCfg macUeCfg;        /* Mac Ue Cfg */
174    RlcUeCfg rlcUeCfg;        /* Rlc Ue Cfg */
175 }DuUeCb;
176
177 typedef struct  slotInfo
178 {
179    uint16_t sfn;
180    uint16_t slot;
181 }SlotInfo;
182
183 typedef struct pagingMsg
184 {
185    /*Note: Paging UEID is extracted from 5gSTMSI as per Spec 38.304, Sec 7.1.
186     *This is not same as DU-UE_F1AP_ID or CU_UE_F1AP_ID*/
187    uint16_t  pagUeId;              /* UE Identifier from CU*/
188
189    /*TODO: When RAN Inititated Paging will be supported then I-RNTI will be
190     * added as a choice for UE Identity along with S-TMSI*/
191    uint64_t  sTmsi;             /* UE Paging Identity: S-TMSI */
192    bool      pagingDrxPres;     /* flag to indicate paging drx present or not */
193    uint16_t  pagingDrx;         /* UE specific paging drx */
194    uint8_t   pagPriority;       /* Paging priority */
195    uint16_t  pagingFrame;       /* paging frame */
196    uint16_t  pagingFrameOffset; /* paging offset */
197    uint8_t   i_s;               /* Index points to PO from the sub-frame pattern */
198    uint16_t  T;                 /* T is DRX cycle of the UE */
199 }DuPagingMsg;
200
201 typedef struct duPagUeRecord
202 {
203    uint16_t  pagUeId;              /*UEID calculated from 5gsTMSI as per Spec 38.304*/
204    uint64_t  sTmsi;             /*UE Paging Identity: 5GS-TMSI*/
205    uint8_t   pagPriority;       /* Paging priority */
206 }DuPagUeRecord;
207
208 typedef struct duPagInfo
209 {
210    uint8_t      i_s;          /*Index of PO*/
211    CmLListCp    pagUeList;    /*List of UEs to be paged in this Paging Frame/Paging Occ*/
212 }DuPagUeList;
213
214 typedef struct duPagInfoMap
215 {
216    uint16_t    pf;             /* Paging Frame*/
217    CmLListCp   pagInfoList;    /* Master List of Paging Identified by PF and i_s*/
218 }DuPagInfoList;
219
220 typedef struct duCellCb
221 {
222    uint16_t       cellId;                 /* Internal cell Id */
223    CellCfgParams  cellInfo;               /* Cell info */
224    /* pointer to store the address of macCellCfg params used to send du-app to MAC */
225    MacCellCfg     *duMacCellCfg;
226    CellStatus     cellStatus;             /* Cell status */
227    uint32_t       numActvUes;             /* Total Active UEs */
228    DuUeCb         ueCb[MAX_NUM_UE];       /* Stores UE context */
229    SlotInfo       currSlotInfo;
230    DuPagingMsg    tmpPagingInfoOfUe;      /* UE paging information */
231    CmHashListCp   pagingInfoMap;          /*Paging Map between PF and PagingInfoList*/
232 }DuCellCb;
233
234 typedef struct duLSapCb
235 {
236    Pst pst;
237    SuId        suId;
238    SpId        spId;
239    State       sapState;
240    Mem         mem;
241    CmTimer     timer;
242    uint8_t     bndRetryCnt;
243    uint8_t     maxBndRetry;
244    TmrCfg      bndTmr;
245 }DuLSapCb;
246
247 typedef struct ueCcchCtxt
248 {
249    uint32_t gnbDuUeF1apId; /* GNB DU UE F1AP ID */
250    uint16_t crnti;         /* CRNTI */
251    uint16_t cellId;        /* Cell Id */
252 }UeCcchCtxt;
253
254 /* This structure is added to store the information about the F1AP pdu and
255  * transId so that It can be used in future */
256 typedef struct reservedF1apPduInfo
257 {
258    uint8_t transId;               /* trans Id */
259    void *f1apMsg;              /* msg structure */
260 }ReservedF1apPduInfo;
261
262 /* DU APP DB */
263 typedef struct duCb
264 {
265    Mem           mem;                       /* Memory configs */
266    TskInit       init;                      /* DU Init */
267    bool          f1Status;                  /* Status of F1 connection */
268    bool          e2Status;                  /* Status of E2 connection */
269    uint8_t       numCfgCells;               /* number of configured cells */ 
270    DuCellCb*     cfgCellLst[MAX_NUM_CELL];  /* List of cells at DU APP of type DuCellCb */
271    uint8_t       numActvCells;              /* Number of active cells */
272    DuCellCb*     actvCellLst[MAX_NUM_CELL]; /* List of cells activated/to be activated of type DuCellCb */
273    uint32_t      gnbDuUeF1apIdGenerator;    /* Generating Du Ue F1ap Id */
274    uint32_t      numUe;                     /* current number of UEs */
275    UeCcchCtxt    ueCcchCtxt[MAX_NUM_UE];    /* mapping of gnbDuUeF1apId to CRNTI required for CCCH processing*/
276    uint8_t       numTeId;                   /* current number of TEIDs configured in the system*/
277    UpTnlCfg*     upTnlCfg[MAX_TEID];        /* tunnel info for every Drb */
278    CmLListCp     reservedF1apPduList;       /*storing F1AP pdu infomation and transId */
279    SliceCfgState sliceState;
280    F1SetupMsg    f1SetupReqAndRspMsg;
281 }DuCb;
282
283
284 typedef struct duLSapCfg
285 {
286    SuId        suId;
287    SpId        spId;
288    Ent         srcEnt;
289    Inst        srcInst;
290    ProcId      dstProcId;
291    Ent         dstEnt;
292    Inst        dstInst;
293    Priority    dstPrior;
294    Route       dstRoute;
295    Selector    dstSel;
296    Mem         mem;
297    uint8_t          maxBndRetry;
298    TmrCfg      bndTmr;
299    TmrCfg      connTmr;
300 }DuLSapCfg;
301
302 /* global variables */
303 DuCb duCb;
304 //DuCfgParams duCfgParam;
305
306 /* DU Cell Functions */
307 uint8_t duActvInit(Ent entity, Inst inst, Region region, Reason reason);
308 uint8_t duActvTsk(Pst *pst, Buffer *mBuf);
309 uint8_t duSendRlcUlCfg();
310 uint8_t duSendRlcDlCfg();
311 uint8_t duBuildRlcCfg(Inst inst);
312 uint8_t duBuildRlcLsapCfg(Ent ent, Inst inst, uint8_t lsapInst);
313 uint8_t duBuildRlcUsapCfg(uint8_t elemId, Ent ent, Inst inst);
314 uint8_t DuHdlRlcCfgComplete(Pst *pst, RlcMngmt *cfm);
315 uint8_t duHdlRlcCntrlCfgComplete(Pst *pst, RlcMngmt *cfm);
316 uint8_t duProcRlcUlCfgComplete(Pst *pst, RlcMngmt *cfm);
317 uint8_t duProcRlcDlCfgComplete(Pst *pst, RlcMngmt *cfm);
318 uint8_t duSendMacCfg();
319 uint8_t duBuildMacGenCfg();
320 uint8_t duBuildMacUsapCfg(SpId sapId);
321 uint8_t duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm);
322 uint8_t duBindUnbindRlcToMacSap(uint8_t inst, uint8_t action);
323 uint8_t duProcCfgComplete();
324 uint8_t duSendSchCfg();
325 uint8_t duSctpStartReq();
326 uint8_t duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy);
327
328 uint8_t duBuildEgtpCfgReq();
329 uint8_t duHdlEgtpCfgComplete(CmStatus cfm);
330 uint8_t duSendEgtpSrvOpenReq();
331 uint8_t duHdlEgtpSrvOpenComplete(CmStatus cfm);
332 uint8_t duSendEgtpTnlMgmtReq(uint8_t action, uint32_t teIdMod, GtpTnlCfg *tnlInfo);
333 uint8_t duSendEgtpDatInd(Buffer *mBuf);
334 uint8_t duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm);
335 uint8_t duBuildAndSendMacCellStart();
336 uint8_t duBuildAndSendMacCellStop(uint16_t cellId);
337 #endif
338
339 /**********************************************************************
340   End of file
341  **********************************************************************/