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