a661d5a561a2be68fd03b4aa0514964bcba24c40
[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
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
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         enum rte_security_session_protocol proto_alg; /*!< Security Algorithm*/
126         union {
127                 struct {
128                         uint8_t *data;  /**< pointer to key data */
129                         size_t length;  /**< key length in bytes */
130                         uint32_t alg;
131                         uint32_t algmode;
132                 } aead_key;
133                 struct {
134                         struct {
135                                 uint8_t *data;  /**< pointer to key data */
136                                 size_t length;  /**< key length in bytes */
137                                 uint32_t alg;
138                                 uint32_t algmode;
139                         } cipher_key;
140                         struct {
141                                 uint8_t *data;  /**< pointer to key data */
142                                 size_t length;  /**< key length in bytes */
143                                 uint32_t alg;
144                                 uint32_t algmode;
145                         } auth_key;
146                 };
147         };
148         union {
149                 struct {
150                         struct {
151                                 uint16_t length;
152                                 uint16_t offset;
153                         } iv;   /**< Initialisation vector parameters */
154                         uint16_t auth_only_len;
155                                         /*!< Length of data for Auth only */
156                         uint32_t digest_length;
157                         struct ipsec_decap_pdb decap_pdb;
158                         struct ipsec_encap_pdb encap_pdb;
159                         union {
160                                 struct ip ip4_hdr;
161                                 struct rte_ipv6_hdr ip6_hdr;
162                         };
163                         uint8_t auth_cipher_text;
164                                 /**< Authenticate/cipher ordering */
165                 };
166                 struct sec_pdcp_ctxt pdcp;
167         };
168         struct dpaa_sec_qp *qp[MAX_DPAA_CORES];
169         struct qman_fq *inq[MAX_DPAA_CORES];
170         struct sec_cdb cdb;     /**< cmd block associated with qp */
171 } dpaa_sec_session;
172
173 struct dpaa_sec_qp {
174         struct dpaa_sec_dev_private *internals;
175         struct rte_mempool *ctx_pool; /* mempool for dpaa_sec_op_ctx */
176         struct qman_fq outq;
177         int rx_pkts;
178         int rx_errs;
179         int tx_pkts;
180         int tx_errs;
181 };
182
183 #define RTE_DPAA_MAX_NB_SEC_QPS 2
184 #define RTE_DPAA_MAX_RX_QUEUE (MAX_DPAA_CORES * RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS)
185 #define DPAA_MAX_DEQUEUE_NUM_FRAMES 63
186
187 /* internal sec queue interface */
188 struct dpaa_sec_dev_private {
189         void *sec_hw;
190         struct dpaa_sec_qp qps[RTE_DPAA_MAX_NB_SEC_QPS]; /* i/o queue for sec */
191         struct qman_fq inq[RTE_DPAA_MAX_RX_QUEUE];
192         unsigned char inq_attach[RTE_DPAA_MAX_RX_QUEUE];
193         unsigned int max_nb_queue_pairs;
194         unsigned int max_nb_sessions;
195         rte_spinlock_t lock;
196 };
197
198 #define MAX_SG_ENTRIES          16
199 #define MAX_JOB_SG_ENTRIES      36
200
201 struct dpaa_sec_job {
202         /* sg[0] output, sg[1] input, others are possible sub frames */
203         struct qm_sg_entry sg[MAX_JOB_SG_ENTRIES];
204 };
205
206 #define DPAA_MAX_NB_MAX_DIGEST  32
207 struct dpaa_sec_op_ctx {
208         struct dpaa_sec_job job;
209         struct rte_crypto_op *op;
210         struct rte_mempool *ctx_pool; /* mempool pointer for dpaa_sec_op_ctx */
211         uint32_t fd_status;
212         int64_t vtop_offset;
213         uint8_t digest[DPAA_MAX_NB_MAX_DIGEST];
214 };
215
216 static const struct rte_cryptodev_capabilities dpaa_sec_capabilities[] = {
217         {       /* MD5 HMAC */
218                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
219                 {.sym = {
220                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
221                         {.auth = {
222                                 .algo = RTE_CRYPTO_AUTH_MD5_HMAC,
223                                 .block_size = 64,
224                                 .key_size = {
225                                         .min = 1,
226                                         .max = 64,
227                                         .increment = 1
228                                 },
229                                 .digest_size = {
230                                         .min = 1,
231                                         .max = 16,
232                                         .increment = 1
233                                 },
234                                 .iv_size = { 0 }
235                         }, }
236                 }, }
237         },
238         {       /* SHA1 HMAC */
239                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
240                 {.sym = {
241                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
242                         {.auth = {
243                                 .algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
244                                 .block_size = 64,
245                                 .key_size = {
246                                         .min = 1,
247                                         .max = 64,
248                                         .increment = 1
249                                 },
250                                 .digest_size = {
251                                         .min = 1,
252                                         .max = 20,
253                                         .increment = 1
254                                 },
255                                 .iv_size = { 0 }
256                         }, }
257                 }, }
258         },
259         {       /* SHA224 HMAC */
260                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
261                 {.sym = {
262                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
263                         {.auth = {
264                                 .algo = RTE_CRYPTO_AUTH_SHA224_HMAC,
265                                 .block_size = 64,
266                                 .key_size = {
267                                         .min = 1,
268                                         .max = 64,
269                                         .increment = 1
270                                 },
271                                 .digest_size = {
272                                         .min = 1,
273                                         .max = 28,
274                                         .increment = 1
275                                 },
276                                 .iv_size = { 0 }
277                         }, }
278                 }, }
279         },
280         {       /* SHA256 HMAC */
281                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
282                 {.sym = {
283                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
284                         {.auth = {
285                                 .algo = RTE_CRYPTO_AUTH_SHA256_HMAC,
286                                 .block_size = 64,
287                                 .key_size = {
288                                         .min = 1,
289                                         .max = 64,
290                                         .increment = 1
291                                 },
292                                 .digest_size = {
293                                         .min = 1,
294                                         .max = 32,
295                                         .increment = 1
296                                 },
297                                 .iv_size = { 0 }
298                         }, }
299                 }, }
300         },
301         {       /* SHA384 HMAC */
302                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
303                 {.sym = {
304                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
305                         {.auth = {
306                                 .algo = RTE_CRYPTO_AUTH_SHA384_HMAC,
307                                 .block_size = 128,
308                                 .key_size = {
309                                         .min = 1,
310                                         .max = 128,
311                                         .increment = 1
312                                 },
313                                 .digest_size = {
314                                         .min = 1,
315                                         .max = 48,
316                                         .increment = 1
317                                 },
318                                 .iv_size = { 0 }
319                         }, }
320                 }, }
321         },
322         {       /* SHA512 HMAC */
323                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
324                 {.sym = {
325                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
326                         {.auth = {
327                                 .algo = RTE_CRYPTO_AUTH_SHA512_HMAC,
328                                 .block_size = 128,
329                                 .key_size = {
330                                         .min = 1,
331                                         .max = 128,
332                                         .increment = 1
333                                 },
334                                 .digest_size = {
335                                         .min = 1,
336                                         .max = 64,
337                                         .increment = 1
338                                 },
339                                 .iv_size = { 0 }
340                         }, }
341                 }, }
342         },
343         {       /* AES GCM */
344                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
345                 {.sym = {
346                         .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD,
347                         {.aead = {
348                                 .algo = RTE_CRYPTO_AEAD_AES_GCM,
349                                 .block_size = 16,
350                                 .key_size = {
351                                         .min = 16,
352                                         .max = 32,
353                                         .increment = 8
354                                 },
355                                 .digest_size = {
356                                         .min = 8,
357                                         .max = 16,
358                                         .increment = 4
359                                 },
360                                 .aad_size = {
361                                         .min = 0,
362                                         .max = 240,
363                                         .increment = 1
364                                 },
365                                 .iv_size = {
366                                         .min = 12,
367                                         .max = 12,
368                                         .increment = 0
369                                 },
370                         }, }
371                 }, }
372         },
373         {       /* AES CBC */
374                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
375                 {.sym = {
376                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
377                         {.cipher = {
378                                 .algo = RTE_CRYPTO_CIPHER_AES_CBC,
379                                 .block_size = 16,
380                                 .key_size = {
381                                         .min = 16,
382                                         .max = 32,
383                                         .increment = 8
384                                 },
385                                 .iv_size = {
386                                         .min = 16,
387                                         .max = 16,
388                                         .increment = 0
389                                 }
390                         }, }
391                 }, }
392         },
393         {       /* AES CTR */
394                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
395                 {.sym = {
396                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
397                         {.cipher = {
398                                 .algo = RTE_CRYPTO_CIPHER_AES_CTR,
399                                 .block_size = 16,
400                                 .key_size = {
401                                         .min = 16,
402                                         .max = 32,
403                                         .increment = 8
404                                 },
405                                 .iv_size = {
406                                         .min = 16,
407                                         .max = 16,
408                                         .increment = 0
409                                 },
410                         }, }
411                 }, }
412         },
413         {       /* 3DES CBC */
414                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
415                 {.sym = {
416                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
417                         {.cipher = {
418                                 .algo = RTE_CRYPTO_CIPHER_3DES_CBC,
419                                 .block_size = 8,
420                                 .key_size = {
421                                         .min = 16,
422                                         .max = 24,
423                                         .increment = 8
424                                 },
425                                 .iv_size = {
426                                         .min = 8,
427                                         .max = 8,
428                                         .increment = 0
429                                 }
430                         }, }
431                 }, }
432         },
433         {       /* SNOW 3G (UIA2) */
434                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
435                 {.sym = {
436                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
437                         {.auth = {
438                                 .algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2,
439                                 .block_size = 16,
440                                 .key_size = {
441                                         .min = 16,
442                                         .max = 16,
443                                         .increment = 0
444                                 },
445                                 .digest_size = {
446                                         .min = 4,
447                                         .max = 4,
448                                         .increment = 0
449                                 },
450                                 .iv_size = {
451                                         .min = 16,
452                                         .max = 16,
453                                         .increment = 0
454                                 }
455                         }, }
456                 }, }
457         },
458         {       /* SNOW 3G (UEA2) */
459                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
460                 {.sym = {
461                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
462                         {.cipher = {
463                                 .algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
464                                 .block_size = 16,
465                                 .key_size = {
466                                         .min = 16,
467                                         .max = 16,
468                                         .increment = 0
469                                 },
470                                 .iv_size = {
471                                         .min = 16,
472                                         .max = 16,
473                                         .increment = 0
474                                 }
475                         }, }
476                 }, }
477         },
478         {       /* ZUC (EEA3) */
479                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
480                 {.sym = {
481                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
482                         {.cipher = {
483                                 .algo = RTE_CRYPTO_CIPHER_ZUC_EEA3,
484                                 .block_size = 16,
485                                 .key_size = {
486                                         .min = 16,
487                                         .max = 16,
488                                         .increment = 0
489                                 },
490                                 .iv_size = {
491                                         .min = 16,
492                                         .max = 16,
493                                         .increment = 0
494                                 }
495                         }, }
496                 }, }
497         },
498         {       /* ZUC (EIA3) */
499                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
500                 {.sym = {
501                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
502                         {.auth = {
503                                 .algo = RTE_CRYPTO_AUTH_ZUC_EIA3,
504                                 .block_size = 16,
505                                 .key_size = {
506                                         .min = 16,
507                                         .max = 16,
508                                         .increment = 0
509                                 },
510                                 .digest_size = {
511                                         .min = 4,
512                                         .max = 4,
513                                         .increment = 0
514                                 },
515                                 .iv_size = {
516                                         .min = 16,
517                                         .max = 16,
518                                         .increment = 0
519                                 }
520                         }, }
521                 }, }
522         },
523         RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
524 };
525
526 static const struct rte_cryptodev_capabilities dpaa_pdcp_capabilities[] = {
527         {       /* SNOW 3G (UIA2) */
528                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
529                 {.sym = {
530                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
531                         {.auth = {
532                                 .algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2,
533                                 .block_size = 16,
534                                 .key_size = {
535                                         .min = 16,
536                                         .max = 16,
537                                         .increment = 0
538                                 },
539                                 .digest_size = {
540                                         .min = 4,
541                                         .max = 4,
542                                         .increment = 0
543                                 },
544                                 .iv_size = {
545                                         .min = 16,
546                                         .max = 16,
547                                         .increment = 0
548                                 }
549                         }, }
550                 }, }
551         },
552         {       /* SNOW 3G (UEA2) */
553                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
554                 {.sym = {
555                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
556                         {.cipher = {
557                                 .algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
558                                 .block_size = 16,
559                                 .key_size = {
560                                         .min = 16,
561                                         .max = 16,
562                                         .increment = 0
563                                 },
564                                 .iv_size = {
565                                         .min = 16,
566                                         .max = 16,
567                                         .increment = 0
568                                 }
569                         }, }
570                 }, }
571         },
572         {       /* AES CTR */
573                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
574                 {.sym = {
575                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
576                         {.cipher = {
577                                 .algo = RTE_CRYPTO_CIPHER_AES_CTR,
578                                 .block_size = 16,
579                                 .key_size = {
580                                         .min = 16,
581                                         .max = 32,
582                                         .increment = 8
583                                 },
584                                 .iv_size = {
585                                         .min = 16,
586                                         .max = 16,
587                                         .increment = 0
588                                 }
589                         }, }
590                 }, }
591         },
592         {       /* NULL (AUTH) */
593                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
594                 {.sym = {
595                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
596                         {.auth = {
597                                 .algo = RTE_CRYPTO_AUTH_NULL,
598                                 .block_size = 1,
599                                 .key_size = {
600                                         .min = 0,
601                                         .max = 0,
602                                         .increment = 0
603                                 },
604                                 .digest_size = {
605                                         .min = 0,
606                                         .max = 0,
607                                         .increment = 0
608                                 },
609                                 .iv_size = { 0 }
610                         }, },
611                 }, },
612         },
613         {       /* NULL (CIPHER) */
614                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
615                 {.sym = {
616                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
617                         {.cipher = {
618                                 .algo = RTE_CRYPTO_CIPHER_NULL,
619                                 .block_size = 1,
620                                 .key_size = {
621                                         .min = 0,
622                                         .max = 0,
623                                         .increment = 0
624                                 },
625                                 .iv_size = {
626                                         .min = 0,
627                                         .max = 0,
628                                         .increment = 0
629                                 }
630                         }, },
631                 }, }
632         },
633         {       /* ZUC (EEA3) */
634                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
635                 {.sym = {
636                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
637                         {.cipher = {
638                                 .algo = RTE_CRYPTO_CIPHER_ZUC_EEA3,
639                                 .block_size = 16,
640                                 .key_size = {
641                                         .min = 16,
642                                         .max = 16,
643                                         .increment = 0
644                                 },
645                                 .iv_size = {
646                                         .min = 16,
647                                         .max = 16,
648                                         .increment = 0
649                                 }
650                         }, }
651                 }, }
652         },
653         {       /* ZUC (EIA3) */
654                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
655                 {.sym = {
656                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
657                         {.auth = {
658                                 .algo = RTE_CRYPTO_AUTH_ZUC_EIA3,
659                                 .block_size = 16,
660                                 .key_size = {
661                                         .min = 16,
662                                         .max = 16,
663                                         .increment = 0
664                                 },
665                                 .digest_size = {
666                                         .min = 4,
667                                         .max = 4,
668                                         .increment = 0
669                                 },
670                                 .iv_size = {
671                                         .min = 16,
672                                         .max = 16,
673                                         .increment = 0
674                                 }
675                         }, }
676                 }, }
677         },
678
679         RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
680 };
681
682 static const struct rte_security_capability dpaa_sec_security_cap[] = {
683         { /* IPsec Lookaside Protocol offload ESP Transport Egress */
684                 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
685                 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
686                 .ipsec = {
687                         .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
688                         .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
689                         .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
690                         .options = { 0 }
691                 },
692                 .crypto_capabilities = dpaa_sec_capabilities
693         },
694         { /* IPsec Lookaside Protocol offload ESP Tunnel Ingress */
695                 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
696                 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
697                 .ipsec = {
698                         .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
699                         .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
700                         .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
701                         .options = { 0 }
702                 },
703                 .crypto_capabilities = dpaa_sec_capabilities
704         },
705         { /* PDCP Lookaside Protocol offload Data */
706                 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
707                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
708                 .pdcp = {
709                         .domain = RTE_SECURITY_PDCP_MODE_DATA,
710                 },
711                 .crypto_capabilities = dpaa_pdcp_capabilities
712         },
713         { /* PDCP Lookaside Protocol offload Control */
714                 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
715                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
716                 .pdcp = {
717                         .domain = RTE_SECURITY_PDCP_MODE_CONTROL,
718                 },
719                 .crypto_capabilities = dpaa_pdcp_capabilities
720         },
721         {
722                 .action = RTE_SECURITY_ACTION_TYPE_NONE
723         }
724 };
725
726 /**
727  * Checksum
728  *
729  * @param buffer calculate chksum for buffer
730  * @param len    buffer length
731  *
732  * @return checksum value in host cpu order
733  */
734 static inline uint16_t
735 calc_chksum(void *buffer, int len)
736 {
737         uint16_t *buf = (uint16_t *)buffer;
738         uint32_t sum = 0;
739         uint16_t result;
740
741         for (sum = 0; len > 1; len -= 2)
742                 sum += *buf++;
743
744         if (len == 1)
745                 sum += *(unsigned char *)buf;
746
747         sum = (sum >> 16) + (sum & 0xFFFF);
748         sum += (sum >> 16);
749         result = ~sum;
750
751         return  result;
752 }
753
754 #endif /* _DPAA_SEC_H_ */