Modify licenses
[scp/ocu/5gnr.git] / Include / pdcpCommon.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2020 ICT/CAS.
4 *
5 *   Licensed under the O-RAN Software License, Version 1.0 (the "Software 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 *       https://www.o-ran.org/software
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
20 #ifndef NR_PDCP_COMMON_H
21 #define NR_PDCP_COMMON_H
22
23 #include "vos_types.h"
24 #include "vos_linklist.h"
25 #include "vos_lib.h"
26 #include "gnbCommon.h"
27
28
29 #define FALSE                                                   0
30 #define TRUE                                                    1
31 #define PDCP_INFINITY                                   1
32 #define PDCP_DISCARD_TIMER_INFINITY     2
33 #define ROHC_BUFFER_SIZE                         8096//1024
34 #define PDCP_MAC_I_LEN                                  4
35 #define PDCP_SN_12_HEAD_LEN                     2
36 #define PDCP_SN_18_HEAD_LEN                     3
37 #define MAX_PDCP_SN_12                     0x1000
38 #define MAX_PDCP_SN_18                    0x40000
39 #define SN_12_WINDOW_SIZE                        2048
40 #define SN_18_WINDOW_SIZE                  131072
41 #define REORDER_TIMER_NUM                          36
42 #define DISCARD_TIMER_NUM                          15
43
44
45 // TODO: the number of node is not sure yet
46 #define PDCP_MAX_NODE_NUM       10
47 #define PDCP_SPARED             -1
48
49 /* for ciphering */
50 #define INACTIVE_ENC_STATE              0
51 #define ACTIVE_ENC_STATE                1
52 #define MIDDLE_ENC_STATE                3       /* for srb */
53
54 /* for ciphering */
55 #define INACTIVE_INT_STATE              0
56 #define ACTIVE_INT_STATE                1
57
58
59 typedef plist pdcpcList;
60
61 #if 0
62 typedef UINT8  PdcpSrbId;
63 typedef UINT16 PdcpUeIdx;
64 typedef UINT8  PdcpCellId;
65 #endif
66
67 typedef UINT8 PdcpBool_t;
68
69 /* the type of RB */
70 typedef enum
71 {
72         SRB = 0,
73         DRB = 1
74 }RbType;
75
76
77 /* the direction of data transmission */
78 typedef enum
79 {
80         UPLINK          = 0,
81         DOWNLINK        = 1
82 }PdcpDirection_e;
83
84
85 /* pdcp pdu type */
86 typedef enum
87 {
88         PDCP_CTRL_PDU = 0,                      /* control pdu */
89         PDCP_DATA_PDU = 1                       /* data pdu */
90 }PdcpPduType_e;
91
92
93 /* pdcp control pdu type */
94 typedef enum
95 {
96         PDCP_CTRL_PDU_SR = 0,           /*status report*/
97         PDCP_CTRL_PDU_RF = 1,           /*rohc feedback*/
98         PDCP_CTRL_PDU_RESERVED1 = 2,
99         PDCP_CTRL_PDU_RESERVED2 = 3,
100         PDCP_CTRL_PDU_RESERVED3 = 4,
101         PDCP_CTRL_PDU_RESERVED4 = 5,
102         PDCP_CTRL_PDU_RESERVED5 = 6,
103         PDCP_CTRL_PDU_RESERVED6 = 7
104 }PdcpCtrlPduType_e;
105
106
107 /* integrity algorithm */
108 typedef enum
109 {
110     NIA0 = 0,
111     NIA1 = 1,
112     NIA2 = 2,
113     NIA3 = 3,
114     INT_SPARE4 = 4,
115     INT_SPARE3 = 5,
116     INT_SPARE2 = 6,
117     INT_SPARE1 = 7
118 }IntAlgorithm;
119
120
121 /* ciphering algorithm */
122 typedef enum
123 {
124         NEA0 = 0,
125         NEA1 = 1,
126         NEA2 = 2,
127         NEA3 = 3,
128         CIP_SPARE4 = 4,
129         CIP_SPARE3 = 5,
130         CIP_SPARE2 = 6,
131         CIP_SPARE1 = 7
132 }CipAlgorithm;
133
134
135 #if 0
136 /* For all srbs and drbs per ue */
137 typedef struct{
138         UINT32  k_gnb[8];                       /* 256 bit */
139         UINT32  k_up_enc[4];            /* 128 bit */
140         UINT32  k_cp_enc[4];            /* 128 bit */
141         UINT32  k_up_int[4];            /* 128 bit */
142         UINT32  k_cp_int[4];            /* 128 bit */
143         UINT32  nh[8];                          /* Next Hop parameter 256 bit */
144         UINT8   ncc;                            /* maximum: 3bit */
145         UINT8   enc_algorithm;          /* Encryption Algorithm */
146         UINT8   int_algorithm;          /* Integrity Algorithm */
147         UINT8   enc_active_flag;        /* define whether the encryption function has been activated */
148         UINT8   int_active_flag;        /* define whether the integrity protection function has been activated */
149         UINT8   nh_ind;                         /* 1: nh existed 0: not existed */
150 } UeSecurityParams;
151 #endif
152
153 typedef enum {
154     DISCARD_MS10 = 10,
155     DISCARD_MS20 = 20,
156     DISCARD_MS30 = 30,
157     DISCARD_MS40 = 40,
158     DISCARD_MS50 = 50,
159     DISCARD_MS60 = 60,
160     DISCARD_MS75 = 75,
161     DISCARD_MS100 = 100,
162     DISCARD_MS150 = 150,
163     DISCARD_MS200 = 200,
164     DISCARD_MS250 = 250,
165     DISCARD_MS300 = 300,
166     DISCARD_MS500 = 500,
167     DISCARD_MS750 = 750,
168     DISCARD_MS1500 = 1500,
169     DISCARD_INFINITY = PDCP_DISCARD_TIMER_INFINITY
170 }DISCARD_TIMER;
171
172
173 typedef enum{
174     LEN12BITS = 12,
175     LEN18BITS = 18
176 }PdcpSnSize_e;
177
178
179 typedef enum pdcpRlcMode
180 {
181         TM_MODE = 1,            /*!< RLC TM Mode */
182         UM_MODE,                        /*!< RLC UM Mode */
183         AM_MODE,                        /*!< RLC AM Mode */
184 }PdcpRlcMode_e;
185
186
187 typedef struct{
188     PdcpBool_t profile0x0001;
189     PdcpBool_t profile0x0002;
190     PdcpBool_t profile0x0003;
191     PdcpBool_t profile0x0004;
192     PdcpBool_t profile0x0005;
193     PdcpBool_t profile0x0006;
194     PdcpBool_t profile0x0101;
195     PdcpBool_t profile0x0102;
196     PdcpBool_t profile0x0103;
197     PdcpBool_t profile0x0104;
198 }ROHCProfiles_t;
199
200 typedef struct{
201     UINT16 maxCID;
202     ROHCProfiles_t rohcProfiles;
203 }ROHCConfig_t;
204
205 typedef struct{
206     UINT16 maxCID;
207     PdcpBool_t profile0x0006;
208 }UplinkOnlyRohc_t;
209
210
211 typedef struct{
212     UINT16 cellGroupID;
213     UINT8  lcID;
214 }PrimaryPath;
215
216 typedef enum{
217     B0 = 0,
218     B100 = 100,
219     B200 = 200,
220     B400 = 400,
221     B800 = 800,
222     B1600 = 1600,
223     B3200 = 3200,
224     B6400 = 6400,
225     B12800 = 12800,
226     B51200 = 51200,
227     B102400 = 102400,
228     B204800 = 204800,
229     B409600 = 409600,
230     B819200 = 819200,
231     B1228800 = 1228800,
232     B1638400 = 1638400,
233     B2457600 = 2457600,
234     B3276800 = 3276800,
235     B4096000 = 4096000,
236     B4915200 = 4915200,
237     B5734400 = 5734400,
238     B6553600 = 6553600,
239     INFINITY = PDCP_INFINITY,
240     SPARE8 = PDCP_SPARED,
241     SPARE7 = PDCP_SPARED,
242     SPARE6 = PDCP_SPARED,
243     SPARE5 = PDCP_SPARED,
244     SPARE4 = PDCP_SPARED,
245     SPARE3 = PDCP_SPARED,
246     SPARE2 = PDCP_SPARED,
247     SPARE1 = PDCP_SPARED
248 }ULSPILT_THRESHOLD;
249
250 typedef struct{
251     UINT16 release;
252     ULSPILT_THRESHOLD ulspiltThreshold;
253 }UlDataSplitThreshold;
254
255 typedef struct{
256     PrimaryPath primaryPath;
257     UlDataSplitThreshold ulDataSplitThreshold;
258     PdcpBool_t duplication;
259 }MoreThanOneRLCContext;
260
261 typedef enum{
262         REORDER_MS0 = 0,
263         REORDER_MS1 = 1,
264         REORDER_MS2 = 2,
265         REORDER_MS4 = 4,
266         REORDER_MS5 = 5,
267         REORDER_MS8 = 8,
268         REORDER_MS10 = 10,
269         REORDER_MS15 = 15,
270         REORDER_MS20 = 20,
271         REORDER_MS30 = 30,
272         REORDER_MS40 = 40,
273         REORDER_MS50 = 50,
274         REORDER_MS60 = 60,
275         REORDER_MS80 = 80,
276         REORDER_MS100 = 100,
277         REORDER_MS120 = 120,
278         REORDER_MS140 = 140,
279         REORDER_MS160 = 160,
280         REORDER_MS180 = 180,
281         REORDER_MS200 = 200,
282         REORDER_MS220 = 220,
283         REORDER_MS240 = 240,
284         REORDER_MS260 = 260,
285         REORDER_MS280 = 280,
286         REORDER_MS300 = 300,
287         REORDER_MS500 = 500,
288         REORDER_MS750 = 750,
289         REORDER_MS1000 = 1000,
290         REORDER_MS1250 = 1250,
291         REORDER_MS1500 = 1500,
292         REORDER_MS1750 = 1750,
293         REORDER_MS2000 = 2000,
294         REORDER_MS2250 = 2250,
295         REORDER_MS2500 = 2500,
296         REORDER_MS2750 = 2750,
297         REORDER_MS3000 = 3000,
298         REORDER_SPARE28 = PDCP_SPARED,
299         REORDER_SPARE27 = PDCP_SPARED,
300         REORDER_SPARE26 = PDCP_SPARED,
301         REORDER_SPARE25 = PDCP_SPARED,
302         REORDER_SPARE24 = PDCP_SPARED,
303         REORDER_SPARE23 = PDCP_SPARED,
304         REORDER_SPARE22 = PDCP_SPARED,
305         REORDER_SPARE21 = PDCP_SPARED,
306         REORDER_SPARE20 = PDCP_SPARED,
307         REORDER_SPARE19 = PDCP_SPARED,
308         REORDER_SPARE18 = PDCP_SPARED,
309         REORDER_SPARE17 = PDCP_SPARED,
310         REORDER_SPARE16 = PDCP_SPARED,
311         REORDER_SPARE15 = PDCP_SPARED,
312         REORDER_SPARE14 = PDCP_SPARED,
313         REORDER_SPARE13 = PDCP_SPARED,
314         REORDER_SPARE12 = PDCP_SPARED,
315         REORDER_SPARE11 = PDCP_SPARED,
316         REORDER_SPARE10 = PDCP_SPARED,
317         REORDER_SPARE09 = PDCP_SPARED,
318         REORDER_SPARE08 = PDCP_SPARED,
319         REORDER_SPARE07 = PDCP_SPARED,
320         REORDER_SPARE06 = PDCP_SPARED,
321         REORDER_SPARE05 = PDCP_SPARED,
322         REORDER_SPARE04 = PDCP_SPARED,
323         REORDER_SPARE03 = PDCP_SPARED,
324         REORDER_SPARE02 = PDCP_SPARED,
325         REORDER_SPARE01 = PDCP_SPARED
326 }PDCP_TREORDERING;
327
328 typedef struct{
329         UINT32 rxCount;         /* count value calculated of per data packet */
330     UINT32 txNext;
331     UINT32 rxDelivery;
332     UINT32 rxNext;
333     UINT32 rxReorder;
334 }PdcpStateVar_t;
335
336
337 typedef struct{
338
339 }ROHCCompressor;
340
341 typedef struct{
342
343 }ROHCDecompressor;
344
345
346 /* get sn value when sn size is 12 bits */
347 #define GET_SN_12_SN(p)  ((p) & 0x00000fff)
348
349 /* get sn value when sn size is 18 bits */
350 #define GET_SN_18_SN(p)  ((p) & 0x0003ffff)
351
352 /* get hfn value when sn size is 12 bits */
353 #define GET_HFN_12_SN(p) (((p) & 0xfffff000) >> 12)
354
355 /* get hfn value when sn size is 18 bits */
356 #define GET_HFN_18_SN(p) (((p) & 0xfffc0000) >> 18)
357
358 /* get count value when sn size is 12 bits */
359 #define GET_COUNT_12_SN(a,b)  ((((a) & 0x000fffff)<<12)|((b) & 0x00000fff))
360
361 /* get count value when sn size is 18 bits */
362 #define GET_COUNT_18_SN(a,b)  ((((a) & 0x00003fff)<<18)|((b) & 0x00003ffff))
363
364
365
366
367 #endif /* NR_PDCP_COMMON_H */