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