net/i40e: fix bitmap free
[dpdk.git] / drivers / crypto / dpaa2_sec / dpaa2_sec_priv.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
4  *   Copyright 2016 NXP
5  *
6  */
7
8 #ifndef _DPAA2_SEC_PMD_PRIVATE_H_
9 #define _DPAA2_SEC_PMD_PRIVATE_H_
10
11 #ifdef RTE_LIBRTE_SECURITY
12 #include <rte_security_driver.h>
13 #endif
14
15 #define CRYPTODEV_NAME_DPAA2_SEC_PMD    crypto_dpaa2_sec
16 /**< NXP DPAA2 - SEC PMD device name */
17
18 #define MAX_QUEUES              64
19 #define MAX_DESC_SIZE           64
20 /** private data structure for each DPAA2_SEC device */
21 struct dpaa2_sec_dev_private {
22         void *mc_portal; /**< MC Portal for configuring this device */
23         void *hw; /**< Hardware handle for this device.Used by NADK framework */
24         struct rte_mempool *fle_pool; /* per device memory pool for FLE */
25         int32_t hw_id; /**< An unique ID of this device instance */
26         int32_t vfio_fd; /**< File descriptor received via VFIO */
27         uint16_t token; /**< Token required by DPxxx objects */
28         unsigned int max_nb_queue_pairs;
29         /**< Max number of queue pairs supported by device */
30 };
31
32 struct dpaa2_sec_qp {
33         struct dpaa2_queue rx_vq;
34         struct dpaa2_queue tx_vq;
35 };
36
37 enum shr_desc_type {
38         DESC_UPDATE,
39         DESC_FINAL,
40         DESC_INITFINAL,
41 };
42
43 #define DIR_ENC                 1
44 #define DIR_DEC                 0
45
46 #define DPAA2_IPv6_DEFAULT_VTC_FLOW     0x60000000
47
48 #define DPAA2_SET_FLC_EWS(flc)  (flc->word1_bits23_16 |= 0x1)
49 #define DPAA2_SET_FLC_RSC(flc)  (flc->word1_bits31_24 |= 0x1)
50 #define DPAA2_SET_FLC_REUSE_BS(flc) (flc->mode_bits |= 0x8000)
51 #define DPAA2_SET_FLC_REUSE_FF(flc) (flc->mode_bits |= 0x2000)
52
53 /* SEC Flow Context Descriptor */
54 struct sec_flow_context {
55         /* word 0 */
56         uint16_t word0_sdid;            /* 11-0  SDID */
57         uint16_t word0_res;             /* 31-12 reserved */
58
59         /* word 1 */
60         uint8_t word1_sdl;              /* 5-0 SDL */
61                                         /* 7-6 reserved */
62
63         uint8_t word1_bits_15_8;        /* 11-8 CRID */
64                                         /* 14-12 reserved */
65                                         /* 15 CRJD */
66
67         uint8_t word1_bits23_16;        /* 16  EWS */
68                                         /* 17 DAC */
69                                         /* 18,19,20 ? */
70                                         /* 23-21 reserved */
71
72         uint8_t word1_bits31_24;        /* 24 RSC */
73                                         /* 25 RBMT */
74                                         /* 31-26 reserved */
75
76         /* word 2  RFLC[31-0] */
77         uint32_t word2_rflc_31_0;
78
79         /* word 3  RFLC[63-32] */
80         uint32_t word3_rflc_63_32;
81
82         /* word 4 */
83         uint16_t word4_iicid;           /* 15-0  IICID */
84         uint16_t word4_oicid;           /* 31-16 OICID */
85
86         /* word 5 */
87         uint32_t word5_ofqid:24;                /* 23-0 OFQID */
88         uint32_t word5_31_24:8;
89                                         /* 24 OSC */
90                                         /* 25 OBMT */
91                                         /* 29-26 reserved */
92                                         /* 31-30 ICR */
93
94         /* word 6 */
95         uint32_t word6_oflc_31_0;
96
97         /* word 7 */
98         uint32_t word7_oflc_63_32;
99
100         /* Word 8-15 storage profiles */
101         uint16_t dl;                    /**<  DataLength(correction) */
102         uint16_t reserved;              /**< reserved */
103         uint16_t dhr;                   /**< DataHeadRoom(correction) */
104         uint16_t mode_bits;             /**< mode bits */
105         uint16_t bpv0;                  /**< buffer pool0 valid */
106         uint16_t bpid0;                 /**< Bypass Memory Translation */
107         uint16_t bpv1;                  /**< buffer pool1 valid */
108         uint16_t bpid1;                 /**< Bypass Memory Translation */
109         uint64_t word_12_15[2];         /**< word 12-15 are reserved */
110 };
111
112 struct sec_flc_desc {
113         struct sec_flow_context flc;
114         uint32_t desc[MAX_DESC_SIZE];
115 };
116
117 struct ctxt_priv {
118         struct rte_mempool *fle_pool; /* per device memory pool for FLE */
119         struct sec_flc_desc flc_desc[0];
120 };
121
122 enum dpaa2_sec_op_type {
123         DPAA2_SEC_NONE,  /*!< No Cipher operations*/
124         DPAA2_SEC_CIPHER,/*!< CIPHER operations */
125         DPAA2_SEC_AUTH,  /*!< Authentication Operations */
126         DPAA2_SEC_AEAD,  /*!< AEAD (AES-GCM/CCM) type operations */
127         DPAA2_SEC_CIPHER_HASH,  /*!< Authenticated Encryption with
128                                  * associated data
129                                  */
130         DPAA2_SEC_HASH_CIPHER,  /*!< Encryption with Authenticated
131                                  * associated data
132                                  */
133         DPAA2_SEC_IPSEC, /*!< IPSEC protocol operations*/
134         DPAA2_SEC_PDCP,  /*!< PDCP protocol operations*/
135         DPAA2_SEC_PKC,   /*!< Public Key Cryptographic Operations */
136         DPAA2_SEC_MAX
137 };
138
139 struct dpaa2_sec_aead_ctxt {
140         uint16_t auth_only_len; /*!< Length of data for Auth only */
141         uint8_t auth_cipher_text;       /**< Authenticate/cipher ordering */
142 };
143
144 #ifdef RTE_LIBRTE_SECURITY
145 /*
146  * The structure is to be filled by user for PDCP Protocol
147  */
148 struct dpaa2_pdcp_ctxt {
149         enum rte_security_pdcp_domain domain; /*!< Data/Control mode*/
150         int8_t bearer;  /*!< PDCP bearer ID */
151         int8_t pkt_dir;/*!< PDCP Frame Direction 0:UL 1:DL*/
152         int8_t hfn_ovd;/*!< Overwrite HFN per packet*/
153         uint8_t sn_size;        /*!< Sequence number size, 5/7/12/15/18 */
154         uint32_t hfn_ovd_offset;/*!< offset from rte_crypto_op at which
155                                  * per packet hfn is stored
156                                  */
157         uint32_t hfn;   /*!< Hyper Frame Number */
158         uint32_t hfn_threshold; /*!< HFN Threashold for key renegotiation */
159 };
160 #endif
161 typedef struct dpaa2_sec_session_entry {
162         void *ctxt;
163         uint8_t ctxt_type;
164         uint8_t dir;         /*!< Operation Direction */
165         enum rte_crypto_cipher_algorithm cipher_alg; /*!< Cipher Algorithm*/
166         enum rte_crypto_auth_algorithm auth_alg; /*!< Authentication Algorithm*/
167         enum rte_crypto_aead_algorithm aead_alg; /*!< AEAD Algorithm*/
168         union {
169                 struct {
170                         uint8_t *data;  /**< pointer to key data */
171                         size_t length;  /**< key length in bytes */
172                 } aead_key;
173                 struct {
174                         struct {
175                                 uint8_t *data;  /**< pointer to key data */
176                                 size_t length;  /**< key length in bytes */
177                         } cipher_key;
178                         struct {
179                                 uint8_t *data;  /**< pointer to key data */
180                                 size_t length;  /**< key length in bytes */
181                         } auth_key;
182                 };
183         };
184         union {
185                 struct {
186                         struct {
187                                 uint16_t length; /**< IV length in bytes */
188                                 uint16_t offset; /**< IV offset in bytes */
189                         } iv;
190                         uint16_t digest_length;
191                         uint8_t status;
192                         union {
193                                 struct dpaa2_sec_aead_ctxt aead_ctxt;
194                         } ext_params;
195                 };
196 #ifdef RTE_LIBRTE_SECURITY
197                 struct dpaa2_pdcp_ctxt pdcp;
198 #endif
199         };
200 } dpaa2_sec_session;
201
202 static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
203         {       /* NULL (AUTH) */
204                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
205                 {.sym = {
206                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
207                         {.auth = {
208                                 .algo = RTE_CRYPTO_AUTH_NULL,
209                                 .block_size = 1,
210                                 .key_size = {
211                                         .min = 0,
212                                         .max = 0,
213                                         .increment = 0
214                                 },
215                                 .digest_size = {
216                                         .min = 0,
217                                         .max = 0,
218                                         .increment = 0
219                                 },
220                                 .iv_size = { 0 }
221                         }, },
222                 }, },
223         },
224         {       /* MD5 HMAC */
225                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
226                 {.sym = {
227                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
228                         {.auth = {
229                                 .algo = RTE_CRYPTO_AUTH_MD5_HMAC,
230                                 .block_size = 64,
231                                 .key_size = {
232                                         .min = 1,
233                                         .max = 64,
234                                         .increment = 1
235                                 },
236                                 .digest_size = {
237                                         .min = 1,
238                                         .max = 16,
239                                         .increment = 1
240                                 },
241                                 .iv_size = { 0 }
242                         }, }
243                 }, }
244         },
245         {       /* SHA1 HMAC */
246                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
247                 {.sym = {
248                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
249                         {.auth = {
250                                 .algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
251                                 .block_size = 64,
252                                 .key_size = {
253                                         .min = 1,
254                                         .max = 64,
255                                         .increment = 1
256                                 },
257                                 .digest_size = {
258                                         .min = 1,
259                                         .max = 20,
260                                         .increment = 1
261                                 },
262                                 .iv_size = { 0 }
263                         }, }
264                 }, }
265         },
266         {       /* SHA224 HMAC */
267                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
268                 {.sym = {
269                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
270                         {.auth = {
271                                 .algo = RTE_CRYPTO_AUTH_SHA224_HMAC,
272                                 .block_size = 64,
273                                 .key_size = {
274                                         .min = 1,
275                                         .max = 64,
276                                         .increment = 1
277                                 },
278                                 .digest_size = {
279                                         .min = 1,
280                                         .max = 28,
281                                         .increment = 1
282                                 },
283                                 .iv_size = { 0 }
284                         }, }
285                 }, }
286         },
287         {       /* SHA256 HMAC */
288                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
289                 {.sym = {
290                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
291                         {.auth = {
292                                 .algo = RTE_CRYPTO_AUTH_SHA256_HMAC,
293                                 .block_size = 64,
294                                 .key_size = {
295                                         .min = 1,
296                                         .max = 64,
297                                         .increment = 1
298                                 },
299                                 .digest_size = {
300                                         .min = 1,
301                                         .max = 32,
302                                         .increment = 1
303                                 },
304                                 .iv_size = { 0 }
305                                 }, }
306                         }, }
307                 },
308         {       /* SHA384 HMAC */
309                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
310                 {.sym = {
311                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
312                         {.auth = {
313                                 .algo = RTE_CRYPTO_AUTH_SHA384_HMAC,
314                                 .block_size = 128,
315                                 .key_size = {
316                                         .min = 1,
317                                         .max = 128,
318                                         .increment = 1
319                                 },
320                                 .digest_size = {
321                                         .min = 1,
322                                         .max = 48,
323                                         .increment = 1
324                                 },
325                                 .iv_size = { 0 }
326                         }, }
327                 }, }
328         },
329         {       /* SHA512 HMAC */
330                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
331                 {.sym = {
332                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
333                         {.auth = {
334                                 .algo = RTE_CRYPTO_AUTH_SHA512_HMAC,
335                                 .block_size = 128,
336                                 .key_size = {
337                                         .min = 1,
338                                         .max = 128,
339                                         .increment = 1
340                                 },
341                                 .digest_size = {
342                                         .min = 1,
343                                         .max = 64,
344                                         .increment = 1
345                                 },
346                                 .iv_size = { 0 }
347                         }, }
348                 }, }
349         },
350         {       /* AES GCM */
351                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
352                 {.sym = {
353                         .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD,
354                         {.aead = {
355                                 .algo = RTE_CRYPTO_AEAD_AES_GCM,
356                                 .block_size = 16,
357                                 .key_size = {
358                                         .min = 16,
359                                         .max = 32,
360                                         .increment = 8
361                                 },
362                                 .digest_size = {
363                                         .min = 8,
364                                         .max = 16,
365                                         .increment = 4
366                                 },
367                                 .aad_size = {
368                                         .min = 0,
369                                         .max = 240,
370                                         .increment = 1
371                                 },
372                                 .iv_size = {
373                                         .min = 12,
374                                         .max = 12,
375                                         .increment = 0
376                                 },
377                         }, }
378                 }, }
379         },
380         {       /* NULL (CIPHER) */
381                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
382                 {.sym = {
383                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
384                         {.cipher = {
385                                 .algo = RTE_CRYPTO_CIPHER_NULL,
386                                 .block_size = 1,
387                                 .key_size = {
388                                         .min = 0,
389                                         .max = 0,
390                                         .increment = 0
391                                 },
392                                 .iv_size = {
393                                         .min = 0,
394                                         .max = 0,
395                                         .increment = 0
396                                 }
397                         }, },
398                 }, }
399         },
400         {       /* AES CBC */
401                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
402                 {.sym = {
403                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
404                         {.cipher = {
405                                 .algo = RTE_CRYPTO_CIPHER_AES_CBC,
406                                 .block_size = 16,
407                                 .key_size = {
408                                         .min = 16,
409                                         .max = 32,
410                                         .increment = 8
411                                 },
412                                 .iv_size = {
413                                         .min = 16,
414                                         .max = 16,
415                                         .increment = 0
416                                 }
417                         }, }
418                 }, }
419         },
420         {       /* AES CTR */
421                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
422                 {.sym = {
423                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
424                         {.cipher = {
425                                 .algo = RTE_CRYPTO_CIPHER_AES_CTR,
426                                 .block_size = 16,
427                                 .key_size = {
428                                         .min = 16,
429                                         .max = 32,
430                                         .increment = 8
431                                 },
432                                 .iv_size = {
433                                         .min = 16,
434                                         .max = 16,
435                                         .increment = 0
436                                 },
437                         }, }
438                 }, }
439         },
440         {       /* 3DES CBC */
441                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
442                 {.sym = {
443                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
444                         {.cipher = {
445                                 .algo = RTE_CRYPTO_CIPHER_3DES_CBC,
446                                 .block_size = 8,
447                                 .key_size = {
448                                         .min = 16,
449                                         .max = 24,
450                                         .increment = 8
451                                 },
452                                 .iv_size = {
453                                         .min = 8,
454                                         .max = 8,
455                                         .increment = 0
456                                 }
457                         }, }
458                 }, }
459         },
460         {       /* SNOW 3G (UIA2) */
461                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
462                 {.sym = {
463                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
464                         {.auth = {
465                                 .algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2,
466                                 .block_size = 16,
467                                 .key_size = {
468                                         .min = 16,
469                                         .max = 16,
470                                         .increment = 0
471                                 },
472                                 .digest_size = {
473                                         .min = 4,
474                                         .max = 4,
475                                         .increment = 0
476                                 },
477                                 .iv_size = {
478                                         .min = 16,
479                                         .max = 16,
480                                         .increment = 0
481                                 }
482                         }, }
483                 }, }
484         },
485         {       /* SNOW 3G (UEA2) */
486                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
487                 {.sym = {
488                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
489                         {.cipher = {
490                                 .algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
491                                 .block_size = 16,
492                                 .key_size = {
493                                         .min = 16,
494                                         .max = 16,
495                                         .increment = 0
496                                 },
497                                 .iv_size = {
498                                         .min = 16,
499                                         .max = 16,
500                                         .increment = 0
501                                 }
502                         }, }
503                 }, }
504         },
505         {       /* ZUC (EEA3) */
506                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
507                 {.sym = {
508                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
509                         {.cipher = {
510                                 .algo = RTE_CRYPTO_CIPHER_ZUC_EEA3,
511                                 .block_size = 16,
512                                 .key_size = {
513                                         .min = 16,
514                                         .max = 16,
515                                         .increment = 0
516                                 },
517                                 .iv_size = {
518                                         .min = 16,
519                                         .max = 16,
520                                         .increment = 0
521                                 }
522                         }, }
523                 }, }
524         },
525         {       /* ZUC (EIA3) */
526                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
527                 {.sym = {
528                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
529                         {.auth = {
530                                 .algo = RTE_CRYPTO_AUTH_ZUC_EIA3,
531                                 .block_size = 16,
532                                 .key_size = {
533                                         .min = 16,
534                                         .max = 16,
535                                         .increment = 0
536                                 },
537                                 .digest_size = {
538                                         .min = 4,
539                                         .max = 4,
540                                         .increment = 0
541                                 },
542                                 .iv_size = {
543                                         .min = 16,
544                                         .max = 16,
545                                         .increment = 0
546                                 }
547                         }, }
548                 }, }
549         },
550         RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
551 };
552
553 #ifdef RTE_LIBRTE_SECURITY
554
555 static const struct rte_cryptodev_capabilities dpaa2_pdcp_capabilities[] = {
556         {       /* SNOW 3G (UIA2) */
557                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
558                 {.sym = {
559                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
560                         {.auth = {
561                                 .algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2,
562                                 .block_size = 16,
563                                 .key_size = {
564                                         .min = 16,
565                                         .max = 16,
566                                         .increment = 0
567                                 },
568                                 .digest_size = {
569                                         .min = 4,
570                                         .max = 4,
571                                         .increment = 0
572                                 },
573                                 .iv_size = {
574                                         .min = 16,
575                                         .max = 16,
576                                         .increment = 0
577                                 }
578                         }, }
579                 }, }
580         },
581         {       /* SNOW 3G (UEA2) */
582                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
583                 {.sym = {
584                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
585                         {.cipher = {
586                                 .algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
587                                 .block_size = 16,
588                                 .key_size = {
589                                         .min = 16,
590                                         .max = 16,
591                                         .increment = 0
592                                 },
593                                 .iv_size = {
594                                         .min = 16,
595                                         .max = 16,
596                                         .increment = 0
597                                 }
598                         }, }
599                 }, }
600         },
601         {       /* AES CTR */
602                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
603                 {.sym = {
604                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
605                         {.cipher = {
606                                 .algo = RTE_CRYPTO_CIPHER_AES_CTR,
607                                 .block_size = 16,
608                                 .key_size = {
609                                         .min = 16,
610                                         .max = 32,
611                                         .increment = 8
612                                 },
613                                 .iv_size = {
614                                         .min = 16,
615                                         .max = 16,
616                                         .increment = 0
617                                 }
618                         }, }
619                 }, }
620         },
621         {       /* NULL (AUTH) */
622                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
623                 {.sym = {
624                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
625                         {.auth = {
626                                 .algo = RTE_CRYPTO_AUTH_NULL,
627                                 .block_size = 1,
628                                 .key_size = {
629                                         .min = 0,
630                                         .max = 0,
631                                         .increment = 0
632                                 },
633                                 .digest_size = {
634                                         .min = 0,
635                                         .max = 0,
636                                         .increment = 0
637                                 },
638                                 .iv_size = { 0 }
639                         }, },
640                 }, },
641         },
642         {       /* NULL (CIPHER) */
643                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
644                 {.sym = {
645                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
646                         {.cipher = {
647                                 .algo = RTE_CRYPTO_CIPHER_NULL,
648                                 .block_size = 1,
649                                 .key_size = {
650                                         .min = 0,
651                                         .max = 0,
652                                         .increment = 0
653                                 },
654                                 .iv_size = {
655                                         .min = 0,
656                                         .max = 0,
657                                         .increment = 0
658                                 }
659                         }, },
660                 }, }
661         },
662         {       /* ZUC (EEA3) */
663                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
664                 {.sym = {
665                         .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
666                         {.cipher = {
667                                 .algo = RTE_CRYPTO_CIPHER_ZUC_EEA3,
668                                 .block_size = 16,
669                                 .key_size = {
670                                         .min = 16,
671                                         .max = 16,
672                                         .increment = 0
673                                 },
674                                 .iv_size = {
675                                         .min = 16,
676                                         .max = 16,
677                                         .increment = 0
678                                 }
679                         }, }
680                 }, }
681         },
682         {       /* ZUC (EIA3) */
683                 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
684                 {.sym = {
685                         .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
686                         {.auth = {
687                                 .algo = RTE_CRYPTO_AUTH_ZUC_EIA3,
688                                 .block_size = 16,
689                                 .key_size = {
690                                         .min = 16,
691                                         .max = 16,
692                                         .increment = 0
693                                 },
694                                 .digest_size = {
695                                         .min = 4,
696                                         .max = 4,
697                                         .increment = 0
698                                 },
699                                 .iv_size = {
700                                         .min = 16,
701                                         .max = 16,
702                                         .increment = 0
703                                 }
704                         }, }
705                 }, }
706         },
707
708         RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
709 };
710
711 static const struct rte_security_capability dpaa2_sec_security_cap[] = {
712         { /* IPsec Lookaside Protocol offload ESP Transport Egress */
713                 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
714                 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
715                 .ipsec = {
716                         .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
717                         .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
718                         .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
719                         .options = { 0 },
720                         .replay_win_sz_max = 128
721                 },
722                 .crypto_capabilities = dpaa2_sec_capabilities
723         },
724         { /* IPsec Lookaside Protocol offload ESP Tunnel Ingress */
725                 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
726                 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
727                 .ipsec = {
728                         .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
729                         .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
730                         .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
731                         .options = { 0 },
732                         .replay_win_sz_max = 128
733                 },
734                 .crypto_capabilities = dpaa2_sec_capabilities
735         },
736         { /* PDCP Lookaside Protocol offload Data */
737                 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
738                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
739                 .pdcp = {
740                         .domain = RTE_SECURITY_PDCP_MODE_DATA,
741                         .capa_flags = 0
742                 },
743                 .crypto_capabilities = dpaa2_pdcp_capabilities
744         },
745         { /* PDCP Lookaside Protocol offload Control */
746                 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
747                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
748                 .pdcp = {
749                         .domain = RTE_SECURITY_PDCP_MODE_CONTROL,
750                         .capa_flags = 0
751                 },
752                 .crypto_capabilities = dpaa2_pdcp_capabilities
753         },
754         {
755                 .action = RTE_SECURITY_ACTION_TYPE_NONE
756         }
757 };
758 #endif
759 /**
760  * Checksum
761  *
762  * @param buffer calculate chksum for buffer
763  * @param len    buffer length
764  *
765  * @return checksum value in host cpu order
766  */
767 static inline uint16_t
768 calc_chksum(void *buffer, int len)
769 {
770         uint16_t *buf = (uint16_t *)buffer;
771         uint32_t sum = 0;
772         uint16_t result;
773
774         for (sum = 0; len > 1; len -= 2)
775                 sum += *buf++;
776
777         if (len == 1)
778                 sum += *(unsigned char *)buf;
779
780         sum = (sum >> 16) + (sum & 0xFFFF);
781         sum += (sum >> 16);
782         result = ~sum;
783
784         return  result;
785 }
786
787 #endif /* _DPAA2_SEC_PMD_PRIVATE_H_ */