[JIRA ID: ODUHIGH-242] RB configuration for Ue Context Setup for RLC
[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 }UeCtxtActionType;
80
81 typedef struct cellCfgParams
82 {
83    NrEcgi      nrEcgi;         /* ECGI */
84    uint16_t    nrPci;          /* PCI */
85    uint16_t    fiveGsTac;         /* 5gSTac */
86    Plmn        plmn[MAX_PLMN]; /* List of serving PLMN IDs */
87    uint32_t    maxUe;          /* max UE per slot */
88 }CellCfgParams;
89
90 typedef struct duUeCfg
91 {
92    uint8_t numRlcLcs;        /* Rlc Ue Cfg */
93    RlcBearerCfg rlcLcCfg[MAX_NUM_LC];
94    uint8_t numMacLcs;        /* Mac Ue Cfg */
95    LcCfg   macLcCfg[MAX_NUM_LC];
96    MaxAggrBitRate *maxAggrBitRate;
97 }DuUeCfg;
98
99 typedef struct ueContextSetup
100 {
101    UeCtxtActionType actionType;
102    uint8_t  cellIdx;
103    void     *cellGrpCfg;
104    uint16_t rrcMsgLen;
105    uint8_t  *rrcMsg;
106    bool     deliveryStaReq; 
107    DuUeCfg  duUeCfg;          /* Du Ue Cfg */
108 }UeContextSetupDb;
109
110 typedef struct duUeCb
111 {
112    uint16_t crnti;
113    uint32_t gnbDuUeF1apId;   /* GNB DU UE F1AP ID */
114    uint32_t gnbCuUeF1apId;   /* GNB CU UE F1AP ID */
115    uint32_t drbBitMap;       /* Drb Bit Map */
116    UeState  ueState;         /* UE Active/ Ue Inactive state */
117    MacUeCfg macUeCfg;        /* Mac Ue Cfg */
118    RlcUeCfg rlcUeCfg;        /* Rlc Ue Cfg */
119    UeContextSetupDb *f1UeDb;
120 }DuUeCb;
121
122 typedef struct duCellCb
123 {
124    uint16_t       cellId;           /* Internal cell Id */
125    CellCfgParams  cellInfo;         /* Cell info */
126    /* pointer to store the address of macCellCfg params used to send du-app to MAC */
127    MacCellCfg    *duMacCellCfg;
128    bool           firstSlotIndRcvd;
129    CellStatus     cellStatus;       /* Cell status */
130    uint32_t       numActvUes;       /* Total Active UEs */
131    DuUeCb         ueCb[MAX_NUM_UE];  /* UE CONTEXT */
132 }DuCellCb;
133
134 typedef struct duLSapCb
135 {
136    Pst pst;
137    SuId        suId;
138    SpId        spId;
139    State       sapState;
140    Mem         mem;
141    CmTimer     timer;
142    uint8_t     bndRetryCnt;
143    uint8_t     maxBndRetry;
144    TmrCfg      bndTmr;
145 }DuLSapCb;
146
147 typedef struct ueCcchCtxt
148 {
149    uint32_t gnbDuUeF1apId; /* GNB DU UE F1AP ID */
150    uint16_t crnti;         /* CRNTI */
151    uint16_t cellId;        /* Cell Id */
152 }UeCcchCtxt;
153
154
155 /* DU APP DB */
156 typedef struct duCb
157 {
158    Mem           mem;    /* Memory configs */
159    TskInit       init;   /* DU Init */
160    //DuLSapCb      **macSap;  /* MAC SAP */
161    bool          f1Status; /* Status of F1 connection */
162    bool          e2Status; /* Status of E2 connection */
163    uint8_t       numCfgCells; 
164    DuCellCb*     cfgCellLst[MAX_NUM_CELL];     /* List of cells at DU APP of type DuCellCb */
165    uint8_t       numActvCells;
166    DuCellCb*     actvCellLst[MAX_NUM_CELL];    /* List of cells activated/to be activated of type DuCellCb */
167    uint32_t       numUe;            /* current number of UEs */
168    UeCcchCtxt     ueCcchCtxt[MAX_NUM_UE]; /* mapping of gnbDuUeF1apId to CRNTI required for CCCH processing*/
169 }DuCb;
170
171
172 typedef struct duLSapCfg
173 {
174    SuId        suId;
175    SpId        spId;
176    Ent         srcEnt;
177    Inst        srcInst;
178    ProcId      dstProcId;
179    Ent         dstEnt;
180    Inst        dstInst;
181    Priority    dstPrior;
182    Route       dstRoute;
183    Selector    dstSel;
184    Mem         mem;
185    uint8_t          maxBndRetry;
186    TmrCfg      bndTmr;
187    TmrCfg      connTmr;
188 }DuLSapCfg;
189
190 /* global variables */
191 DuCb duCb;
192 //DuCfgParams duCfgParam;
193
194 /* DU Cell Functions */
195 uint8_t duActvInit(Ent entity, Inst inst, Region region, Reason reason);
196 uint8_t duActvTsk(Pst *pst, Buffer *mBuf);
197 uint8_t duSendRlcUlCfg();
198 uint8_t duSendRlcDlCfg();
199 uint8_t duBuildRlcCfg(Inst inst);
200 uint8_t duBuildRlcLsapCfg(Ent ent, Inst inst, uint8_t lsapInst);
201 uint8_t duBuildRlcUsapCfg(uint8_t elemId, Ent ent, Inst inst);
202 uint8_t DuHdlRlcCfgComplete(Pst *pst, RlcMngmt *cfm);
203 uint8_t duHdlRlcCntrlCfgComplete(Pst *pst, RlcMngmt *cfm);
204 uint8_t duProcRlcUlCfgComplete(Pst *pst, RlcMngmt *cfm);
205 uint8_t duProcRlcDlCfgComplete(Pst *pst, RlcMngmt *cfm);
206 uint8_t duSendMacCfg();
207 uint8_t duBuildMacGenCfg();
208 uint8_t duBuildMacUsapCfg(SpId sapId);
209 uint8_t duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm);
210 uint8_t duBindUnbindRlcToMacSap(uint8_t inst, uint8_t action);
211 uint8_t duProcCfgComplete();
212 uint8_t duSendSchCfg();
213 uint8_t duSctpStartReq();
214 uint8_t duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy);
215
216 uint8_t duBuildEgtpCfgReq();
217 uint8_t duHdlEgtpCfgComplete(CmStatus cfm);
218 uint8_t duSendEgtpSrvOpenReq();
219 uint8_t duHdlEgtpSrvOpenComplete(CmStatus cfm);
220 uint8_t duSendEgtpTnlMgmtReq(uint8_t action, uint32_t lclTeid, uint32_t remTeid);
221 uint8_t duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm);
222 uint8_t duSendEgtpTestData();
223 uint8_t duSendEgtpDatInd(Buffer *mBuf);
224 uint8_t duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm);
225 uint8_t duBuildAndSendMacCellStartReq();
226 uint8_t duBuildAndSendMacCellStopReq();
227 #endif
228
229 /**********************************************************************
230   End of file
231  **********************************************************************/