Committing in PDCP code
[o-du/l2.git] / src / 5gnrpdcp / pj_sec.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  #include "prc_types.h"
20 /* lenghth of the pointer variable */
21 #define BC_ICPU_MSG_LEN  sizeof(BcIcpuMsg)
22 #define BC_LOCAL_REG     0
23 #define BC_SHARED_REG    1
24 #define BC_ICPU_MSG_NOR  0
25 #define BC_ICPU_MSG_FREE 1
26
27 #define BC_MAX_PDU_CIPHER_REQ 1
28 #define BC_MAX_PDU_INTPROT_REQ 1
29 #define BC_MAX_CPU 2
30
31
32 #define PJ_SEC_ALLOC(_cb, _buf, _size)                         \
33 {                                                          \
34  if (SGetSBuf(1,0, (Data **)&_buf,\
35                 (Size) _size) == ROK)                      \
36    {                                                       \
37       cmMemset((U8 *)(_buf), 0, _size);                    \
38    }                                                       \
39    else                                                    \
40    {                                                       \
41       (_buf) = NULLP;                                      \
42    }                                                       \
43 }
44 typedef struct intProtCallBkParams
45 {
46    PRC_SNOW_INTEGRITY_PARAMS *intgrtyParams;
47    U32                       numPdu;
48    PRC_SNOW_INTEGRITY_DATA   *pdu_list;
49    PjLibTrans                libTrans; 
50    Pst                    *pst;
51    Buffer                 *pduInfoBuffer;
52    Buffer                 *pduListBuffer;
53 }IntProtCallBkParams;
54 typedef struct intVerCallBkParams
55 {
56    PRC_SNOW_INTEGRITY_PARAMS *intgrtyParams;
57    U32                       numPdu;
58    PRC_SNOW_INTEGRITY_DATA   *pdu_list;
59    PjLibTrans                libTrans; 
60    Pst                    *pst;
61    Buffer                 *pduInfoBuffer;
62    Buffer                 *pduListBuffer;
63    U32                    recvMacI;
64 }IntVerCallBkParams;
65
66 #ifdef CIPH_BATCH_PROC
67 typedef struct pjTxEntDtl {
68   void   *txEnt;
69   void  *rbCb;
70 }PjTxEntDtl;
71
72 typedef struct pjRxEntDtl {
73   void   *rxEnt;
74   void  *rbCb;
75 }PjRxEntDtl;
76 #endif
77 typedef struct cipherCallBkParams
78 {
79 #ifdef CIPH_BATCH_PROC
80    Data                  *cipheredBuf[32];
81    PjTxEnt                *txEntLst[32];      
82    PjRxEnt                *rxEntLst[32];      
83    PRC_SNOW_CIPHER_DATA *pduList;
84 #else
85    PRC_SNOW_CIPHER_DATA   *pdu_list;
86    PjLibTrans             libTrans; 
87    Buffer                 *mBuf[10];
88    Buffer                 *pduInfoBuffer;
89    Buffer                 *pduListBuffer;
90    Pst                    *pst;
91 #endif
92    U32                    numTxPdu;
93    U32                    numRxPdu;
94    PRC_SNOW_CIPHER_PARAMS *cipherParams;
95 }CipherCallBkParams;
96
97 /* ZUC_ALGO start */
98 typedef struct zucIntProtCallBkParams
99 {
100    PRC_ZUC_INTEGRITY_PARAMS *intgrtyParams;
101    U32                       numPdu;
102    PRC_ZUC_INTEGRITY_DATA   *pdu_list;
103    PjLibTrans                libTrans; 
104    Pst                    *pst;
105    Buffer                 *pduInfoBuffer;
106    Buffer                 *pduListBuffer;
107 }ZucIntProtCallBkParams;
108
109 typedef struct zucIntVerCallBkParams
110 {
111    PRC_ZUC_INTEGRITY_PARAMS *intgrtyParams;
112    U32                       numPdu;
113    PRC_ZUC_INTEGRITY_DATA   *pdu_list;
114    PjLibTrans                libTrans; 
115    Pst                    *pst;
116    Buffer                 *pduInfoBuffer;
117    Buffer                 *pduListBuffer;
118    U32                    recvMacI;
119 }ZucIntVerCallBkParams;
120
121 typedef struct zucEncryptCallBkParams
122 {
123 #ifdef CIPH_BATCH_PROC
124    Data                  *encryptBuf[32];
125    PjTxEnt                *txEntLst[32];      
126    PjRxEnt                *rxEntLst[32];
127    PRC_ZUC_ENCRYPTION_DATA  *pduList;      
128 #else
129    PRC_ZUC_ENCRYPTION_DATA   *pdu_list;
130    PjLibTrans             libTrans; 
131    Buffer                 *mBuf[10];
132    Buffer                 *pduInfoBuffer;
133    Buffer                 *pduListBuffer;
134    Pst                    *pst;
135 #endif
136    U32                    numTxPdu;
137    U32                    numRxPdu;
138    PRC_ZUC_ENCRYPTION_PARAMS *encryptParams;
139 }ZucEncryptCallBkParams;
140 /* ZUC_ALGO - end */
141
142 #ifdef AES
143 typedef struct aesIntProtCallBkParams
144 {
145    PRC_AES_INTEGRITY_PARAMS *intgrtyParams;
146    U32                       numPdu;
147    PRC_AES_INTEGRITY_DATA   *pdu_list;
148    PjLibTrans                libTrans; 
149    Pst                    *pst;
150    Buffer                 *pduInfoBuffer;
151    Buffer                 *pduListBuffer;
152 }AesIntProtCallBkParams;
153
154 typedef struct aesIntVerCallBkParams
155 {
156    PRC_AES_INTEGRITY_PARAMS *intgrtyParams;
157    U32                       numPdu;
158    PRC_AES_INTEGRITY_DATA   *pdu_list;
159    PjLibTrans                libTrans; 
160    Pst                    *pst;
161    Buffer                 *pduInfoBuffer;
162    Buffer                 *pduListBuffer;
163    U32                    recvMacI;
164 }AesIntVerCallBkParams;
165
166 typedef struct aesEncryptCallBkParams
167 {
168 #ifdef CIPH_BATCH_PROC
169    Data                  *encryptBuf[32];
170    PjTxEnt                *txEntLst[32];      
171    PjRxEnt                *rxEntLst[32];
172    PRC_AES_ENCRYPTION_DATA  *pduList;      
173 #else
174    PRC_AES_ENCRYPTION_DATA   *pdu_list;
175    PjLibTrans             libTrans; 
176    Buffer                 *mBuf[10];
177    Buffer                 *pduInfoBuffer;
178    Buffer                 *pduListBuffer;
179    Pst                    *pst;
180 #endif
181    U32                    numTxPdu;
182    U32                    numRxPdu;
183    PRC_AES_ENCRYPTION_PARAMS *encryptParams;
184 }AesEncryptCallBkParams;
185 #endif /* AES */
186
187 #ifdef CIPH_BATCH_PROC
188 typedef struct deCipherCallBkParams
189 {
190    U32                    numPdu;
191    PjRxEnt                *rxEntLst[32];      
192    //Buffer                 *deCipheredBuf[16];
193    PRC_SNOW_CIPHER_DATA *pduList;
194    PRC_SNOW_CIPHER_PARAMS *deCipherParams;
195 }DecipherCallBkParams;
196
197 typedef struct decryptCallBkParams
198 {
199    U32                    numPdu;
200    PjRxEnt                *rxEntLst[32];      
201    //Buffer                 *deCipheredBuf[16];
202    PRC_ZUC_ENCRYPTION_DATA *pduList;
203    PRC_ZUC_ENCRYPTION_PARAMS *decryptParams;
204 }DecryptCallBkParams;
205
206 #ifdef AES
207 typedef struct decryptAesCallBkParams
208 {
209    U32                    numPdu;
210    PjRxEnt                *rxEntLst[32];      
211    //Buffer                 *deCipheredBuf[16];
212    PRC_AES_ENCRYPTION_DATA *pduList;
213    PRC_AES_ENCRYPTION_PARAMS *decryptParams;
214 }DecryptAesCallBkParams;
215 #endif
216 #endif
217
218 #ifdef PJ_INT_ASYNC
219 extern  S16 pjUtlIntProtCallBk ARGS((
220 U32 rc, 
221 Void* callback_params
222 ));
223 extern  S16 pjUtlIntVerCallBk ARGS((
224 U32 rc, 
225 Void* callback_params
226 ));
227
228
229 extern S16 bcIntProtReq ARGS((
230 Pst       *pst,
231 PjSecInp   secInp,                  /* Input for Integrity protection */
232 PjLibTrans libTrans,
233 Buffer     *mBuf                  /* SDU to be compressed */
234 ));
235 #else
236 extern S16 bcIntProtReq ARGS((
237 PjSecInp   secInp,                  /* Input for Integrity protection */
238 PjDlUeCb *ueCb,
239 Buffer     *mBuf,                  /* SDU to be compressed */
240 U32        *macI                   /* Message authentication code for the SDU */
241 ));
242 #endif
243
244 extern S16 pjUtlCipherCallBk ARGS((U32 rc, Void* callback_params));
245 #ifdef CIPH_BATCH_PROC
246 extern S16 pjUtlBatchCipherCallBk ARGS((U32 rc, Void* callback_params));
247 #endif
248