826038a4a581405c7c7b3832c71c3dfc2a1438db
[o-du/l2.git] / src / cu_stub / cu_stub.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 #ifndef __CU_MGR_MAIN_H__
20 #define __CU_MGR_MAIN_H__
21
22 #define CU_ID 1
23 #define CU_NAME "ORAN_OAM_CU"
24
25 #define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
26 #define CU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
27
28 #ifndef O1_ENABLE
29 #define DU_IP_V4_ADDR (char*[]){"192.168.130.81", "192.168.130.83"}
30 #define DU_SCTP_PORT (int[]){38472, 38473}
31
32 #define CU_IP_V4_ADDR "192.168.130.82"
33 #define CU_SCTP_PORT_TO_DU (int[]){38472, 38473}
34 #endif
35
36 #define DU_EGTP_PORT 39001
37 #define CU_EGTP_PORT 39002
38 #define RRC_VER 0
39 #define EXT_RRC_VER 5
40 #define PLMN_MCC0 3
41 #define PLMN_MCC1 1
42 #define PLMN_MCC2 1
43 #define PLMN_MNC0 4
44 #define PLMN_MNC1 8
45 #define PLMN_MNC2 0
46
47 #define CU_DU_NAME_LEN_MAX 30      /* Max length of CU/DU name string */
48
49 #define CU_APP_MEM_REG 1
50 #define CU_POOL 1
51
52 #define MAX_NUM_OF_SLICE 1024 /* As per the spec 38.473, maxnoofSliceItems = 1024*/
53 #define MAX_QOS_FLOWS 64 /* As per the spec 38.331, maxNrofQFIs = 64 */
54
55 /* allocate and zero out a static buffer */
56
57 #define CU_ALLOC(_datPtr, _size)                             \
58 {                                                            \
59    S16 _ret;                                                 \
60    _ret = SGetSBuf(CU_APP_MEM_REG, CU_POOL,                  \
61                      (Data **)&_datPtr, _size);              \
62    if(_ret == ROK)                                           \
63       memset(_datPtr, 0, _size);                      \
64    else                                                      \
65       _datPtr = NULLP;                                       \
66 }
67  
68 /* free a static buffer */
69 #define CU_FREE(_datPtr, _size)                              \
70    if(_datPtr)                                               \
71    SPutSBuf(CU_APP_MEM_REG, CU_POOL,                         \
72          (Data *)_datPtr, _size);
73
74 #define SEARCH_DU_DB(_duIdx, _duId, _duDb){\
75    _duDb = NULLP; \
76    for(_duIdx=0; _duIdx < cuCb.numDu; _duIdx++)\
77    {\
78       if(cuCb.duInfo[_duIdx].duId == _duId)\
79       {\
80          _duDb =  (&cuCb.duInfo[_duIdx]);\
81          break; \
82      }\
83    }\
84 }
85
86 #define SEARCH_CELL_DB(_cellIdx, _duDb, _nrCellId, _cellCb){\
87    _cellCb = NULLP; \
88    for(_cellIdx=0; _cellIdx < _duDb->numCells; _cellIdx++)\
89    {\
90       if(_duDb->cellCb[_cellIdx].nrCellId == _nrCellId)\
91       {\
92          _cellCb = (&(_duDb->cellCb[_cellIdx]));\
93          break;\
94       }\
95    }\
96 }
97
98
99 typedef enum
100 {
101    UE_IDLE,
102    UE_ATTACH_IN_PROGRESS,
103    UE_ACTIVE,
104    UE_HANDOVER_IN_PROGRESS
105 }UeState;
106
107 typedef struct RrcVersion
108 {
109   uint8_t    rrcVer;     /* Latest RRC Version */
110   uint32_t   extRrcVer;  /* Latest RRC version extended */
111 }RrcVersion;
112
113 typedef struct cuCfgParams
114 {
115    uint32_t         cuId;
116    char             cuName[CU_DU_NAME_LEN_MAX];
117    CuSctpParams     sctpParams;
118    Plmn             plmn;
119    EgtpParams       egtpParams;
120    RrcVersion       rrcVersion;
121 }CuCfgParams;
122
123 typedef struct handoverInfo
124 {
125    uint32_t sourceDuId;
126    uint32_t targetDuId;
127 }HandoverInfo;
128
129 typedef struct dlAmCfg
130 {
131    uint8_t        snLenDl;              /* Sequence Number length in bits. Allowed values are 12 and 18 */
132    int8_t         reAssemTmr;           /* T_reassembling Timer in msec*/
133    int16_t        statProhTmr;          /* T_status_prohibit Timer in msec*/
134 }DlAmCfg;
135
136 typedef struct ulAmCfg
137 {
138    uint8_t      snLenUl;             /* Sequence Number length in bits. Allowed values are 12 and 18 */
139    uint16_t     pollRetxTmr;         /* T_poll_retransmit Timer in msec */
140    int16_t      pollPdu;             /* Used to trigger a poll for every pollPdu.*/
141    int32_t      pollByte;            /* Poll_Byte in bytes. */
142    uint8_t      maxRetxTh;           /* Max_Retx_Threshold */
143 }UlAmCfg;
144
145 typedef struct amBearerCfg
146 {
147    UlAmCfg  ulAmCfg;
148    DlAmCfg  dlAmCfg;
149 }AmBearerCfg;
150
151 typedef struct ulUmCfg
152 {
153    uint8_t        snLenUlUm;             /* Sequence Number length in bits. Allowed values are 6 and 12 */
154 }UlUmCfg;
155
156 typedef struct dlUmCfg
157 {
158    uint8_t        snLenDlUm;             /* Sequence Number length in bits. Allowed values are 6 and 12 */
159    int8_t         reAssemTmr;            /* T_reassembling Timer in msec*/
160 }DlUmCfg;
161
162 typedef struct umBiDirBearerCfg
163 {
164    UlUmCfg  ulUmCfg;
165    DlUmCfg  dlUmCfg;
166 }UmBiDirBearerCfg;
167
168 typedef struct umUniDirUlBearerCfg
169 {
170    UlUmCfg  ulUmCfg;
171 }UmUniDirUlBearerCfg;
172
173 typedef struct umUniDirDlBearerCfg
174 {
175    DlUmCfg  dlUmCfg;
176 }UmUniDirDlBearerCfg;
177
178 typedef struct rlcLcCfg
179 {
180    uint8_t rlcMode;
181    union
182    {   
183       AmBearerCfg         amCfg;
184       UmBiDirBearerCfg    umBiDirCfg;
185       UmUniDirUlBearerCfg umUniDirUlCfg;
186       UmUniDirDlBearerCfg umUniDirDlCfg;
187    }u; 
188 }RlcLcCfg;
189
190 typedef struct macLcCfg
191 {
192    uint8_t priority;
193    uint8_t lcGroup;
194    uint8_t schReqId;
195    uint8_t pbr;        // prioritisedBitRate
196    uint8_t bsd;        // bucketSizeDuration
197 }MacLcCfg;
198
199 typedef struct srbInfo
200 {
201    uint8_t   srbId;
202    uint8_t   lcId;
203    RlcLcCfg  rlcLcCfg;
204    MacLcCfg  macLcCfg;
205    bool      cfgSentToUe;
206 }SrbInfo;
207
208 typedef struct qosInfo
209 {
210    uint8_t nonDynFiveQI;
211    uint16_t avgWindow;
212    uint16_t maxBurstDataVol;
213    uint8_t priorityLevel;
214    uint8_t preemptionCapability;
215    uint8_t preemptionVulnerability;
216    uint8_t pduSessionId;
217 }QosInfo;
218
219 typedef struct flowsMapped
220 {
221    uint8_t qosFlowId;
222    QosInfo qos;
223 }FlowsMapped;
224
225 typedef struct TnlInfo
226 {
227    uint8_t address[4];
228    uint8_t teId[4];
229 }TnlInfo;
230
231 typedef struct drbInfo
232 {
233    uint8_t drbId;
234    uint8_t lcId;
235    QosInfo qos;
236    Snssai *snssai;
237    uint8_t numFlowMap;
238    FlowsMapped flowMapList[MAX_QOS_FLOWS];
239    TnlInfo ulUpTnlInfo;
240    TnlInfo dlUpTnlInfo;
241    uint8_t rlcMode;
242    RlcLcCfg  rlcLcCfg;
243    MacLcCfg  macLcCfg;
244    bool      cfgSentToUe;
245 }DrbInfo;
246
247 typedef struct cuCellCb CuCellCb;
248
249 typedef struct cuUeCb
250 {
251    CuCellCb  *cellCb;
252    uint32_t  crnti;
253    uint8_t   gnbDuUeF1apId;
254    uint8_t   gnbCuUeF1apId;
255    uint8_t   numSrb;
256    SrbInfo   srbList[MAX_NUM_SRB];
257    uint8_t   numDrb;
258    DrbInfo   drbList[MAX_NUM_DRB];
259    F1apMsgDb f1apMsgDb;
260    UeState   state;
261    HandoverInfo hoInfo;
262 }CuUeCb;
263
264 struct cuCellCb
265 {
266    uint32_t nrCellId;
267    uint8_t  numUe;
268    CuUeCb   *ueCb[MAX_NUM_UE];
269 };
270
271 typedef struct duDb
272 {
273    uint32_t duId;
274    char     duName[CU_DU_NAME_LEN_MAX];
275    uint8_t  numCells;
276    CuCellCb cellCb[MAX_NUM_CELL];  
277    uint8_t  numUe;
278    CuUeCb   ueCb[MAX_NUM_CELL * MAX_NUM_UE];
279 }DuDb;
280
281 typedef struct cuGlobalCb
282 {
283    CuCfgParams cuCfgParams;
284    uint8_t     numSnssaiSupported;
285    Snssai      *snssaiList[MAX_NUM_OF_SLICE];
286    uint8_t     numDu;
287    DuDb        duInfo[MAX_DU_SUPPORTED];
288    uint32_t    gnbCuUeF1apIdGenerator;   /* Generating CU UE F1AP ID */
289 }CuGlobalCb;
290
291 CuGlobalCb cuCb;
292
293 void readCuCfg();
294 void cuAppInmsgHdlr(Buffer *mBuf);
295 void sctpNtfyInd(CmInetSctpNotification *ntfy);
296 uint8_t egtpInitReq();
297 void *cuConsoleHandler(void *);
298
299 #endif
300
301 /**********************************************************************
302          End of file
303 **********************************************************************/