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