Merge "Fix in DL PRB allocation [Issue-ID: ODUHIGH-380]"
[o-du/l2.git] / src / cm / du_app_rlc_inf.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 /* Defines APIs exchanged between du_app and cl module of RLC */
20 #ifndef __RLC_INF_H__
21 #define __RLC_INF_H__
22
23 /* Events */
24 #define EVENT_RLC_UE_CREATE_REQ  210
25 #define EVENT_RLC_UE_CREATE_RSP 211    /*!< Config Confirm */
26 #define EVENT_UL_RRC_MSG_TRANS_TO_DU  212
27 #define EVENT_DL_RRC_MSG_TRANS_TO_RLC 213
28 #define EVENT_RRC_DELIVERY_MSG_TRANS_TO_DU 214
29 #define EVENT_RLC_UE_RECONFIG_REQ  215
30 #define EVENT_RLC_UE_RECONFIG_RSP  216
31 #define EVENT_DL_RRC_MSG_RSP_TO_DU 217
32 #define EVENT_DL_USER_DATA_TRANS_TO_RLC 218
33 #define EVENT_UL_USER_DATA_TRANS_TO_DU 219
34 #define EVENT_RLC_UE_DELETE_REQ 220
35 #define EVENT_RLC_UE_DELETE_RSP 221
36
37 #define RB_ID_SRB 0
38 #define RB_ID_DRB 1
39
40 #define RB_TYPE_SRB 0        /* Signalling Radio Bearer */
41 #define RB_TYPE_DRB 1        /* Data Radio Bearer */
42
43 /* RLC Direction Config */
44 #define RLC_CFG_DIR_UL        1     /*!< Uplink direction */
45 #define RLC_CFG_DIR_DL        2     /*!< Downlink direction */
46 #define RLC_CFG_DIR_BOTH      3     /*!< Both Downlink and Uplink Direction*/
47
48
49 /* Logical Channel Type */
50 #define LCH_BCCH      1      /*!< BCCH Logical Channel */
51 #define LCH_PCCH      2      /*!< PCCH Logical Channel */
52 #define LCH_CCCH      3      /*!< CCCH Logical Channel */
53 #define LCH_DTCH      4      /*!< DTCH Logical Channel */
54 #define LCH_DCCH      5      /*!< DCCH Logical Channel */
55
56 typedef enum
57 {
58    TRANSMISSION_IN_PROGRESS,
59    TRANSMISSION_COMPLETE,
60    TRANSMISSION_FAILED
61 }DlMsgState;
62
63 typedef enum
64 {
65    RLC_CFG_REAS_NONE            ,  /*!< No Failure */
66    RLC_CFG_REAS_RB_CREAT_FAIL   ,  /*!< RB CB creation Failure */
67    RLC_CFG_REAS_UE_CREAT_FAIL   ,  /*!< UE CB creation Failure */
68    RLC_CFG_REAS_CELL_CREAT_FAIL ,  /*!< CELL CB creation Failure */
69    RLC_CFG_REAS_RB_PRSNT        ,  /*!< RB CB already present */
70    RLC_CFG_REAS_LCHTYPE_MIS     ,  /*!< Logical channel type mismatch */
71    RLC_CFG_REAS_RB_UNKWN        ,  /*!< RB Cb unknown */
72    RLC_CFG_REAS_UE_UNKWN        ,  /*!< UE Cb unknown */
73    RLC_CFG_REAS_CELL_UNKWN      ,  /*!< Cell Cb unknown */
74    RLC_CFG_REAS_RB_DEL_FAIL     ,  /*!< RB Cb Deletion Failure */
75    RLC_CFG_REAS_UE_DEL_FAIL     ,  /*!< UE Cb Deletion Failure */
76    RLC_CFG_REAS_RB_REEST_FAIL   ,  /*!< RB Cb Re establish Failure */
77    RLC_CFG_REAS_RB_MODE_MIS     ,  /*!< RB Cb Mode mismatch */
78    RLC_CFG_REAS_REEST_FAIL      ,  /*!< RB Cb Re-establishment Failed */
79    RLC_CFG_REAS_RECFG_FAIL      ,  /*!< RB Cb Re-configuration Failed */
80    RLC_CFG_REAS_INVALID_CFG     ,  /*!< Invalid Configuration Type */
81    RLC_CFG_REAS_SAME_UEID       ,  /*!< UE Ids match in ChngUeId Request */
82    RLC_CFG_REAS_CELL_DEL_FAIL   ,  /*!< Cell Cb Deletion Failure */
83    RLC_CFG_REAS_INVALID_LCHID   ,  /*!< Invalid LChId */
84    RLC_CFG_REAS_INVALID_DIR     ,  /*!< Invalid Direction */
85    RLC_CFG_REAS_UE_EXISTS       ,  /*!< UE ID already exists */
86    RLC_CFG_REAS_INVALID_SNLEN   ,  /*!< Invalid SN Length */
87    RLC_CFG_REAS_SNLEN_MIS       ,  /*!< SN Length mismatch */
88    RLC_CFG_REAS_INVALID_RGUSAP     /*!< Invalid RGU SAP ID */
89 }FailureReason;
90
91 typedef enum
92 {
93    SUCCESSFUL            ,  /*!< No Failure */
94    INVALID_CELLID      ,  /*!< CellId not present */
95    INVALID_UEID        ,  /*!< UEId not present */
96 }UeDeleteResult;
97
98 typedef enum
99 {
100    RLC_AM,                    //Acknowledged Mode
101    RLC_UM_BI_DIRECTIONAL,     //UnAcknowledged Mode
102    RLC_UM_UNI_DIRECTIONAL_UL,
103    RLC_UM_UNI_DIRECTIONAL_DL
104 }RlcMode;
105
106 typedef enum
107 {
108    AM_SIZE_12 = 1,
109    AM_SIZE_18
110 }SnLenAm;
111
112 typedef enum
113 {
114    UM_SIZE_6 = 1,
115    UM_SIZE_12
116 }SnLenUm;
117
118 typedef enum
119 {
120    RLC_DU_APP_RSP_OK = 1,
121    RLC_DU_APP_RSP_NOK
122 }RlcRsp;
123
124 typedef struct ulAmCfg
125 {
126    SnLenAm        snLenUl;              /* Sequence Number length in bits. Allowed values are 12 and 18 */
127    int8_t         reAssemTmr;           /* T_reassembling Timer in msec*/
128    int16_t        statProhTmr;          /* T_status_prohibit Timer in msec*/
129
130 }UlAmCfg;
131
132 typedef struct dlAmCfg
133 {
134    SnLenAm      snLenDl;             /* Sequence Number length in bits. Allowed values are 12 and 18 */
135    uint16_t     pollRetxTmr;         /* T_poll_retransmit Timer in msec */
136    int16_t      pollPdu;             /* Used to trigger a poll for every pollPdu.*/
137    int32_t      pollByte;            /* Poll_Byte in bytes. */
138    uint8_t      maxRetxTh;           /* Max_Retx_Threshold */
139
140 }DlAmCfg;
141
142 typedef struct dlUmCfg
143 {
144    SnLenUm        snLenDlUm;             /* Sequence Number length in bits. Allowed values are 6 and 12 */
145
146 }DlUmCfg;
147
148 typedef struct ulUmCfg
149 {
150    SnLenUm        snLenUlUm;             /* Sequence Number length in bits. Allowed values are 6 and 12 */
151    int8_t         reAssemTmr;            /* T_reassembling Timer in msec*/
152
153 }UlUmCfg;
154
155 typedef struct amBearerCfg
156 {
157    UlAmCfg  ulAmCfg;
158    DlAmCfg  dlAmCfg;
159 }AmBearerCfg;
160
161 typedef struct umBiDirBearerCfg
162 {
163    UlUmCfg  ulUmCfg;
164    DlUmCfg  dlUmCfg;
165 }UmBiDirBearerCfg;
166
167 typedef struct umUniDirUlBearerCfg
168 {
169    UlUmCfg  ulUmCfg;
170 }UmUniDirUlBearerCfg;
171
172 typedef struct umUniDirDlBearerCfg
173 {
174    DlUmCfg  dlUmCfg;
175 }UmUniDirDlBearerCfg;
176
177 /* Spec Ref: 38.331, 6.3.2 RLC-BearerConfig */
178 typedef struct rlcBearerCfg
179 {
180    ConfigType   configType;
181    uint8_t      rbId;
182    uint8_t      rbType;
183    uint8_t      lcId;
184    uint8_t      lcType;
185    Snssai       *snssai; 
186    RlcMode      rlcMode;
187    union
188    {
189       AmBearerCfg         *amCfg;
190       UmBiDirBearerCfg    *umBiDirCfg;
191       UmUniDirUlBearerCfg *umUniDirUlCfg;
192       UmUniDirDlBearerCfg *umUniDirDlCfg;
193    }u;
194 }RlcBearerCfg;
195
196 typedef struct rlcUeCfg
197 {
198    uint16_t     cellId;
199    uint8_t      ueIdx;
200    uint8_t      numLcs;
201    RlcBearerCfg rlcLcCfg[MAX_NUM_LC];
202    UeCfgState rlcUeCfgState; /* InActive / Completed */
203 }RlcUeCfg;
204
205 typedef struct rlcUeCfgRsp
206 {
207    uint16_t       cellId;
208    uint16_t       ueIdx;
209    RlcRsp         result;
210    FailureReason  reason;
211 }RlcUeCfgRsp;
212
213 typedef struct rlcUeDelete
214 {
215    uint16_t      cellId;
216    uint8_t       ueId;
217 }RlcUeDelete;
218
219 typedef struct rlcUeDeleteRsp
220 {
221    uint16_t       cellId;
222    uint8_t        ueId;
223    UeDeleteResult result;
224 }RlcUeDeleteRsp;
225
226 /* UL RRC Message from RLC to DU APP */
227 typedef struct ulRrcMsgInfo
228 {
229    uint16_t   cellId;       /* Cell Id */
230    uint16_t   ueIdx;        /* UE Index */
231    uint8_t    lcId;         /* Logical channel Id */
232    uint16_t   msgLen;       /* RRC message length (in bytes) */
233    uint8_t    *rrcMsg;      /* RRC Message (UL-DCCH Message) */
234 }RlcUlRrcMsgInfo;
235
236 /* UL User Data from RLC to DU APP */
237 typedef struct ulUserDatInfo
238 {
239    uint16_t   cellId;       /* Cell Id */
240    uint16_t   ueIdx;        /* UE Index */
241    uint8_t    rbId;
242    uint16_t   msgLen;       /* User data length (in bytes) */
243    uint8_t    *userData;    /* User data (UL-DTCH Message) */
244 }RlcUlUserDatInfo;
245
246 /* DL RRC Message from DU APP to RLC */
247 typedef struct dlRrcMsgInfo
248 {
249    uint16_t   cellId;         /* Cell Id */
250    uint16_t   ueIdx;          /* UE index */
251    uint8_t    rbType;         /* Radio Bearer Type */
252    uint8_t    rbId;           /* Radio Bearer Id */
253    uint8_t    lcType;         /* Logical channel type */
254    uint8_t    lcId;           /* Logical channel Id */
255    bool       execDup;        /* Execution duplication enabled */
256    bool       deliveryStaRpt;  /* Reporting of delivery status by RLC to DU-APP enabled */
257    uint16_t   msgLen;         /* RRC Message length */
258    uint8_t    *rrcMsg;        /* RRC Message (DL-DCCH Message) */
259 }RlcDlRrcMsgInfo;
260
261 /* DL RRC Message Rsp From RLC to DU APP */
262 typedef struct dlRrcMsgRsp
263 {
264    uint16_t   cellId;         /* Cell Id */
265    uint16_t   crnti;          /* UE index */
266    DlMsgState state;         /* Dl RRC Msg State */
267 }RlcDlRrcMsgRsp;
268
269 /* RRC delivery message from RLC to DU APP */
270 typedef struct rrcDeliveryStatus
271 {
272    uint16_t  deliveryStatus;
273    uint16_t  triggeringMessage;
274 }RrcDeliveryStatus;
275
276 typedef struct rrcDeliveryReportInfo
277 {
278    uint16_t  cellId;
279    uint16_t  ueIdx;
280    uint8_t   srbId;
281    RrcDeliveryStatus  rrcDeliveryStatus;
282 }RrcDeliveryReport;
283
284 /* DL Data Message from DU APP to RLC */
285 typedef struct dlDataMsgInfo
286 {
287    uint16_t   cellId;         /* Cell Id */
288    uint16_t   ueIdx;          /* UE index */
289    uint8_t    rbId;           /* Radio Bearer Id */
290    uint16_t   msgLen;         /* Message length */
291    Buffer     *dlMsg;         /* DL Data */
292 }RlcDlUserDataInfo;
293
294 /* Function Pointers */
295 /* UE create Request from DU APP to RLC*/
296 typedef uint8_t (*DuRlcUeCreateReq) ARGS((
297    Pst           *pst,
298    RlcUeCfg      *ueCfg ));
299
300 /* UE Cfg Response from RLC to DU APP*/
301 typedef uint8_t (*RlcDuUeCfgRsp) ARGS((
302    Pst          *pst,
303    RlcUeCfgRsp  *ueCfgRsp));
304
305 /* UE Delete Response from RLC to DU APP*/
306 typedef uint8_t (*RlcDuUeDeleteRsp) ARGS((
307    Pst          *pst,
308    RlcUeDeleteRsp  *ueDelRsp));
309
310 /* UL RRC Message from RLC to DU APP */
311 typedef uint8_t (*RlcUlRrcMsgToDuFunc) ARGS((
312    Pst           *pst,
313    RlcUlRrcMsgInfo *ulRrcMsgInfo));
314
315 /* DL RRC Message from DU APP to RLC */
316 typedef uint8_t (*DuDlRrcMsgToRlcFunc) ARGS((
317    Pst           *pst,
318    RlcDlRrcMsgInfo *dlRrcMsgInfo));
319
320 /* RRC delivery message from RLC to DU APP */
321 typedef uint8_t (*RlcRrcDeliveryReportToDuFunc) ARGS((
322    Pst           *pst,
323    RrcDeliveryReport *rrcDeliveryReport));
324
325 /* UE Reconfig Request from DU APP to RLC */
326 typedef uint8_t (*DuRlcUeReconfigReq) ARGS((
327    Pst           *pst,
328    RlcUeCfg      *ueCfg ));
329
330 /* UE Delete Request from DU APP to RLC */
331 typedef uint8_t (*DuRlcUeDeleteReq) ARGS((
332    Pst           *pst,
333    RlcUeDelete   *ueDelete));
334
335 /* DL RRC Message from RLC to DU APP */
336 typedef uint8_t (*RlcDlRrcMsgRspToDuFunc) ARGS((
337    Pst           *pst,
338    RlcDlRrcMsgRsp *dlRrcMsgRsp));
339
340 /* UL User data from RLC to DU APP */
341 typedef uint8_t (*RlcUlUserDataToDuFunc) ARGS((
342    Pst           *pst,
343    RlcUlUserDatInfo *ulUserData));
344
345 /* DL User Data from DU APP to RLC */
346 typedef uint8_t (*DuRlcDlUserDataToRlcFunc) ARGS((
347    Pst           *pst,
348    RlcDlUserDataInfo *dlDataMsg));
349
350 /* Pack/Unpack function declarations */
351 uint8_t packDuRlcUeCreateReq(Pst *pst, RlcUeCfg *ueCfg);
352 uint8_t unpackRlcUeCreateReq(DuRlcUeCreateReq func, Pst *pst, Buffer *mBuf);
353 uint8_t packRlcDuUeCfgRsp(Pst *pst, RlcUeCfgRsp *ueCfgRsp);
354 uint8_t unpackRlcUeCfgRsp(RlcDuUeCfgRsp func, Pst *pst, Buffer *mBuf);
355 uint8_t packRlcUlRrcMsgToDu(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo);
356 uint8_t unpackRlcUlRrcMsgToDu(RlcUlRrcMsgToDuFunc func, Pst *pst, Buffer *mBuf);
357 uint8_t packDlRrcMsgToRlc(Pst *pst, RlcDlRrcMsgInfo *dlRrcMsgInfo);
358 uint8_t unpackDlRrcMsgToRlc(DuDlRrcMsgToRlcFunc func, Pst *pst, Buffer *mBuf);
359 uint8_t packRrcDeliveryReportToDu(Pst *pst, RrcDeliveryReport *rrcDeliveryReport);
360 uint8_t unpackRrcDeliveryReportToDu(RlcRrcDeliveryReportToDuFunc func,Pst *pst, Buffer *mBuf);
361 uint8_t packDuRlcUeReconfigReq(Pst *pst, RlcUeCfg *ueCfg);
362 uint8_t unpackRlcUeReconfigReq(DuRlcUeReconfigReq func, Pst *pst, Buffer *mBuf);
363 uint8_t packRlcDlRrcMsgRspToDu(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsgRsp);
364 uint8_t unpackRlcDlRrcMsgRspToDu(RlcDlRrcMsgRspToDuFunc func, Pst *pst, Buffer *mBuf);
365 uint8_t packRlcUlUserDataToDu(Pst *pst, RlcUlUserDatInfo *ulUserData);
366 uint8_t unpackRlcUlUserDataToDu(RlcUlUserDataToDuFunc func, Pst *pst, Buffer *mBuf);
367 uint8_t packRlcDlUserDataToRlc(Pst *pst, RlcDlUserDataInfo *dlDataMsg);
368 uint8_t unpackRlcDlUserDataToRlc(DuRlcDlUserDataToRlcFunc func, Pst *pst, Buffer *mBuf);
369 uint8_t packDuRlcUeDeleteReq(Pst *pst, RlcUeDelete *ueDelete);
370 uint8_t unpackRlcUeDeleteReq(DuRlcUeDeleteReq func, Pst *pst, Buffer *mBuf);
371 uint8_t packRlcDuUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *ueDeleteRsp);
372 uint8_t unpackRlcUeDeleteRsp(RlcDuUeDeleteRsp func, Pst *pst, Buffer *mBuf);
373
374 /* Event Handler function declarations */
375 uint8_t RlcProcUeCreateReq(Pst *pst, RlcUeCfg *ueCfg);
376 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp);
377 uint8_t DuProcRlcUlRrcMsgTrans(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo);
378 uint8_t RlcProcDlRrcMsgTransfer(Pst *pst, RlcDlRrcMsgInfo *dlRrcMsgInfo);
379 uint8_t DuProcRlcRrcDeliveryReport(Pst *pst, RrcDeliveryReport *rrcDeliveryReport);
380 uint8_t RlcProcUeReconfigReq(Pst *pst, RlcUeCfg *ueCfg);
381 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg);
382 uint8_t DuProcRlcUlUserDataTrans(Pst *pst, RlcUlUserDatInfo *ulUserData);
383 uint8_t RlcProcDlUserDataTransfer(Pst *pst, RlcDlUserDataInfo *dlDataMsgInfo);
384 uint8_t RlcProcUeDeleteReq(Pst *pst, RlcUeDelete *ueDelete);
385 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp);
386 #endif /* RLC_INF_H */
387
388 /**********************************************************************
389          End of file
390 **********************************************************************/