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