Modify licenses
[scp/ocu/5gnr.git] / Include / pdcpu.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 PDCP_U_H
21 #define PDCP_U_H
22
23 #include "vos_linklist.h"
24 #include "pdcpCommon.h"
25 #include "msgb.h"
26 #include "cuupCommon.h"
27 #include "cuModuleCommon.h"
28 #include "plat_syslog.h"
29
30 #define PROFILE0X0001_PRENSENT 0x0001
31 #define PROFILE0X0002_PRENSENT 0x0002
32 #define PROFILE0X0003_PRENSENT 0x0004
33 #define PROFILE0X0004_PRENSENT 0x0008
34 #define PROFILE0X0006_PRENSENT 0x0010
35 #define PROFILE0X0101_PRENSENT 0x0020
36 #define PROFILE0X0102_PRENSENT 0x0040
37 #define PROFILE0X0103_PRENSENT 0x0080
38 #define PROFILE0X0104_PRENSENT 0x0100
39
40 #define pdcpuLog(iLog_Level, content, arg...) \
41         VOS_SysLog(gPdcpuModuleId, iLog_Level, __FILE__, __LINE__, __func__, content, ##arg);
42
43 #define pdcpuNullCheck(p) \
44 {\
45    if(NULL == p)\
46    {\
47            pdcpuLog(LOG_ERR,"[PDCPU] NULL pointer\n");\
48        return VOS_ERROR;\
49    }\
50 }
51
52 #define pdcpuNullCheckRp(p) \
53 {\
54    if(NULL == p)\
55    {\
56            pdcpuLog(LOG_ERR,"[PDCPU] NULL pointer\n");\
57        return NULL;\
58    }\
59 }
60
61
62 #define pdcpuCheckUeIdx(n) if(n<0 || n>MAX_UE_NUM) {pdcpuLog(LOG_ERR,#n" is wrong\r\n");return VOS_ERROR;}
63 #define pdcpuCheckDrbId(n) if(n<1 || n>MAX_DRB_ID) {pdcpuLog(LOG_ERR,#n":%d is wrong\r\n");return VOS_ERROR;}
64 #define pdcpuCheckPduSessionId(n) if(n<0 || n>255) {pdcpuLog(LOG_ERR,#n" is wrong\r\n");return VOS_ERROR;}
65
66 #define pdcpuGetEntity(ueIdx, drbId, p)\
67 {\
68         if((NULL==gPdcpuUeInfo[ueIdx])\
69                 ||(NULL==gPdcpuUeInfo[ueIdx]->pdcpDrbEntity[drbId]))\
70         {\
71                 p = NULL;\
72         }else\
73         {\
74                 p = gPdcpuUeInfo[ueIdx]->pdcpDrbEntity[drbId];\
75         }\
76 }
77
78 #define pdcpuMsgbFree(p)\
79 {\
80         if(NULL != p)\
81         {\
82                 msgbFree(p);\
83                 p = NULL;\
84         }\
85 }
86
87 typedef struct
88 {
89         UINT16  pduSessionId;
90         UINT8  integrityEnableFlag;
91         UINT8  cipherEnableFlag;
92         UINT64 maxIPDataRate;   /* Maximum Integrity Protected Data Rate */
93 }PdcpuSecEnableInfo_t;
94
95
96 typedef enum
97 {
98         NEW_PACKET = 0,
99         OLD_PACKET
100 }PdcpTxNodeType_e;
101
102 typedef enum
103 {
104         PDCP_DISCARD_TIMER = 1,
105         PDCP_REORDER_TIMER
106 }PdcpTimer_e;
107
108
109 typedef struct
110 {
111         UINT32                  count;
112         UINT32                  f1uSn;          /* Not used in receiving buffer */
113         MsgbBuff_t     *pData;
114         UINT8               flag;
115     struct timeval      startTime;
116 }PdcpuDataBuffNode_t;
117
118
119 typedef struct
120 {
121     UINT16                              notUsed;
122         RohcParaPR_e            rohcType;
123     union
124     {
125                 ROHCConfig_t     rohcConfig;
126                 UplinkOnlyRohc_t uplinkOnlyRohc;
127     }u;
128 }HeaderCompression_t;
129
130 typedef struct
131 {
132         UINT8                                   drbId;
133         UINT16                                  pduSessionId;
134         UINT64                                  ueE1apId;
135         UINT16                                  ueIdx;
136         UINT32                                  rlcState;
137         PdcpRlcMode_e                   rlcMode;
138         UINT8                                   sdapUlHeadLen;
139         UINT8                                   sdapDlHeadLen;
140     PdcpSnSize_e                        pdcpSnSizeUl;
141     PdcpSnSize_e                        pdcpSnSizeDl;
142     HeaderCompression_t         headerCompress;
143
144         UINT8                                   tDiscardActive;                 /* TRUE/FALSE */
145         UINT8                                   tDiscardRun;                    /* TRUE/FALSE */
146         UINT16                                  tDiscard;                               /* ms */
147         ModuleMsg_t                     *pDiscardMsg;
148
149         UINT8                                   tReorderActive;                 /* TRUE/FALSE */
150         UINT8                                   tReorderRun;                    /* TRUE/FALSE */
151         UINT16                                  tReorder;                               /* ms */
152         ModuleMsg_t                     *pReorderMsg;
153         LONG                                    tReorderId;
154
155     MoreThanOneRLCContext       moreThanOneRLCContext;
156     UINT8                                       integrityProtection;    /* TRUR: used, FALSE: not used */
157     UINT8                                       outOfOrderDelivery;
158         UINT8                                   ciperingEnabled;                /* TRUR: used, FALSE: not used */
159         PdcpStateVar_t                  stateVar;
160
161         plist                                   pTxPduList;                             /* transmitting buffer */
162         ULONG                                   txListLock;                             /* txListLock */
163
164         plist                                   pRxSduList;                             /* receiving buffer        */
165         ULONG                                   rxListLock;                             /* rxListLock */
166 }PdcpDrbEntity_t;
167
168 typedef struct
169 {
170         UINT64  ueE1apId;
171         UINT16  ueIdx;
172         UINT32  kUpEnc[4];                      /* 128 bit */
173         UINT32  kUpInt[4];                      /* 128 bit */
174         UINT32  nh[8];                          /* Next Hop parameter 256 bit */
175         UINT8   ncc;                            /* maximum: 3bit */
176         UINT8   encAlgorithm;           /* Encryption Algorithm */
177         UINT8   intAlgorithm;           /* Integrity Algorithm */
178         UINT8   encActiveFlag;          /* define whether the encryption function has been activated */
179         UINT8   intActiveFlag;          /* define whether the integrity protection function has been activated */
180         UINT8   nhInd;                          /* 1: nh existed 0: not existed */
181 }PdcpuSecInfo_t;
182
183 typedef struct
184 {
185         UINT16                            ueIdx;
186         CuupBearerStatus_e        ueStatus;
187         PdcpuSecInfo_t           *secInfo;
188         PdcpuSecEnableInfo_t *secEnableInfo[CUUP_MAX_SESSION_NUM];
189         PdcpDrbEntity_t          *pdcpDrbEntity[MAX_DRB_NUM];
190 }PdcpuUeInfo_t;
191
192 typedef struct
193 {
194         UINT16          ueIdx;
195         UINT8           drbId;
196 }PdcpuDrbIdx_t;
197
198
199 #endif /* PDCP_U_H */