[Issue-ID : ODUHIGH-486] SCTP Port fix at F1 and E2 interface
[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 LOCAL_IP_CU "192.168.130.82"
30
31 #define F1_SCTP_PORT 38472
32 #define NUM_F1_ASSOC 1  
33 #define REMOTE_IP_DU (char*[]){"192.168.130.81", "192.168.130.83"}
34 #endif
35
36 #define DU_EGTP_PORT  (int[]){39001, 39002}
37 #define CU_EGTP_PORT (int[]){39003, 39004}
38 #define RRC_VER 0
39 #define EXT_RRC_VER 5
40
41 #define PLMN_MCC0 3
42 #define PLMN_MCC1 1
43 #define PLMN_MCC2 1
44 #define PLMN_MNC0 4
45 #define PLMN_MNC1 8
46 #define PLMN_MNC2 0
47
48 #define CU_DU_NAME_LEN_MAX 30      /* Max length of CU/DU name string */
49
50 #define CU_APP_MEM_REG 1
51 #define CU_POOL 1
52
53 #define MAX_NUM_OF_SLICE 1024 /* As per the spec 38.473, maxnoofSliceItems = 1024*/
54 #define MAX_QOS_FLOWS 64 /* As per the spec 38.331, maxNrofQFIs = 64 */
55
56 /* allocate and zero out a static buffer */
57
58 #define CU_ALLOC(_datPtr, _size)                             \
59 {                                                            \
60    S16 _ret;                                                 \
61    _ret = SGetSBuf(CU_APP_MEM_REG, CU_POOL,                  \
62                      (Data **)&_datPtr, _size);              \
63    if(_ret == ROK)                                           \
64       memset(_datPtr, 0, _size);                      \
65    else                                                      \
66       _datPtr = NULLP;                                       \
67 }
68  
69 /* free a static buffer */
70 #define CU_FREE(_datPtr, _size)                              \
71    if(_datPtr)                                               \
72    SPutSBuf(CU_APP_MEM_REG, CU_POOL,                         \
73          (Data *)_datPtr, _size);
74
75 #define SEARCH_DU_DB(_duIdx, _duId, _duDb){\
76    _duDb = NULLP; \
77    for(_duIdx=0; _duIdx < cuCb.numDu; _duIdx++)\
78    {\
79       if(cuCb.duInfo[_duIdx].duId == _duId)\
80       {\
81          _duDb =  (&cuCb.duInfo[_duIdx]);\
82          break; \
83      }\
84    }\
85 }
86
87 #define SEARCH_CELL_DB(_cellIdx, _duDb, _nrCellId, _cellCb){\
88    _cellCb = NULLP; \
89    for(_cellIdx=0; _cellIdx < _duDb->numCells; _cellIdx++)\
90    {\
91       if(_duDb->cellCb[_cellIdx].nrCellId == _nrCellId)\
92       {\
93          _cellCb = (&(_duDb->cellCb[_cellIdx]));\
94          break;\
95       }\
96    }\
97 }
98
99 #ifdef NR_DRX
100 /* Set this parameter true of false as per the need to enable or disable drx of
101  * a particular UE */
102 #define DRX_TO_BE_RELEASE true 
103 #endif
104
105 typedef enum
106 {
107    CELL_INACTIVE,
108    CELL_ACTIVE,
109    CELL_DELETION_IN_PROGRESS
110 }CellStatusInfo;
111
112 typedef enum
113 {
114    UE_IDLE,
115    UE_ATTACH_IN_PROGRESS,
116    UE_ACTIVE,
117    UE_HANDOVER_IN_PROGRESS
118 }UeState;
119
120 typedef struct RrcVersion
121 {
122   uint8_t    rrcVer;     /* Latest RRC Version */
123   uint32_t   extRrcVer;  /* Latest RRC version extended */
124 }RrcVersion;
125
126 typedef struct cuCfgParams
127 {
128    uint32_t         cuId;
129    char             cuName[CU_DU_NAME_LEN_MAX];
130    CuSctpParams     sctpParams;
131    Plmn             plmn;
132    CuEgtpParams     egtpParams;
133    RrcVersion       rrcVersion;
134 }CuCfgParams;
135
136 typedef struct handoverInfo
137 {
138    uint32_t sourceDuId;
139    uint32_t targetDuId;
140 }HandoverInfo;
141
142 typedef struct dlAmCfg
143 {
144    uint8_t        snLenDl;              /* Sequence Number length in bits. Allowed values are 12 and 18 */
145    int8_t         reAssemTmr;           /* T_reassembling Timer in msec*/
146    int16_t        statProhTmr;          /* T_status_prohibit Timer in msec*/
147 }DlAmCfg;
148
149 typedef struct ulAmCfg
150 {
151    uint8_t      snLenUl;             /* Sequence Number length in bits. Allowed values are 12 and 18 */
152    uint16_t     pollRetxTmr;         /* T_poll_retransmit Timer in msec */
153    int16_t      pollPdu;             /* Used to trigger a poll for every pollPdu.*/
154    int32_t      pollByte;            /* Poll_Byte in bytes. */
155    uint8_t      maxRetxTh;           /* Max_Retx_Threshold */
156 }UlAmCfg;
157
158 typedef struct amBearerCfg
159 {
160    UlAmCfg  ulAmCfg;
161    DlAmCfg  dlAmCfg;
162 }AmBearerCfg;
163
164 typedef struct ulUmCfg
165 {
166    uint8_t        snLenUlUm;             /* Sequence Number length in bits. Allowed values are 6 and 12 */
167 }UlUmCfg;
168
169 typedef struct dlUmCfg
170 {
171    uint8_t        snLenDlUm;             /* Sequence Number length in bits. Allowed values are 6 and 12 */
172    int8_t         reAssemTmr;            /* T_reassembling Timer in msec*/
173 }DlUmCfg;
174
175 typedef struct umBiDirBearerCfg
176 {
177    UlUmCfg  ulUmCfg;
178    DlUmCfg  dlUmCfg;
179 }UmBiDirBearerCfg;
180
181 typedef struct umUniDirUlBearerCfg
182 {
183    UlUmCfg  ulUmCfg;
184 }UmUniDirUlBearerCfg;
185
186 typedef struct umUniDirDlBearerCfg
187 {
188    DlUmCfg  dlUmCfg;
189 }UmUniDirDlBearerCfg;
190
191 typedef struct rlcLcCfg
192 {
193    uint8_t rlcMode;
194    union
195    {   
196       AmBearerCfg         amCfg;
197       UmBiDirBearerCfg    umBiDirCfg;
198       UmUniDirUlBearerCfg umUniDirUlCfg;
199       UmUniDirDlBearerCfg umUniDirDlCfg;
200    }u; 
201 }RlcLcCfg;
202
203 typedef struct macLcCfg
204 {
205    uint8_t priority;
206    uint8_t lcGroup;
207    uint8_t schReqId;
208    uint8_t pbr;        // prioritisedBitRate
209    uint8_t bsd;        // bucketSizeDuration
210 }MacLcCfg;
211
212 typedef struct srbInfo
213 {
214    uint8_t   srbId;
215    uint8_t   lcId;
216    RlcLcCfg  rlcLcCfg;
217    MacLcCfg  macLcCfg;
218    bool      cfgSentToUe;
219 }SrbInfo;
220
221 typedef struct qosInfo
222 {
223    uint8_t nonDynFiveQI;
224    uint16_t avgWindow;
225    uint16_t maxBurstDataVol;
226    uint8_t priorityLevel;
227    uint8_t preemptionCapability;
228    uint8_t preemptionVulnerability;
229    uint8_t pduSessionId;
230 }QosInfo;
231
232 typedef struct flowsMapped
233 {
234    uint8_t qosFlowId;
235    QosInfo qos;
236 }FlowsMapped;
237
238 typedef struct TnlInfo
239 {
240    uint8_t address[4];
241    uint8_t teId[4];
242 }TnlInfo;
243
244 typedef struct drbInfo
245 {
246    uint8_t drbId;
247    uint8_t lcId;
248    QosInfo qos;
249    Snssai *snssai;
250    uint8_t numFlowMap;
251    FlowsMapped flowMapList[MAX_QOS_FLOWS];
252    TnlInfo ulUpTnlInfo;
253    TnlInfo dlUpTnlInfo;
254    uint8_t rlcMode;
255    RlcLcCfg  rlcLcCfg;
256    MacLcCfg  macLcCfg;
257    bool      cfgSentToUe;
258 }DrbInfo;
259
260 typedef struct cuCellCb CuCellCb;
261
262 #ifdef NR_DRX
263 /* The following list of structures is taken from the DRX-Config section of specification 33.331. */
264 typedef struct drxOnDurationTimer
265 {
266    bool  onDurationTimerValInMs;
267    union
268    {
269       uint8_t  subMilliSeconds;
270       uint16_t milliSeconds;
271    }onDurationtimerValue;
272 }DrxOnDurationTimer;
273
274 typedef struct drxLongCycleStartOffset
275 {
276    uint16_t drxLongCycleStartOffsetChoice;
277    uint16_t drxLongCycleStartOffsetVal;
278 }DrxLongCycleStartOffset;
279
280 typedef struct shortDrx
281 {
282    uint16_t   drxShortCycle;
283    uint8_t    drxShortCycleTimer;
284 }ShortDrx;
285
286 typedef struct drxCfg
287 {
288    DrxOnDurationTimer       drxOnDurationTimer;
289    uint16_t                 drxInactivityTimer;
290    uint8_t                  drxHarqRttTimerDl;
291    uint8_t                  drxHarqRttTimerUl;
292    uint16_t                 drxRetransmissionTimerDl;
293    uint16_t                 drxRetransmissionTimerUl;
294    DrxLongCycleStartOffset  drxLongCycleStartOffset;
295    bool                     shortDrxPres;
296    ShortDrx                 shortDrx;
297    uint8_t                  drxSlotOffset;
298 }DrxCfg;
299 #endif
300
301 typedef struct cuUeCb
302 {
303    CuCellCb  *cellCb;
304    uint32_t  crnti;
305    uint8_t   gnbDuUeF1apId;
306    uint8_t   gnbCuUeF1apId;
307    uint16_t  pdcpSn;
308    uint8_t   numSrb;
309    SrbInfo   srbList[MAX_NUM_SRB];
310    uint8_t   numDrb;
311    DrbInfo   drbList[MAX_NUM_DRB];
312    F1apMsgDb f1apMsgDb;
313    UeState   state;
314 #ifdef NR_DRX
315    bool      drxCfgPresent;
316    DrxCfg    drxCfg;
317 #endif
318    HandoverInfo hoInfo;
319 }CuUeCb;
320
321 struct cuCellCb
322 {
323    uint32_t nrCellId;
324    uint8_t  numUe;
325    CuUeCb   *ueCb[MAX_NUM_UE];
326    CellStatusInfo cellStatus;
327 };
328
329 typedef struct duDb
330 {
331    uint32_t duId;
332    char     duName[CU_DU_NAME_LEN_MAX];
333    uint8_t  numCells;
334    CuCellCb cellCb[MAX_NUM_CELL];  
335    uint8_t  numUe;
336    CuUeCb   ueCb[MAX_NUM_CELL * MAX_NUM_UE];
337 }DuDb;
338
339 typedef struct cuGlobalCb
340 {
341    CuCfgParams cuCfgParams;
342    uint8_t     numSnssaiSupported;
343    Snssai      *snssaiList[MAX_NUM_OF_SLICE];
344    uint8_t     numDu;
345    DuDb        duInfo[MAX_DU_SUPPORTED];
346    uint32_t    gnbCuUeF1apIdGenerator;   /* Generating CU UE F1AP ID */
347 }CuGlobalCb;
348
349 CuGlobalCb cuCb;
350
351 void readCuCfg();
352 void cuAppInmsgHdlr(Buffer *mBuf);
353 void sctpNtfyInd(CmInetSctpNotification *ntfy);
354 uint8_t egtpInitReq();
355 void *cuConsoleHandler(void *);
356
357 #endif
358
359 /**********************************************************************
360          End of file
361 **********************************************************************/