c10ec100756d8ef073a5f683587f9cc4da3d410a
[dpdk.git] / drivers / crypto / dpaa_sec / dpaa_sec.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  *   Copyright 2016 NXP
4  *
5  */
6
7 #ifndef _DPAA_SEC_H_
8 #define _DPAA_SEC_H_
9
10 #define CRYPTODEV_NAME_DPAA_SEC_PMD     crypto_dpaa_sec
11 /**< NXP DPAA - SEC PMD device name */
12
13 #define MAX_DPAA_CORES          4
14 #define NUM_POOL_CHANNELS       4
15 #define DPAA_SEC_BURST          7
16 #define DPAA_SEC_ALG_UNSUPPORT  (-1)
17 #define TDES_CBC_IV_LEN         8
18 #define AES_CBC_IV_LEN          16
19 #define AES_CTR_IV_LEN          16
20 #define AES_GCM_IV_LEN          12
21
22 #define DPAA_IPv6_DEFAULT_VTC_FLOW      0x60000000
23
24 /* Minimum job descriptor consists of a oneword job descriptor HEADER and
25  * a pointer to the shared descriptor.
26  */
27 #define MIN_JOB_DESC_SIZE       (CAAM_CMD_SZ + CAAM_PTR_SZ)
28 /* CTX_POOL_NUM_BUFS is set as per the ipsec-secgw application */
29 #define CTX_POOL_NUM_BUFS       32000
30 #define CTX_POOL_BUF_SIZE       sizeof(struct dpaa_sec_op_ctx)
31 #define CTX_POOL_CACHE_SIZE     512
32 #define RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS 1024
33
34 #define DIR_ENC                 1
35 #define DIR_DEC                 0
36
37 enum dpaa_sec_op_type {
38         DPAA_SEC_NONE,  /*!< No Cipher operations*/
39         DPAA_SEC_CIPHER,/*!< CIPHER operations */
40         DPAA_SEC_AUTH,  /*!< Authentication Operations */
41         DPAA_SEC_AEAD,  /*!< AEAD (AES-GCM/CCM) type operations */
42         DPAA_SEC_CIPHER_HASH,  /*!< Authenticated Encryption with
43                                 * associated data
44                                 */
45         DPAA_SEC_HASH_CIPHER,  /*!< Encryption with Authenticated
46                                 * associated data
47                                 */
48         DPAA_SEC_IPSEC, /*!< IPSEC protocol operations*/
49         DPAA_SEC_PDCP,  /*!< PDCP protocol operations*/
50         DPAA_SEC_PKC,   /*!< Public Key Cryptographic Operations */
51         DPAA_SEC_MAX
52 };
53
54 #define DPAA_SEC_MAX_DESC_SIZE  64
55 /* code or cmd block to caam */
56 struct sec_cdb {
57         struct {
58                 union {
59                         uint32_t word;
60                         struct {
61 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
62                                 uint16_t rsvd63_48;
63                                 unsigned int rsvd47_39:9;
64                                 unsigned int idlen:7;
65 #else
66                                 unsigned int idlen:7;
67                                 unsigned int rsvd47_39:9;
68                                 uint16_t rsvd63_48;
69 #endif
70                         } field;
71                 } __packed hi;
72
73                 union {
74                         uint32_t word;
75                         struct {
76 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
77                                 unsigned int rsvd31_30:2;
78                                 unsigned int fsgt:1;
79                                 unsigned int lng:1;
80                                 unsigned int offset:2;
81                                 unsigned int abs:1;
82                                 unsigned int add_buf:1;
83                                 uint8_t pool_id;
84                                 uint16_t pool_buffer_size;
85 #else
86                                 uint16_t pool_buffer_size;
87                                 uint8_t pool_id;
88                                 unsigned int add_buf:1;
89                                 unsigned int abs:1;
90                                 unsigned int offset:2;
91                                 unsigned int lng:1;
92                                 unsigned int fsgt:1;
93                                 unsigned int rsvd31_30:2;
94 #endif
95                         } field;
96                 } __packed lo;
97         } __packed sh_hdr;
98
99         uint32_t sh_desc[DPAA_SEC_MAX_DESC_SIZE];
100 };
101 #ifdef RTE_LIBRTE_SECURITY
102 /*!
103  * The structure is to be filled by user as a part of
104  * dpaa_sec_proto_ctxt for PDCP Protocol
105  */
106 struct sec_pdcp_ctxt {
107         enum rte_security_pdcp_domain domain; /*!< Data/Control mode*/
108         int8_t bearer;  /*!< PDCP bearer ID */
109         int8_t pkt_dir;/*!< PDCP Frame Direction 0:UL 1:DL*/
110         int8_t hfn_ovd;/*!< Overwrite HFN per packet*/
111         uint8_t sn_size;        /*!< Sequence number size, 5/7/12/15/18 */
112         uint32_t hfn_ovd_offset;/*!< offset from rte_crypto_op at which
113                                  * per packet hfn is stored
114                                  */
115         uint32_t hfn;   /*!< Hyper Frame Number */
116         uint32_t hfn_threshold; /*!< HFN Threashold for key renegotiation */
117 };
118 #endif
119 typedef struct dpaa_sec_session_entry {
120         uint8_t dir;         /*!< Operation Direction */
121         uint8_t ctxt;   /*!< Session Context Type */
122         enum rte_crypto_cipher_algorithm cipher_alg; /*!< Cipher Algorithm*/
123         enum rte_crypto_auth_algorithm auth_alg; /*!< Authentication Algorithm*/
124         enum rte_crypto_aead_algorithm aead_alg; /*!< AEAD Algorithm*/
125 #ifdef RTE_LIBRTE_SECURITY
126         enum rte_security_session_protocol proto_alg; /*!< Security Algorithm*/
127 #endif
128         union {
129                 struct {
130                         uint8_t *data;  /**< pointer to key data */
131                         size_t length;  /**< key length in bytes */
132                         uint32_t alg;
133                         uint32_t algmode;
134                 } aead_key;
135                 struct {
136                         struct {
137                                 uint8_t *data;  /**< pointer to key data */
138                                 size_t length;  /**< key length in bytes */
139                                 uint32_t alg;
140                                 uint32_t algmode;
141                         } cipher_key;
142                         struct {
143                                 uint8_t *data;  /**< pointer to key data */
144                                 size_t length;  /**< key length in bytes */
145                                 uint32_t alg;
146                                 uint32_t algmode;
147                         } auth_key;
148                 };
149         };
150         union {
151                 struct {
152                         struct {
153                                 uint16_t length;
154                                 uint16_t offset;
155                         } iv;   /**< Initialisation vector parameters */
156                         uint16_t auth_only_len;
157                                         /*!< Length of data for Auth only */
158                         uint32_t digest_length;
159                         struct ipsec_decap_pdb decap_pdb;
160                         struct ipsec_encap_pdb encap_pdb;
161                         union {
162                                 struct ip ip4_hdr;
163                                 struct rte_ipv6_hdr ip6_hdr;
164                         };
165                         uint8_t auth_cipher_text;
166                                 /**< Authenticate/cipher ordering */
167                 };
168 #ifdef RTE_LIBRTE_SECURITY
169                 struct sec_pdcp_ctxt pdcp;
170 #endif
171         };
172         struct dpaa_sec_qp *qp[MAX_DPAA_CORES];
173         struct qman_fq *inq[MAX_DPAA_CORES];
174         struct sec_cdb cdb;     /**< cmd block associated with qp */
175 } dpaa_sec_session;
176
177 struct dpaa_sec_qp {
178         struct dpaa_sec_dev_private *internals;
179         struct rte_mempool *ctx_pool; /* mempool for dpaa_sec_op_ctx */
180         struct qman_fq outq;
181         int rx_pkts;
182         int rx_errs;
183         int tx_pkts;
184         int tx_errs;
185 };
186
187 #define RTE_DPAA_MAX_NB_SEC_QPS 2
188 #define RTE_DPAA_MAX_RX_QUEUE (MAX_DPAA_CORES * RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS)
189 #define DPAA_MAX_DEQUEUE_NUM_FRAMES 63
190
191 /* internal sec queue interface */
192 struct dpaa_sec_dev_private {
193         void *sec_hw;
194         struct dpaa_sec_qp qps[RTE_DPAA_MAX_NB_SEC_QPS]; /* i/o queue for sec */
195         struct qman_fq inq[RTE_DPAA_MAX_RX_QUEUE];
196         unsigned char inq_attach[RTE_DPAA_MAX_RX_QUEUE];
197         unsigned int max_nb_queue_pairs;
198         unsigned int max_nb_sessions;
199         rte_spinlock_t lock;
200 };
201
202 #define MAX_SG_ENTRIES          16
203 #define MAX_JOB_SG_ENTRIES      36
204
205 struct dpaa_sec_job {
206         /* sg[0] output, sg[1] input, others are possible sub frames */
207         struct qm_sg_entry sg[MAX_JOB_SG_ENTRIES];
208 };
209
210 #define DPAA_MAX_NB_MAX_DIGEST  32
211 struct dpaa_sec_op_ctx {
212         struct dpaa_sec_job job;
213         struct rte_crypto_op *op;
214         struct rte_mempool *ctx_pool; /* mempool pointer for dpaa_sec_op_ctx */
215         uint32_t fd_status;
216         int64_t vtop_offset;
217         uint8_t digest[DPAA_MAX_NB_MAX_DIGEST];
218 };
219
220 static const struct rte_cryptodev_capabilities dpaa_sec_capabilities[] = {
221         {       /* MD5 HMAC */
222                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
223                 {.sym = {
224                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
225                         {.auth = {
226                                 .algo = RTE_CRYPTO_AUTH_MD5_HMAC,
227                                 .block_size = 64,
228                                 .key_size = {
229                                         .min = 1,
230                                         .max = 64,
231                                         .increment = 1
232                                 },
233                                 .digest_size = {
234                                         .min = 1,
235                                         .max = 16,
236                                         .increment = 1
237                                 },
238                                 .iv_size = { 0 }
239                         }, }
240                 }, }
241         },
242         {       /* SHA1 HMAC */
243                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
244                 {.sym = {
245                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
246                         {.auth = {
247                                 .algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
248                                 .block_size = 64,
249                                 .key_size = {
250                                         .min = 1,
251                                         .max = 64,
252                                         .increment = 1
253                                 },
254                                 .digest_size = {
255                                         .min = 1,
256                                         .max = 20,
257                                         .increment = 1
258                                 },
259                                 .iv_size = { 0 }
260                         }, }
261                 }, }
262         },
263         {       /* SHA224 HMAC */
264                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
265                 {.sym = {
266                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
267                         {.auth = {
268                                 .algo = RTE_CRYPTO_AUTH_SHA224_HMAC,
269                                 .block_size = 64,
270                                 .key_size = {
271                                         .min = 1,
272                                         .max = 64,
273                                         .increment = 1
274                                 },
275                                 .digest_size = {
276                                         .min = 1,
277                                         .max = 28,
278                                         .increment = 1
279                                 },
280                                 .iv_size = { 0 }
281                         }, }
282                 }, }
283         },
284         {       /* SHA256 HMAC */
285                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
286                 {.sym = {
287                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
288                         {.auth = {
289                                 .algo = RTE_CRYPTO_AUTH_SHA256_HMAC,
290                                 .block_size = 64,
291                                 .key_size = {
292                                         .min = 1,
293                                         .max = 64,
294                                         .increment = 1
295                                 },
296                                 .digest_size = {
297                                         .min = 1,
298                                         .max = 32,
299                                         .increment = 1
300                                 },
301                                 .iv_size = { 0 }
302                         }, }
303                 }, }
304         },
305         {       /* SHA384 HMAC */
306                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
307                 {.sym = {
308                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
309                         {.auth = {
310                                 .algo = RTE_CRYPTO_AUTH_SHA384_HMAC,
311                                 .block_size = 128,
312                                 .key_size = {
313                                         .min = 1,
314                                         .max = 128,
315                                         .increment = 1
316                                 },
317                                 .digest_size = {
318                                         .min = 1,
319                                         .max = 48,
320                                         .increment = 1
321                                 },
322                                 .iv_size = { 0 }
323                         }, }
324                 }, }
325         },
326         {       /* SHA512 HMAC */
327                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
328                 {.sym = {
329                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
330                         {.auth = {
331                                 .algo = RTE_CRYPTO_AUTH_SHA512_HMAC,
332                                 .block_size = 128,
333                                 .key_size = {
334                                         .min = 1,
335                                         .max = 128,
336                                         .increment = 1
337                                 },
338                                 .digest_size = {
339                                         .min = 1,
340                                         .max = 64,
341                                         .increment = 1
342                                 },
343                                 .iv_size = { 0 }
344                         }, }
345                 }, }
346         },
347         {       /* AES GCM */
348                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
349                 {.sym = {
350                         .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD,
351                         {.aead = {
352                                 .algo = RTE_CRYPTO_AEAD_AES_GCM,
353                                 .block_size = 16,
354                                 .key_size = {
355                                         .min = 16,
356                                         .max = 32,
357                                         .increment = 8
358                                 },
359                                 .digest_size = {
360                                         .min = 8,
361                                         .max = 16,
362                                         .increment = 4
363                                 },
364                                 .aad_size = {
365                                         .min = 0,
366                                         .max = 240,
367                                         .increment = 1
368                                 },
369                                 .iv_size = {
370                                         .min = 12,
371                                         .max = 12,
372                                         .increment = 0
373                                 },
374                         }, }
375                 }, }
376         },
377         {       /* AES CBC */
378                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
379                 {.sym = {
380                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
381                         {.cipher = {
382                                 .algo = RTE_CRYPTO_CIPHER_AES_CBC,
383                                 .block_size = 16,
384                                 .key_size = {
385                                         .min = 16,
386                                         .max = 32,
387                                         .increment = 8
388                                 },
389                                 .iv_size = {
390                                         .min = 16,
391                                         .max = 16,
392                                         .increment = 0
393                                 }
394                         }, }
395                 }, }
396         },
397         {       /* AES CTR */
398                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
399                 {.sym = {
400                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
401                         {.cipher = {
402                                 .algo = RTE_CRYPTO_CIPHER_AES_CTR,
403                                 .block_size = 16,
404                                 .key_size = {
405                                         .min = 16,
406                                         .max = 32,
407                                         .increment = 8
408                                 },
409                                 .iv_size = {
410                                         .min = 16,
411                                         .max = 16,
412                                         .increment = 0
413                                 },
414                         }, }
415                 }, }
416         },
417         {       /* 3DES CBC */
418                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
419                 {.sym = {
420                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
421                         {.cipher = {
422                                 .algo = RTE_CRYPTO_CIPHER_3DES_CBC,
423                                 .block_size = 8,
424                                 .key_size = {
425                                         .min = 16,
426                                         .max = 24,
427                                         .increment = 8
428                                 },
429                                 .iv_size = {
430                                         .min = 8,
431                                         .max = 8,
432                                         .increment = 0
433                                 }
434                         }, }
435                 }, }
436         },
437         {       /* SNOW 3G (UIA2) */
438                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
439                 {.sym = {
440                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
441                         {.auth = {
442                                 .algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2,
443                                 .block_size = 16,
444                                 .key_size = {
445                                         .min = 16,
446                                         .max = 16,
447                                         .increment = 0
448                                 },
449                                 .digest_size = {
450                                         .min = 4,
451                                         .max = 4,
452                                         .increment = 0
453                                 },
454                                 .iv_size = {
455                                         .min = 16,
456                                         .max = 16,
457                                         .increment = 0
458                                 }
459                         }, }
460                 }, }
461         },
462         {       /* SNOW 3G (UEA2) */
463                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
464                 {.sym = {
465                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
466                         {.cipher = {
467                                 .algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
468                                 .block_size = 16,
469                                 .key_size = {
470                                         .min = 16,
471                                         .max = 16,
472                                         .increment = 0
473                                 },
474                                 .iv_size = {
475                                         .min = 16,
476                                         .max = 16,
477                                         .increment = 0
478                                 }
479                         }, }
480                 }, }
481         },
482         {       /* ZUC (EEA3) */
483                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
484                 {.sym = {
485                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
486                         {.cipher = {
487                                 .algo = RTE_CRYPTO_CIPHER_ZUC_EEA3,
488                                 .block_size = 16,
489                                 .key_size = {
490                                         .min = 16,
491                                         .max = 16,
492                                         .increment = 0
493                                 },
494                                 .iv_size = {
495                                         .min = 16,
496                                         .max = 16,
497                                         .increment = 0
498                                 }
499                         }, }
500                 }, }
501         },
502         {       /* ZUC (EIA3) */
503                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
504                 {.sym = {
505                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
506                         {.auth = {
507                                 .algo = RTE_CRYPTO_AUTH_ZUC_EIA3,
508                                 .block_size = 16,
509                                 .key_size = {
510                                         .min = 16,
511                                         .max = 16,
512                                         .increment = 0
513                                 },
514                                 .digest_size = {
515                                         .min = 4,
516                                         .max = 4,
517                                         .increment = 0
518                                 },
519                                 .iv_size = {
520                                         .min = 16,
521                                         .max = 16,
522                                         .increment = 0
523                                 }
524                         }, }
525                 }, }
526         },
527         RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
528 };
529
530 #ifdef RTE_LIBRTE_SECURITY
531 static const struct rte_cryptodev_capabilities dpaa_pdcp_capabilities[] = {
532         {       /* SNOW 3G (UIA2) */
533                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
534                 {.sym = {
535                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
536                         {.auth = {
537                                 .algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2,
538                                 .block_size = 16,
539                                 .key_size = {
540                                         .min = 16,
541                                         .max = 16,
542                                         .increment = 0
543                                 },
544                                 .digest_size = {
545                                         .min = 4,
546                                         .max = 4,
547                                         .increment = 0
548                                 },
549                                 .iv_size = {
550                                         .min = 16,
551                                         .max = 16,
552                                         .increment = 0
553                                 }
554                         }, }
555                 }, }
556         },
557         {       /* SNOW 3G (UEA2) */
558                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
559                 {.sym = {
560                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
561                         {.cipher = {
562                                 .algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
563                                 .block_size = 16,
564                                 .key_size = {
565                                         .min = 16,
566                                         .max = 16,
567                                         .increment = 0
568                                 },
569                                 .iv_size = {
570                                         .min = 16,
571                                         .max = 16,
572                                         .increment = 0
573                                 }
574                         }, }
575                 }, }
576         },
577         {       /* AES CTR */
578                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
579                 {.sym = {
580                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
581                         {.cipher = {
582                                 .algo = RTE_CRYPTO_CIPHER_AES_CTR,
583                                 .block_size = 16,
584                                 .key_size = {
585                                         .min = 16,
586                                         .max = 32,
587                                         .increment = 8
588                                 },
589                                 .iv_size = {
590                                         .min = 16,
591                                         .max = 16,
592                                         .increment = 0
593                                 }
594                         }, }
595                 }, }
596         },
597         {       /* NULL (AUTH) */
598                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
599                 {.sym = {
600                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
601                         {.auth = {
602                                 .algo = RTE_CRYPTO_AUTH_NULL,
603                                 .block_size = 1,
604                                 .key_size = {
605                                         .min = 0,
606                                         .max = 0,
607                                         .increment = 0
608                                 },
609                                 .digest_size = {
610                                         .min = 0,
611                                         .max = 0,
612                                         .increment = 0
613                                 },
614                                 .iv_size = { 0 }
615                         }, },
616                 }, },
617         },
618         {       /* NULL (CIPHER) */
619                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
620                 {.sym = {
621                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
622                         {.cipher = {
623                                 .algo = RTE_CRYPTO_CIPHER_NULL,
624                                 .block_size = 1,
625                                 .key_size = {
626                                         .min = 0,
627                                         .max = 0,
628                                         .increment = 0
629                                 },
630                                 .iv_size = {
631                                         .min = 0,
632                                         .max = 0,
633                                         .increment = 0
634                                 }
635                         }, },
636                 }, }
637         },
638         {       /* ZUC (EEA3) */
639                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
640                 {.sym = {
641                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
642                         {.cipher = {
643                                 .algo = RTE_CRYPTO_CIPHER_ZUC_EEA3,
644                                 .block_size = 16,
645                                 .key_size = {
646                                         .min = 16,
647                                         .max = 16,
648                                         .increment = 0
649                                 },
650                                 .iv_size = {
651                                         .min = 16,
652                                         .max = 16,
653                                         .increment = 0
654                                 }
655                         }, }
656                 }, }
657         },
658         {       /* ZUC (EIA3) */
659                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
660                 {.sym = {
661                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
662                         {.auth = {
663                                 .algo = RTE_CRYPTO_AUTH_ZUC_EIA3,
664                                 .block_size = 16,
665                                 .key_size = {
666                                         .min = 16,
667                                         .max = 16,
668                                         .increment = 0
669                                 },
670                                 .digest_size = {
671                                         .min = 4,
672                                         .max = 4,
673                                         .increment = 0
674                                 },
675                                 .iv_size = {
676                                         .min = 16,
677                                         .max = 16,
678                                         .increment = 0
679                                 }
680                         }, }
681                 }, }
682         },
683
684         RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
685 };
686
687 static const struct rte_security_capability dpaa_sec_security_cap[] = {
688         { /* IPsec Lookaside Protocol offload ESP Transport Egress */
689                 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
690                 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
691                 .ipsec = {
692                         .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
693                         .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
694                         .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
695                         .options = { 0 }
696                 },
697                 .crypto_capabilities = dpaa_sec_capabilities
698         },
699         { /* IPsec Lookaside Protocol offload ESP Tunnel Ingress */
700                 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
701                 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
702                 .ipsec = {
703                         .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
704                         .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
705                         .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
706                         .options = { 0 }
707                 },
708                 .crypto_capabilities = dpaa_sec_capabilities
709         },
710         { /* PDCP Lookaside Protocol offload Data */
711                 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
712                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
713                 .pdcp = {
714                         .domain = RTE_SECURITY_PDCP_MODE_DATA,
715                 },
716                 .crypto_capabilities = dpaa_pdcp_capabilities
717         },
718         { /* PDCP Lookaside Protocol offload Control */
719                 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
720                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
721                 .pdcp = {
722                         .domain = RTE_SECURITY_PDCP_MODE_CONTROL,
723                 },
724                 .crypto_capabilities = dpaa_pdcp_capabilities
725         },
726         {
727                 .action = RTE_SECURITY_ACTION_TYPE_NONE
728         }
729 };
730 #endif
731
732 /**
733  * Checksum
734  *
735  * @param buffer calculate chksum for buffer
736  * @param len    buffer length
737  *
738  * @return checksum value in host cpu order
739  */
740 static inline uint16_t
741 calc_chksum(void *buffer, int len)
742 {
743         uint16_t *buf = (uint16_t *)buffer;
744         uint32_t sum = 0;
745         uint16_t result;
746
747         for (sum = 0; len > 1; len -= 2)
748                 sum += *buf++;
749
750         if (len == 1)
751                 sum += *(unsigned char *)buf;
752
753         sum = (sum >> 16) + (sum & 0xFFFF);
754         sum += (sum >> 16);
755         result = ~sum;
756
757         return  result;
758 }
759
760 #endif /* _DPAA_SEC_H_ */