1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2021 Intel Corporation
5 #include "pmd_aesni_mb_priv.h"
8 * Calculate the authentication pre-computes
10 * @param one_block_hash Function pointer
11 * to calculate digest on ipad/opad
12 * @param ipad Inner pad output byte array
13 * @param opad Outer pad output byte array
14 * @param hkey Authentication key
15 * @param hkey_len Authentication key length
16 * @param blocksize Block size of selected hash algo
19 calculate_auth_precomputes(hash_one_block_t one_block_hash,
20 uint8_t *ipad, uint8_t *opad,
21 const uint8_t *hkey, uint16_t hkey_len,
26 uint8_t ipad_buf[blocksize] __rte_aligned(16);
27 uint8_t opad_buf[blocksize] __rte_aligned(16);
29 /* Setup inner and outer pads */
30 memset(ipad_buf, HMAC_IPAD_VALUE, blocksize);
31 memset(opad_buf, HMAC_OPAD_VALUE, blocksize);
33 /* XOR hash key with inner and outer pads */
34 length = hkey_len > blocksize ? blocksize : hkey_len;
36 for (i = 0; i < length; i++) {
37 ipad_buf[i] ^= hkey[i];
38 opad_buf[i] ^= hkey[i];
41 /* Compute partial hashes */
42 (*one_block_hash)(ipad_buf, ipad);
43 (*one_block_hash)(opad_buf, opad);
46 memset(ipad_buf, 0, blocksize);
47 memset(opad_buf, 0, blocksize);
51 is_aead_algo(IMB_HASH_ALG hash_alg, IMB_CIPHER_MODE cipher_mode)
53 return (hash_alg == IMB_AUTH_CHACHA20_POLY1305 ||
54 hash_alg == IMB_AUTH_AES_CCM ||
55 (hash_alg == IMB_AUTH_AES_GMAC &&
56 cipher_mode == IMB_CIPHER_GCM));
59 /** Set session authentication parameters */
61 aesni_mb_set_session_auth_parameters(const IMB_MGR *mb_mgr,
62 struct aesni_mb_session *sess,
63 const struct rte_crypto_sym_xform *xform)
65 hash_one_block_t hash_oneblock_fn = NULL;
66 unsigned int key_larger_block_size = 0;
67 uint8_t hashed_key[HMAC_MAX_BLOCK_SIZE] = { 0 };
68 uint32_t auth_precompute = 1;
71 sess->auth.algo = IMB_AUTH_NULL;
75 if (xform->type != RTE_CRYPTO_SYM_XFORM_AUTH) {
76 IPSEC_MB_LOG(ERR, "Crypto xform struct not of type auth");
80 /* Set IV parameters */
81 sess->auth_iv.offset = xform->auth.iv.offset;
82 sess->auth_iv.length = xform->auth.iv.length;
84 /* Set the request digest size */
85 sess->auth.req_digest_len = xform->auth.digest_length;
87 /* Select auth generate/verify */
88 sess->auth.operation = xform->auth.op;
90 /* Set Authentication Parameters */
91 if (xform->auth.algo == RTE_CRYPTO_AUTH_NULL) {
92 sess->auth.algo = IMB_AUTH_NULL;
93 sess->auth.gen_digest_len = 0;
97 if (xform->auth.algo == RTE_CRYPTO_AUTH_AES_XCBC_MAC) {
98 sess->auth.algo = IMB_AUTH_AES_XCBC;
100 uint16_t xcbc_mac_digest_len =
101 get_truncated_digest_byte_length(IMB_AUTH_AES_XCBC);
102 if (sess->auth.req_digest_len != xcbc_mac_digest_len) {
103 IPSEC_MB_LOG(ERR, "Invalid digest size\n");
106 sess->auth.gen_digest_len = sess->auth.req_digest_len;
108 IMB_AES_XCBC_KEYEXP(mb_mgr, xform->auth.key.data,
109 sess->auth.xcbc.k1_expanded,
110 sess->auth.xcbc.k2, sess->auth.xcbc.k3);
114 if (xform->auth.algo == RTE_CRYPTO_AUTH_AES_CMAC) {
117 sess->auth.algo = IMB_AUTH_AES_CMAC;
119 uint16_t cmac_digest_len =
120 get_digest_byte_length(IMB_AUTH_AES_CMAC);
122 if (sess->auth.req_digest_len > cmac_digest_len) {
123 IPSEC_MB_LOG(ERR, "Invalid digest size\n");
127 * Multi-buffer lib supports digest sizes from 4 to 16 bytes
128 * in version 0.50 and sizes of 12 and 16 bytes,
130 * If size requested is different, generate the full digest
131 * (16 bytes) in a temporary location and then memcpy
132 * the requested number of bytes.
134 if (sess->auth.req_digest_len < 4)
135 sess->auth.gen_digest_len = cmac_digest_len;
137 sess->auth.gen_digest_len = sess->auth.req_digest_len;
139 IMB_AES_KEYEXP_128(mb_mgr, xform->auth.key.data,
140 sess->auth.cmac.expkey, dust);
141 IMB_AES_CMAC_SUBKEY_GEN_128(mb_mgr, sess->auth.cmac.expkey,
142 sess->auth.cmac.skey1, sess->auth.cmac.skey2);
146 if (xform->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC) {
147 if (xform->auth.op == RTE_CRYPTO_AUTH_OP_GENERATE) {
148 sess->cipher.direction = IMB_DIR_ENCRYPT;
149 sess->chain_order = IMB_ORDER_CIPHER_HASH;
151 sess->cipher.direction = IMB_DIR_DECRYPT;
153 sess->auth.algo = IMB_AUTH_AES_GMAC;
154 if (sess->auth.req_digest_len >
155 get_digest_byte_length(IMB_AUTH_AES_GMAC)) {
156 IPSEC_MB_LOG(ERR, "Invalid digest size\n");
159 sess->auth.gen_digest_len = sess->auth.req_digest_len;
160 sess->iv.length = xform->auth.iv.length;
161 sess->iv.offset = xform->auth.iv.offset;
163 switch (xform->auth.key.length) {
164 case IMB_KEY_128_BYTES:
165 IMB_AES128_GCM_PRE(mb_mgr, xform->auth.key.data,
166 &sess->cipher.gcm_key);
167 sess->cipher.key_length_in_bytes = IMB_KEY_128_BYTES;
169 case IMB_KEY_192_BYTES:
170 IMB_AES192_GCM_PRE(mb_mgr, xform->auth.key.data,
171 &sess->cipher.gcm_key);
172 sess->cipher.key_length_in_bytes = IMB_KEY_192_BYTES;
174 case IMB_KEY_256_BYTES:
175 IMB_AES256_GCM_PRE(mb_mgr, xform->auth.key.data,
176 &sess->cipher.gcm_key);
177 sess->cipher.key_length_in_bytes = IMB_KEY_256_BYTES;
180 IPSEC_MB_LOG(ERR, "Invalid authentication key length\n");
187 if (xform->auth.algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
188 if (xform->auth.key.length == 16) {
189 sess->auth.algo = IMB_AUTH_ZUC_EIA3_BITLEN;
190 } else if (xform->auth.key.length == 32) {
191 sess->auth.algo = IMB_AUTH_ZUC256_EIA3_BITLEN;
193 IPSEC_MB_LOG(ERR, "Invalid authentication key length\n");
197 uint16_t zuc_eia3_digest_len =
198 get_truncated_digest_byte_length(
199 IMB_AUTH_ZUC_EIA3_BITLEN);
200 if (sess->auth.req_digest_len != zuc_eia3_digest_len) {
201 IPSEC_MB_LOG(ERR, "Invalid digest size\n");
204 sess->auth.gen_digest_len = sess->auth.req_digest_len;
206 memcpy(sess->auth.zuc_auth_key, xform->auth.key.data,
207 xform->auth.key.length);
209 } else if (xform->auth.algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2) {
210 sess->auth.algo = IMB_AUTH_SNOW3G_UIA2_BITLEN;
211 uint16_t snow3g_uia2_digest_len =
212 get_truncated_digest_byte_length(
213 IMB_AUTH_SNOW3G_UIA2_BITLEN);
214 if (sess->auth.req_digest_len != snow3g_uia2_digest_len) {
215 IPSEC_MB_LOG(ERR, "Invalid digest size\n");
218 sess->auth.gen_digest_len = sess->auth.req_digest_len;
220 IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr, xform->auth.key.data,
221 &sess->auth.pKeySched_snow3g_auth);
223 } else if (xform->auth.algo == RTE_CRYPTO_AUTH_KASUMI_F9) {
224 sess->auth.algo = IMB_AUTH_KASUMI_UIA1;
225 uint16_t kasumi_f9_digest_len =
226 get_truncated_digest_byte_length(IMB_AUTH_KASUMI_UIA1);
227 if (sess->auth.req_digest_len != kasumi_f9_digest_len) {
228 IPSEC_MB_LOG(ERR, "Invalid digest size\n");
231 sess->auth.gen_digest_len = sess->auth.req_digest_len;
233 IMB_KASUMI_INIT_F9_KEY_SCHED(mb_mgr, xform->auth.key.data,
234 &sess->auth.pKeySched_kasumi_auth);
238 switch (xform->auth.algo) {
239 case RTE_CRYPTO_AUTH_MD5_HMAC:
240 sess->auth.algo = IMB_AUTH_MD5;
241 hash_oneblock_fn = mb_mgr->md5_one_block;
243 case RTE_CRYPTO_AUTH_SHA1_HMAC:
244 sess->auth.algo = IMB_AUTH_HMAC_SHA_1;
245 hash_oneblock_fn = mb_mgr->sha1_one_block;
246 if (xform->auth.key.length > get_auth_algo_blocksize(
247 IMB_AUTH_HMAC_SHA_1)) {
249 xform->auth.key.data,
250 xform->auth.key.length,
252 key_larger_block_size = 1;
255 case RTE_CRYPTO_AUTH_SHA1:
256 sess->auth.algo = IMB_AUTH_SHA_1;
259 case RTE_CRYPTO_AUTH_SHA224_HMAC:
260 sess->auth.algo = IMB_AUTH_HMAC_SHA_224;
261 hash_oneblock_fn = mb_mgr->sha224_one_block;
262 if (xform->auth.key.length > get_auth_algo_blocksize(
263 IMB_AUTH_HMAC_SHA_224)) {
265 xform->auth.key.data,
266 xform->auth.key.length,
268 key_larger_block_size = 1;
271 case RTE_CRYPTO_AUTH_SHA224:
272 sess->auth.algo = IMB_AUTH_SHA_224;
275 case RTE_CRYPTO_AUTH_SHA256_HMAC:
276 sess->auth.algo = IMB_AUTH_HMAC_SHA_256;
277 hash_oneblock_fn = mb_mgr->sha256_one_block;
278 if (xform->auth.key.length > get_auth_algo_blocksize(
279 IMB_AUTH_HMAC_SHA_256)) {
281 xform->auth.key.data,
282 xform->auth.key.length,
284 key_larger_block_size = 1;
287 case RTE_CRYPTO_AUTH_SHA256:
288 sess->auth.algo = IMB_AUTH_SHA_256;
291 case RTE_CRYPTO_AUTH_SHA384_HMAC:
292 sess->auth.algo = IMB_AUTH_HMAC_SHA_384;
293 hash_oneblock_fn = mb_mgr->sha384_one_block;
294 if (xform->auth.key.length > get_auth_algo_blocksize(
295 IMB_AUTH_HMAC_SHA_384)) {
297 xform->auth.key.data,
298 xform->auth.key.length,
300 key_larger_block_size = 1;
303 case RTE_CRYPTO_AUTH_SHA384:
304 sess->auth.algo = IMB_AUTH_SHA_384;
307 case RTE_CRYPTO_AUTH_SHA512_HMAC:
308 sess->auth.algo = IMB_AUTH_HMAC_SHA_512;
309 hash_oneblock_fn = mb_mgr->sha512_one_block;
310 if (xform->auth.key.length > get_auth_algo_blocksize(
311 IMB_AUTH_HMAC_SHA_512)) {
313 xform->auth.key.data,
314 xform->auth.key.length,
316 key_larger_block_size = 1;
319 case RTE_CRYPTO_AUTH_SHA512:
320 sess->auth.algo = IMB_AUTH_SHA_512;
325 "Unsupported authentication algorithm selection");
328 uint16_t trunc_digest_size =
329 get_truncated_digest_byte_length(sess->auth.algo);
330 uint16_t full_digest_size =
331 get_digest_byte_length(sess->auth.algo);
333 if (sess->auth.req_digest_len > full_digest_size ||
334 sess->auth.req_digest_len == 0) {
335 IPSEC_MB_LOG(ERR, "Invalid digest size\n");
339 if (sess->auth.req_digest_len != trunc_digest_size &&
340 sess->auth.req_digest_len != full_digest_size)
341 sess->auth.gen_digest_len = full_digest_size;
343 sess->auth.gen_digest_len = sess->auth.req_digest_len;
345 /* Plain SHA does not require precompute key */
346 if (auth_precompute == 0)
349 /* Calculate Authentication precomputes */
350 if (key_larger_block_size) {
351 calculate_auth_precomputes(hash_oneblock_fn,
352 sess->auth.pads.inner, sess->auth.pads.outer,
354 xform->auth.key.length,
355 get_auth_algo_blocksize(sess->auth.algo));
357 calculate_auth_precomputes(hash_oneblock_fn,
358 sess->auth.pads.inner, sess->auth.pads.outer,
359 xform->auth.key.data,
360 xform->auth.key.length,
361 get_auth_algo_blocksize(sess->auth.algo));
367 /** Set session cipher parameters */
369 aesni_mb_set_session_cipher_parameters(const IMB_MGR *mb_mgr,
370 struct aesni_mb_session *sess,
371 const struct rte_crypto_sym_xform *xform)
375 uint8_t is_docsis = 0;
377 uint8_t is_snow3g = 0;
378 uint8_t is_kasumi = 0;
381 sess->cipher.mode = IMB_CIPHER_NULL;
385 if (xform->type != RTE_CRYPTO_SYM_XFORM_CIPHER) {
386 IPSEC_MB_LOG(ERR, "Crypto xform struct not of type cipher");
390 /* Select cipher direction */
391 switch (xform->cipher.op) {
392 case RTE_CRYPTO_CIPHER_OP_ENCRYPT:
393 sess->cipher.direction = IMB_DIR_ENCRYPT;
395 case RTE_CRYPTO_CIPHER_OP_DECRYPT:
396 sess->cipher.direction = IMB_DIR_DECRYPT;
399 IPSEC_MB_LOG(ERR, "Invalid cipher operation parameter");
403 /* Select cipher mode */
404 switch (xform->cipher.algo) {
405 case RTE_CRYPTO_CIPHER_AES_CBC:
406 sess->cipher.mode = IMB_CIPHER_CBC;
409 case RTE_CRYPTO_CIPHER_AES_CTR:
410 sess->cipher.mode = IMB_CIPHER_CNTR;
413 case RTE_CRYPTO_CIPHER_AES_DOCSISBPI:
414 sess->cipher.mode = IMB_CIPHER_DOCSIS_SEC_BPI;
417 case RTE_CRYPTO_CIPHER_DES_CBC:
418 sess->cipher.mode = IMB_CIPHER_DES;
420 case RTE_CRYPTO_CIPHER_DES_DOCSISBPI:
421 sess->cipher.mode = IMB_CIPHER_DOCSIS_DES;
423 case RTE_CRYPTO_CIPHER_3DES_CBC:
424 sess->cipher.mode = IMB_CIPHER_DES3;
427 case RTE_CRYPTO_CIPHER_AES_ECB:
428 sess->cipher.mode = IMB_CIPHER_ECB;
431 case RTE_CRYPTO_CIPHER_ZUC_EEA3:
432 sess->cipher.mode = IMB_CIPHER_ZUC_EEA3;
435 case RTE_CRYPTO_CIPHER_SNOW3G_UEA2:
436 sess->cipher.mode = IMB_CIPHER_SNOW3G_UEA2_BITLEN;
439 case RTE_CRYPTO_CIPHER_KASUMI_F8:
440 sess->cipher.mode = IMB_CIPHER_KASUMI_UEA1_BITLEN;
443 case RTE_CRYPTO_CIPHER_NULL:
444 sess->cipher.mode = IMB_CIPHER_NULL;
445 sess->cipher.key_length_in_bytes = 0;
446 sess->iv.offset = xform->cipher.iv.offset;
447 sess->iv.length = xform->cipher.iv.length;
450 IPSEC_MB_LOG(ERR, "Unsupported cipher mode parameter");
454 /* Set IV parameters */
455 sess->iv.offset = xform->cipher.iv.offset;
456 sess->iv.length = xform->cipher.iv.length;
458 /* Check key length and choose key expansion function for AES */
460 switch (xform->cipher.key.length) {
461 case IMB_KEY_128_BYTES:
462 sess->cipher.key_length_in_bytes = IMB_KEY_128_BYTES;
463 IMB_AES_KEYEXP_128(mb_mgr, xform->cipher.key.data,
464 sess->cipher.expanded_aes_keys.encode,
465 sess->cipher.expanded_aes_keys.decode);
467 case IMB_KEY_192_BYTES:
468 sess->cipher.key_length_in_bytes = IMB_KEY_192_BYTES;
469 IMB_AES_KEYEXP_192(mb_mgr, xform->cipher.key.data,
470 sess->cipher.expanded_aes_keys.encode,
471 sess->cipher.expanded_aes_keys.decode);
473 case IMB_KEY_256_BYTES:
474 sess->cipher.key_length_in_bytes = IMB_KEY_256_BYTES;
475 IMB_AES_KEYEXP_256(mb_mgr, xform->cipher.key.data,
476 sess->cipher.expanded_aes_keys.encode,
477 sess->cipher.expanded_aes_keys.decode);
480 IPSEC_MB_LOG(ERR, "Invalid cipher key length");
483 } else if (is_docsis) {
484 switch (xform->cipher.key.length) {
485 case IMB_KEY_128_BYTES:
486 sess->cipher.key_length_in_bytes = IMB_KEY_128_BYTES;
487 IMB_AES_KEYEXP_128(mb_mgr, xform->cipher.key.data,
488 sess->cipher.expanded_aes_keys.encode,
489 sess->cipher.expanded_aes_keys.decode);
491 case IMB_KEY_256_BYTES:
492 sess->cipher.key_length_in_bytes = IMB_KEY_256_BYTES;
493 IMB_AES_KEYEXP_256(mb_mgr, xform->cipher.key.data,
494 sess->cipher.expanded_aes_keys.encode,
495 sess->cipher.expanded_aes_keys.decode);
498 IPSEC_MB_LOG(ERR, "Invalid cipher key length");
501 } else if (is_3DES) {
502 uint64_t *keys[3] = {sess->cipher.exp_3des_keys.key[0],
503 sess->cipher.exp_3des_keys.key[1],
504 sess->cipher.exp_3des_keys.key[2]};
506 switch (xform->cipher.key.length) {
508 IMB_DES_KEYSCHED(mb_mgr, keys[0],
509 xform->cipher.key.data);
510 IMB_DES_KEYSCHED(mb_mgr, keys[1],
511 xform->cipher.key.data + 8);
512 IMB_DES_KEYSCHED(mb_mgr, keys[2],
513 xform->cipher.key.data + 16);
515 /* Initialize keys - 24 bytes: [K1-K2-K3] */
516 sess->cipher.exp_3des_keys.ks_ptr[0] = keys[0];
517 sess->cipher.exp_3des_keys.ks_ptr[1] = keys[1];
518 sess->cipher.exp_3des_keys.ks_ptr[2] = keys[2];
521 IMB_DES_KEYSCHED(mb_mgr, keys[0],
522 xform->cipher.key.data);
523 IMB_DES_KEYSCHED(mb_mgr, keys[1],
524 xform->cipher.key.data + 8);
525 /* Initialize keys - 16 bytes: [K1=K1,K2=K2,K3=K1] */
526 sess->cipher.exp_3des_keys.ks_ptr[0] = keys[0];
527 sess->cipher.exp_3des_keys.ks_ptr[1] = keys[1];
528 sess->cipher.exp_3des_keys.ks_ptr[2] = keys[0];
531 IMB_DES_KEYSCHED(mb_mgr, keys[0],
532 xform->cipher.key.data);
534 /* Initialize keys - 8 bytes: [K1 = K2 = K3] */
535 sess->cipher.exp_3des_keys.ks_ptr[0] = keys[0];
536 sess->cipher.exp_3des_keys.ks_ptr[1] = keys[0];
537 sess->cipher.exp_3des_keys.ks_ptr[2] = keys[0];
540 IPSEC_MB_LOG(ERR, "Invalid cipher key length");
544 sess->cipher.key_length_in_bytes = 24;
546 if (xform->cipher.key.length != 16 &&
547 xform->cipher.key.length != 32) {
548 IPSEC_MB_LOG(ERR, "Invalid cipher key length");
551 sess->cipher.key_length_in_bytes = xform->cipher.key.length;
552 memcpy(sess->cipher.zuc_cipher_key, xform->cipher.key.data,
553 xform->cipher.key.length);
554 } else if (is_snow3g) {
555 if (xform->cipher.key.length != 16) {
556 IPSEC_MB_LOG(ERR, "Invalid cipher key length");
559 sess->cipher.key_length_in_bytes = 16;
560 IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr, xform->cipher.key.data,
561 &sess->cipher.pKeySched_snow3g_cipher);
562 } else if (is_kasumi) {
563 if (xform->cipher.key.length != 16) {
564 IPSEC_MB_LOG(ERR, "Invalid cipher key length");
567 sess->cipher.key_length_in_bytes = 16;
568 IMB_KASUMI_INIT_F8_KEY_SCHED(mb_mgr, xform->cipher.key.data,
569 &sess->cipher.pKeySched_kasumi_cipher);
571 if (xform->cipher.key.length != 8) {
572 IPSEC_MB_LOG(ERR, "Invalid cipher key length");
575 sess->cipher.key_length_in_bytes = 8;
577 IMB_DES_KEYSCHED(mb_mgr,
578 (uint64_t *)sess->cipher.expanded_aes_keys.encode,
579 xform->cipher.key.data);
580 IMB_DES_KEYSCHED(mb_mgr,
581 (uint64_t *)sess->cipher.expanded_aes_keys.decode,
582 xform->cipher.key.data);
589 aesni_mb_set_session_aead_parameters(const IMB_MGR *mb_mgr,
590 struct aesni_mb_session *sess,
591 const struct rte_crypto_sym_xform *xform)
593 switch (xform->aead.op) {
594 case RTE_CRYPTO_AEAD_OP_ENCRYPT:
595 sess->cipher.direction = IMB_DIR_ENCRYPT;
596 sess->auth.operation = RTE_CRYPTO_AUTH_OP_GENERATE;
598 case RTE_CRYPTO_AEAD_OP_DECRYPT:
599 sess->cipher.direction = IMB_DIR_DECRYPT;
600 sess->auth.operation = RTE_CRYPTO_AUTH_OP_VERIFY;
603 IPSEC_MB_LOG(ERR, "Invalid aead operation parameter");
607 /* Set IV parameters */
608 sess->iv.offset = xform->aead.iv.offset;
609 sess->iv.length = xform->aead.iv.length;
611 /* Set digest sizes */
612 sess->auth.req_digest_len = xform->aead.digest_length;
613 sess->auth.gen_digest_len = sess->auth.req_digest_len;
615 switch (xform->aead.algo) {
616 case RTE_CRYPTO_AEAD_AES_CCM:
617 sess->cipher.mode = IMB_CIPHER_CCM;
618 sess->auth.algo = IMB_AUTH_AES_CCM;
620 /* Check key length and choose key expansion function for AES */
621 switch (xform->aead.key.length) {
622 case IMB_KEY_128_BYTES:
623 sess->cipher.key_length_in_bytes = IMB_KEY_128_BYTES;
624 IMB_AES_KEYEXP_128(mb_mgr, xform->aead.key.data,
625 sess->cipher.expanded_aes_keys.encode,
626 sess->cipher.expanded_aes_keys.decode);
628 case IMB_KEY_256_BYTES:
629 sess->cipher.key_length_in_bytes = IMB_KEY_256_BYTES;
630 IMB_AES_KEYEXP_256(mb_mgr, xform->aead.key.data,
631 sess->cipher.expanded_aes_keys.encode,
632 sess->cipher.expanded_aes_keys.decode);
635 IPSEC_MB_LOG(ERR, "Invalid cipher key length");
639 /* CCM digests must be between 4 and 16 and an even number */
640 if (sess->auth.req_digest_len < AES_CCM_DIGEST_MIN_LEN ||
641 sess->auth.req_digest_len > AES_CCM_DIGEST_MAX_LEN ||
642 (sess->auth.req_digest_len & 1) == 1) {
643 IPSEC_MB_LOG(ERR, "Invalid digest size\n");
648 case RTE_CRYPTO_AEAD_AES_GCM:
649 sess->cipher.mode = IMB_CIPHER_GCM;
650 sess->auth.algo = IMB_AUTH_AES_GMAC;
652 switch (xform->aead.key.length) {
653 case IMB_KEY_128_BYTES:
654 sess->cipher.key_length_in_bytes = IMB_KEY_128_BYTES;
655 IMB_AES128_GCM_PRE(mb_mgr, xform->aead.key.data,
656 &sess->cipher.gcm_key);
658 case IMB_KEY_192_BYTES:
659 sess->cipher.key_length_in_bytes = IMB_KEY_192_BYTES;
660 IMB_AES192_GCM_PRE(mb_mgr, xform->aead.key.data,
661 &sess->cipher.gcm_key);
663 case IMB_KEY_256_BYTES:
664 sess->cipher.key_length_in_bytes = IMB_KEY_256_BYTES;
665 IMB_AES256_GCM_PRE(mb_mgr, xform->aead.key.data,
666 &sess->cipher.gcm_key);
669 IPSEC_MB_LOG(ERR, "Invalid cipher key length");
673 /* GCM digest size must be between 1 and 16 */
674 if (sess->auth.req_digest_len == 0 ||
675 sess->auth.req_digest_len > 16) {
676 IPSEC_MB_LOG(ERR, "Invalid digest size\n");
681 case RTE_CRYPTO_AEAD_CHACHA20_POLY1305:
682 sess->cipher.mode = IMB_CIPHER_CHACHA20_POLY1305;
683 sess->auth.algo = IMB_AUTH_CHACHA20_POLY1305;
685 if (xform->aead.key.length != 32) {
686 IPSEC_MB_LOG(ERR, "Invalid key length");
689 sess->cipher.key_length_in_bytes = 32;
690 memcpy(sess->cipher.expanded_aes_keys.encode,
691 xform->aead.key.data, 32);
692 if (sess->auth.req_digest_len != 16) {
693 IPSEC_MB_LOG(ERR, "Invalid digest size\n");
698 IPSEC_MB_LOG(ERR, "Unsupported aead mode parameter");
705 /** Configure a aesni multi-buffer session from a crypto xform chain */
707 aesni_mb_session_configure(IMB_MGR *mb_mgr,
709 const struct rte_crypto_sym_xform *xform)
711 const struct rte_crypto_sym_xform *auth_xform = NULL;
712 const struct rte_crypto_sym_xform *cipher_xform = NULL;
713 const struct rte_crypto_sym_xform *aead_xform = NULL;
714 enum ipsec_mb_operation mode;
715 struct aesni_mb_session *sess = (struct aesni_mb_session *) priv_sess;
718 ret = ipsec_mb_parse_xform(xform, &mode, &auth_xform,
719 &cipher_xform, &aead_xform);
723 /* Select Crypto operation - hash then cipher / cipher then hash */
725 case IPSEC_MB_OP_HASH_VERIFY_THEN_DECRYPT:
726 sess->chain_order = IMB_ORDER_HASH_CIPHER;
728 case IPSEC_MB_OP_ENCRYPT_THEN_HASH_GEN:
729 case IPSEC_MB_OP_DECRYPT_THEN_HASH_VERIFY:
730 sess->chain_order = IMB_ORDER_CIPHER_HASH;
732 case IPSEC_MB_OP_HASH_GEN_ONLY:
733 case IPSEC_MB_OP_HASH_VERIFY_ONLY:
734 case IPSEC_MB_OP_HASH_GEN_THEN_ENCRYPT:
735 sess->chain_order = IMB_ORDER_HASH_CIPHER;
738 * Multi buffer library operates only at two modes,
739 * IMB_ORDER_CIPHER_HASH and IMB_ORDER_HASH_CIPHER.
740 * When doing ciphering only, chain order depends
741 * on cipher operation: encryption is always
742 * the first operation and decryption the last one.
744 case IPSEC_MB_OP_ENCRYPT_ONLY:
745 sess->chain_order = IMB_ORDER_CIPHER_HASH;
747 case IPSEC_MB_OP_DECRYPT_ONLY:
748 sess->chain_order = IMB_ORDER_HASH_CIPHER;
750 case IPSEC_MB_OP_AEAD_AUTHENTICATED_ENCRYPT:
751 sess->chain_order = IMB_ORDER_CIPHER_HASH;
752 sess->aead.aad_len = xform->aead.aad_length;
754 case IPSEC_MB_OP_AEAD_AUTHENTICATED_DECRYPT:
755 sess->chain_order = IMB_ORDER_HASH_CIPHER;
756 sess->aead.aad_len = xform->aead.aad_length;
758 case IPSEC_MB_OP_NOT_SUPPORTED:
761 "Unsupported operation chain order parameter");
765 /* Default IV length = 0 */
767 sess->auth_iv.length = 0;
769 ret = aesni_mb_set_session_auth_parameters(mb_mgr, sess, auth_xform);
772 "Invalid/unsupported authentication parameters");
776 ret = aesni_mb_set_session_cipher_parameters(mb_mgr, sess,
779 IPSEC_MB_LOG(ERR, "Invalid/unsupported cipher parameters");
784 ret = aesni_mb_set_session_aead_parameters(mb_mgr, sess,
788 "Invalid/unsupported aead parameters");
796 #ifdef AESNI_MB_DOCSIS_SEC_ENABLED
797 /** Check DOCSIS security session configuration is valid */
799 check_docsis_sec_session(struct rte_security_session_conf *conf)
801 struct rte_crypto_sym_xform *crypto_sym = conf->crypto_xform;
802 struct rte_security_docsis_xform *docsis = &conf->docsis;
804 /* Downlink: CRC generate -> Cipher encrypt */
805 if (docsis->direction == RTE_SECURITY_DOCSIS_DOWNLINK) {
807 if (crypto_sym != NULL &&
808 crypto_sym->type == RTE_CRYPTO_SYM_XFORM_CIPHER &&
809 crypto_sym->cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT &&
810 crypto_sym->cipher.algo ==
811 RTE_CRYPTO_CIPHER_AES_DOCSISBPI &&
812 (crypto_sym->cipher.key.length == IMB_KEY_128_BYTES ||
813 crypto_sym->cipher.key.length == IMB_KEY_256_BYTES) &&
814 crypto_sym->cipher.iv.length == IMB_AES_BLOCK_SIZE &&
815 crypto_sym->next == NULL) {
818 /* Uplink: Cipher decrypt -> CRC verify */
819 } else if (docsis->direction == RTE_SECURITY_DOCSIS_UPLINK) {
821 if (crypto_sym != NULL &&
822 crypto_sym->type == RTE_CRYPTO_SYM_XFORM_CIPHER &&
823 crypto_sym->cipher.op == RTE_CRYPTO_CIPHER_OP_DECRYPT &&
824 crypto_sym->cipher.algo ==
825 RTE_CRYPTO_CIPHER_AES_DOCSISBPI &&
826 (crypto_sym->cipher.key.length == IMB_KEY_128_BYTES ||
827 crypto_sym->cipher.key.length == IMB_KEY_256_BYTES) &&
828 crypto_sym->cipher.iv.length == IMB_AES_BLOCK_SIZE &&
829 crypto_sym->next == NULL) {
837 /** Set DOCSIS security session auth (CRC) parameters */
839 aesni_mb_set_docsis_sec_session_auth_parameters(struct aesni_mb_session *sess,
840 struct rte_security_docsis_xform *xform)
843 IPSEC_MB_LOG(ERR, "Invalid DOCSIS xform");
847 /* Select CRC generate/verify */
848 if (xform->direction == RTE_SECURITY_DOCSIS_UPLINK) {
849 sess->auth.algo = IMB_AUTH_DOCSIS_CRC32;
850 sess->auth.operation = RTE_CRYPTO_AUTH_OP_VERIFY;
851 } else if (xform->direction == RTE_SECURITY_DOCSIS_DOWNLINK) {
852 sess->auth.algo = IMB_AUTH_DOCSIS_CRC32;
853 sess->auth.operation = RTE_CRYPTO_AUTH_OP_GENERATE;
855 IPSEC_MB_LOG(ERR, "Unsupported DOCSIS direction");
859 sess->auth.req_digest_len = RTE_ETHER_CRC_LEN;
860 sess->auth.gen_digest_len = RTE_ETHER_CRC_LEN;
866 * Parse DOCSIS security session configuration and set private session
870 aesni_mb_set_docsis_sec_session_parameters(
871 __rte_unused struct rte_cryptodev *dev,
872 struct rte_security_session_conf *conf,
875 IMB_MGR *mb_mgr = alloc_init_mb_mgr();
876 struct rte_security_docsis_xform *docsis_xform;
877 struct rte_crypto_sym_xform *cipher_xform;
878 struct aesni_mb_session *ipsec_sess = sess;
884 ret = check_docsis_sec_session(conf);
886 IPSEC_MB_LOG(ERR, "Unsupported DOCSIS security configuration");
890 switch (conf->docsis.direction) {
891 case RTE_SECURITY_DOCSIS_UPLINK:
892 ipsec_sess->chain_order = IMB_ORDER_CIPHER_HASH;
893 docsis_xform = &conf->docsis;
894 cipher_xform = conf->crypto_xform;
896 case RTE_SECURITY_DOCSIS_DOWNLINK:
897 ipsec_sess->chain_order = IMB_ORDER_HASH_CIPHER;
898 cipher_xform = conf->crypto_xform;
899 docsis_xform = &conf->docsis;
902 IPSEC_MB_LOG(ERR, "Unsupported DOCSIS security configuration");
907 /* Default IV length = 0 */
908 ipsec_sess->iv.length = 0;
910 ret = aesni_mb_set_docsis_sec_session_auth_parameters(ipsec_sess,
913 IPSEC_MB_LOG(ERR, "Invalid/unsupported DOCSIS parameters");
917 ret = aesni_mb_set_session_cipher_parameters(mb_mgr,
918 ipsec_sess, cipher_xform);
921 IPSEC_MB_LOG(ERR, "Invalid/unsupported cipher parameters");
931 static inline uint64_t
932 auth_start_offset(struct rte_crypto_op *op, struct aesni_mb_session *session,
935 struct rte_mbuf *m_src, *m_dst;
936 uint8_t *p_src, *p_dst;
937 uintptr_t u_src, u_dst;
938 uint32_t cipher_end, auth_end;
940 /* Only cipher then hash needs special calculation. */
941 if (!oop || session->chain_order != IMB_ORDER_CIPHER_HASH)
942 return op->sym->auth.data.offset;
944 m_src = op->sym->m_src;
945 m_dst = op->sym->m_dst;
947 p_src = rte_pktmbuf_mtod(m_src, uint8_t *);
948 p_dst = rte_pktmbuf_mtod(m_dst, uint8_t *);
949 u_src = (uintptr_t)p_src;
950 u_dst = (uintptr_t)p_dst + op->sym->auth.data.offset;
953 * Copy the content between cipher offset and auth offset for generating
956 if (op->sym->cipher.data.offset > op->sym->auth.data.offset)
957 memcpy(p_dst + op->sym->auth.data.offset,
958 p_src + op->sym->auth.data.offset,
959 op->sym->cipher.data.offset -
960 op->sym->auth.data.offset);
963 * Copy the content between (cipher offset + length) and (auth offset +
964 * length) for generating correct digest
966 cipher_end = op->sym->cipher.data.offset + op->sym->cipher.data.length;
967 auth_end = op->sym->auth.data.offset + op->sym->auth.data.length;
968 if (cipher_end < auth_end)
969 memcpy(p_dst + cipher_end, p_src + cipher_end,
970 auth_end - cipher_end);
973 * Since intel-ipsec-mb only supports positive values,
974 * we need to deduct the correct offset between src and dst.
977 return u_src < u_dst ? (u_dst - u_src) :
978 (UINT64_MAX - u_src + u_dst + 1);
982 set_cpu_mb_job_params(IMB_JOB *job, struct aesni_mb_session *session,
983 union rte_crypto_sym_ofs sofs, void *buf, uint32_t len,
984 struct rte_crypto_va_iova_ptr *iv,
985 struct rte_crypto_va_iova_ptr *aad, void *digest, void *udata)
987 /* Set crypto operation */
988 job->chain_order = session->chain_order;
990 /* Set cipher parameters */
991 job->cipher_direction = session->cipher.direction;
992 job->cipher_mode = session->cipher.mode;
994 job->key_len_in_bytes = session->cipher.key_length_in_bytes;
996 /* Set authentication parameters */
997 job->hash_alg = session->auth.algo;
1000 switch (job->hash_alg) {
1001 case IMB_AUTH_AES_XCBC:
1002 job->u.XCBC._k1_expanded = session->auth.xcbc.k1_expanded;
1003 job->u.XCBC._k2 = session->auth.xcbc.k2;
1004 job->u.XCBC._k3 = session->auth.xcbc.k3;
1006 job->enc_keys = session->cipher.expanded_aes_keys.encode;
1007 job->dec_keys = session->cipher.expanded_aes_keys.decode;
1010 case IMB_AUTH_AES_CCM:
1011 job->u.CCM.aad = (uint8_t *)aad->va + 18;
1012 job->u.CCM.aad_len_in_bytes = session->aead.aad_len;
1013 job->enc_keys = session->cipher.expanded_aes_keys.encode;
1014 job->dec_keys = session->cipher.expanded_aes_keys.decode;
1018 case IMB_AUTH_AES_CMAC:
1019 job->u.CMAC._key_expanded = session->auth.cmac.expkey;
1020 job->u.CMAC._skey1 = session->auth.cmac.skey1;
1021 job->u.CMAC._skey2 = session->auth.cmac.skey2;
1022 job->enc_keys = session->cipher.expanded_aes_keys.encode;
1023 job->dec_keys = session->cipher.expanded_aes_keys.decode;
1026 case IMB_AUTH_AES_GMAC:
1027 if (session->cipher.mode == IMB_CIPHER_GCM) {
1028 job->u.GCM.aad = aad->va;
1029 job->u.GCM.aad_len_in_bytes = session->aead.aad_len;
1032 job->u.GCM.aad = buf;
1033 job->u.GCM.aad_len_in_bytes = len;
1034 job->cipher_mode = IMB_CIPHER_GCM;
1036 job->enc_keys = &session->cipher.gcm_key;
1037 job->dec_keys = &session->cipher.gcm_key;
1040 case IMB_AUTH_CHACHA20_POLY1305:
1041 job->u.CHACHA20_POLY1305.aad = aad->va;
1042 job->u.CHACHA20_POLY1305.aad_len_in_bytes =
1043 session->aead.aad_len;
1044 job->enc_keys = session->cipher.expanded_aes_keys.encode;
1045 job->dec_keys = session->cipher.expanded_aes_keys.encode;
1048 job->u.HMAC._hashed_auth_key_xor_ipad =
1049 session->auth.pads.inner;
1050 job->u.HMAC._hashed_auth_key_xor_opad =
1051 session->auth.pads.outer;
1053 if (job->cipher_mode == IMB_CIPHER_DES3) {
1054 job->enc_keys = session->cipher.exp_3des_keys.ks_ptr;
1055 job->dec_keys = session->cipher.exp_3des_keys.ks_ptr;
1057 job->enc_keys = session->cipher.expanded_aes_keys.encode;
1058 job->dec_keys = session->cipher.expanded_aes_keys.decode;
1063 * Multi-buffer library current only support returning a truncated
1064 * digest length as specified in the relevant IPsec RFCs
1067 /* Set digest location and length */
1068 job->auth_tag_output = digest;
1069 job->auth_tag_output_len_in_bytes = session->auth.gen_digest_len;
1071 /* Set IV parameters */
1072 job->iv_len_in_bytes = session->iv.length;
1074 /* Data Parameters */
1076 job->dst = (uint8_t *)buf + sofs.ofs.cipher.head;
1077 job->cipher_start_src_offset_in_bytes = sofs.ofs.cipher.head;
1078 job->hash_start_src_offset_in_bytes = sofs.ofs.auth.head;
1079 if (job->hash_alg == IMB_AUTH_AES_GMAC &&
1080 session->cipher.mode != IMB_CIPHER_GCM) {
1081 job->msg_len_to_hash_in_bytes = 0;
1082 job->msg_len_to_cipher_in_bytes = 0;
1084 job->msg_len_to_hash_in_bytes = len - sofs.ofs.auth.head -
1086 job->msg_len_to_cipher_in_bytes = len - sofs.ofs.cipher.head -
1087 sofs.ofs.cipher.tail;
1090 job->user_data = udata;
1094 * Process a crypto operation and complete a IMB_JOB job structure for
1095 * submission to the multi buffer library for processing.
1097 * @param qp queue pair
1098 * @param job IMB_JOB structure to fill
1099 * @param op crypto op to process
1100 * @param digest_idx ID for digest to use
1103 * - 0 on success, the IMB_JOB will be filled
1104 * - -1 if invalid session, IMB_JOB will not be filled
1107 set_mb_job_params(IMB_JOB *job, struct ipsec_mb_qp *qp,
1108 struct rte_crypto_op *op, uint8_t *digest_idx)
1110 struct rte_mbuf *m_src = op->sym->m_src, *m_dst;
1111 struct aesni_mb_qp_data *qp_data = ipsec_mb_get_qp_private_data(qp);
1112 struct aesni_mb_session *session;
1113 uint32_t m_offset, oop;
1115 session = ipsec_mb_get_session_private(qp, op);
1116 if (session == NULL) {
1117 op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
1121 /* Set crypto operation */
1122 job->chain_order = session->chain_order;
1124 /* Set cipher parameters */
1125 job->cipher_direction = session->cipher.direction;
1126 job->cipher_mode = session->cipher.mode;
1128 job->key_len_in_bytes = session->cipher.key_length_in_bytes;
1130 /* Set authentication parameters */
1131 job->hash_alg = session->auth.algo;
1133 const int aead = is_aead_algo(job->hash_alg, job->cipher_mode);
1135 if (job->cipher_mode == IMB_CIPHER_DES3) {
1136 job->enc_keys = session->cipher.exp_3des_keys.ks_ptr;
1137 job->dec_keys = session->cipher.exp_3des_keys.ks_ptr;
1139 job->enc_keys = session->cipher.expanded_aes_keys.encode;
1140 job->dec_keys = session->cipher.expanded_aes_keys.decode;
1143 switch (job->hash_alg) {
1144 case IMB_AUTH_AES_XCBC:
1145 job->u.XCBC._k1_expanded = session->auth.xcbc.k1_expanded;
1146 job->u.XCBC._k2 = session->auth.xcbc.k2;
1147 job->u.XCBC._k3 = session->auth.xcbc.k3;
1149 job->enc_keys = session->cipher.expanded_aes_keys.encode;
1150 job->dec_keys = session->cipher.expanded_aes_keys.decode;
1153 case IMB_AUTH_AES_CCM:
1154 job->u.CCM.aad = op->sym->aead.aad.data + 18;
1155 job->u.CCM.aad_len_in_bytes = session->aead.aad_len;
1156 job->enc_keys = session->cipher.expanded_aes_keys.encode;
1157 job->dec_keys = session->cipher.expanded_aes_keys.decode;
1160 case IMB_AUTH_AES_CMAC:
1161 job->u.CMAC._key_expanded = session->auth.cmac.expkey;
1162 job->u.CMAC._skey1 = session->auth.cmac.skey1;
1163 job->u.CMAC._skey2 = session->auth.cmac.skey2;
1164 job->enc_keys = session->cipher.expanded_aes_keys.encode;
1165 job->dec_keys = session->cipher.expanded_aes_keys.decode;
1168 case IMB_AUTH_AES_GMAC:
1169 if (session->cipher.mode == IMB_CIPHER_GCM) {
1170 job->u.GCM.aad = op->sym->aead.aad.data;
1171 job->u.GCM.aad_len_in_bytes = session->aead.aad_len;
1174 job->u.GCM.aad = rte_pktmbuf_mtod_offset(m_src,
1175 uint8_t *, op->sym->auth.data.offset);
1176 job->u.GCM.aad_len_in_bytes = op->sym->auth.data.length;
1177 job->cipher_mode = IMB_CIPHER_GCM;
1179 job->enc_keys = &session->cipher.gcm_key;
1180 job->dec_keys = &session->cipher.gcm_key;
1182 case IMB_AUTH_ZUC_EIA3_BITLEN:
1183 case IMB_AUTH_ZUC256_EIA3_BITLEN:
1184 job->u.ZUC_EIA3._key = session->auth.zuc_auth_key;
1185 job->u.ZUC_EIA3._iv = rte_crypto_op_ctod_offset(op, uint8_t *,
1186 session->auth_iv.offset);
1188 case IMB_AUTH_SNOW3G_UIA2_BITLEN:
1189 job->u.SNOW3G_UIA2._key = (void *)
1190 &session->auth.pKeySched_snow3g_auth;
1191 job->u.SNOW3G_UIA2._iv =
1192 rte_crypto_op_ctod_offset(op, uint8_t *,
1193 session->auth_iv.offset);
1195 case IMB_AUTH_KASUMI_UIA1:
1196 job->u.KASUMI_UIA1._key = (void *)
1197 &session->auth.pKeySched_kasumi_auth;
1199 case IMB_AUTH_CHACHA20_POLY1305:
1200 job->u.CHACHA20_POLY1305.aad = op->sym->aead.aad.data;
1201 job->u.CHACHA20_POLY1305.aad_len_in_bytes =
1202 session->aead.aad_len;
1203 job->enc_keys = session->cipher.expanded_aes_keys.encode;
1204 job->dec_keys = session->cipher.expanded_aes_keys.encode;
1207 job->u.HMAC._hashed_auth_key_xor_ipad =
1208 session->auth.pads.inner;
1209 job->u.HMAC._hashed_auth_key_xor_opad =
1210 session->auth.pads.outer;
1215 m_offset = op->sym->aead.data.offset;
1217 m_offset = op->sym->cipher.data.offset;
1219 if (job->cipher_mode == IMB_CIPHER_ZUC_EEA3) {
1220 job->enc_keys = session->cipher.zuc_cipher_key;
1221 job->dec_keys = session->cipher.zuc_cipher_key;
1222 } else if (job->cipher_mode == IMB_CIPHER_SNOW3G_UEA2_BITLEN) {
1223 job->enc_keys = &session->cipher.pKeySched_snow3g_cipher;
1225 } else if (job->cipher_mode == IMB_CIPHER_KASUMI_UEA1_BITLEN) {
1226 job->enc_keys = &session->cipher.pKeySched_kasumi_cipher;
1230 if (!op->sym->m_dst) {
1231 /* in-place operation */
1234 } else if (op->sym->m_dst == op->sym->m_src) {
1235 /* in-place operation */
1239 /* out-of-place operation */
1240 m_dst = op->sym->m_dst;
1244 /* Set digest output location */
1245 if (job->hash_alg != IMB_AUTH_NULL &&
1246 session->auth.operation == RTE_CRYPTO_AUTH_OP_VERIFY) {
1247 job->auth_tag_output = qp_data->temp_digests[*digest_idx];
1248 *digest_idx = (*digest_idx + 1) % IMB_MAX_JOBS;
1251 job->auth_tag_output = op->sym->aead.digest.data;
1253 job->auth_tag_output = op->sym->auth.digest.data;
1255 if (session->auth.req_digest_len !=
1256 session->auth.gen_digest_len) {
1257 job->auth_tag_output =
1258 qp_data->temp_digests[*digest_idx];
1259 *digest_idx = (*digest_idx + 1) % IMB_MAX_JOBS;
1263 * Multi-buffer library current only support returning a truncated
1264 * digest length as specified in the relevant IPsec RFCs
1267 /* Set digest length */
1268 job->auth_tag_output_len_in_bytes = session->auth.gen_digest_len;
1270 /* Set IV parameters */
1271 job->iv_len_in_bytes = session->iv.length;
1273 /* Data Parameters */
1274 job->src = rte_pktmbuf_mtod(m_src, uint8_t *);
1275 job->dst = rte_pktmbuf_mtod_offset(m_dst, uint8_t *, m_offset);
1277 switch (job->hash_alg) {
1278 case IMB_AUTH_AES_CCM:
1279 job->cipher_start_src_offset_in_bytes =
1280 op->sym->aead.data.offset;
1281 job->msg_len_to_cipher_in_bytes = op->sym->aead.data.length;
1282 job->hash_start_src_offset_in_bytes = op->sym->aead.data.offset;
1283 job->msg_len_to_hash_in_bytes = op->sym->aead.data.length;
1285 job->iv = rte_crypto_op_ctod_offset(op, uint8_t *,
1286 session->iv.offset + 1);
1289 case IMB_AUTH_AES_GMAC:
1290 if (session->cipher.mode == IMB_CIPHER_GCM) {
1291 job->cipher_start_src_offset_in_bytes =
1292 op->sym->aead.data.offset;
1293 job->hash_start_src_offset_in_bytes =
1294 op->sym->aead.data.offset;
1295 job->msg_len_to_cipher_in_bytes =
1296 op->sym->aead.data.length;
1297 job->msg_len_to_hash_in_bytes =
1298 op->sym->aead.data.length;
1300 job->cipher_start_src_offset_in_bytes =
1301 op->sym->auth.data.offset;
1302 job->hash_start_src_offset_in_bytes =
1303 op->sym->auth.data.offset;
1304 job->msg_len_to_cipher_in_bytes = 0;
1305 job->msg_len_to_hash_in_bytes = 0;
1308 job->iv = rte_crypto_op_ctod_offset(op, uint8_t *,
1309 session->iv.offset);
1312 case IMB_AUTH_CHACHA20_POLY1305:
1313 job->cipher_start_src_offset_in_bytes =
1314 op->sym->aead.data.offset;
1315 job->hash_start_src_offset_in_bytes =
1316 op->sym->aead.data.offset;
1317 job->msg_len_to_cipher_in_bytes =
1318 op->sym->aead.data.length;
1319 job->msg_len_to_hash_in_bytes =
1320 op->sym->aead.data.length;
1322 job->iv = rte_crypto_op_ctod_offset(op, uint8_t *,
1323 session->iv.offset);
1326 /* For SNOW3G, length and offsets are already in bits */
1327 job->cipher_start_src_offset_in_bytes =
1328 op->sym->cipher.data.offset;
1329 job->msg_len_to_cipher_in_bytes = op->sym->cipher.data.length;
1331 job->hash_start_src_offset_in_bytes = auth_start_offset(op,
1333 job->msg_len_to_hash_in_bytes = op->sym->auth.data.length;
1335 job->iv = rte_crypto_op_ctod_offset(op, uint8_t *,
1336 session->iv.offset);
1339 if (job->cipher_mode == IMB_CIPHER_NULL && oop) {
1340 memcpy(job->dst + job->cipher_start_src_offset_in_bytes,
1341 job->src + job->cipher_start_src_offset_in_bytes,
1342 job->msg_len_to_cipher_in_bytes);
1345 if (job->cipher_mode == IMB_CIPHER_ZUC_EEA3)
1346 job->msg_len_to_cipher_in_bytes >>= 3;
1347 else if (job->hash_alg == IMB_AUTH_KASUMI_UIA1)
1348 job->msg_len_to_hash_in_bytes >>= 3;
1350 /* Set user data to be crypto operation data struct */
1351 job->user_data = op;
1356 #ifdef AESNI_MB_DOCSIS_SEC_ENABLED
1358 * Process a crypto operation containing a security op and complete a
1359 * IMB_JOB job structure for submission to the multi buffer library for
1363 set_sec_mb_job_params(IMB_JOB *job, struct ipsec_mb_qp *qp,
1364 struct rte_crypto_op *op, uint8_t *digest_idx)
1366 struct aesni_mb_qp_data *qp_data = ipsec_mb_get_qp_private_data(qp);
1367 struct rte_mbuf *m_src, *m_dst;
1368 struct rte_crypto_sym_op *sym;
1369 struct aesni_mb_session *session = NULL;
1371 if (unlikely(op->sess_type != RTE_CRYPTO_OP_SECURITY_SESSION)) {
1372 op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
1375 session = (struct aesni_mb_session *)
1376 get_sec_session_private_data(op->sym->sec_session);
1378 if (unlikely(session == NULL)) {
1379 op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
1382 /* Only DOCSIS protocol operations supported now */
1383 if (session->cipher.mode != IMB_CIPHER_DOCSIS_SEC_BPI ||
1384 session->auth.algo != IMB_AUTH_DOCSIS_CRC32) {
1385 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
1392 if (likely(sym->m_dst == NULL || sym->m_dst == m_src)) {
1393 /* in-place operation */
1396 /* out-of-place operation not supported */
1397 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
1401 /* Set crypto operation */
1402 job->chain_order = session->chain_order;
1404 /* Set cipher parameters */
1405 job->cipher_direction = session->cipher.direction;
1406 job->cipher_mode = session->cipher.mode;
1408 job->key_len_in_bytes = session->cipher.key_length_in_bytes;
1409 job->enc_keys = session->cipher.expanded_aes_keys.encode;
1410 job->dec_keys = session->cipher.expanded_aes_keys.decode;
1412 /* Set IV parameters */
1413 job->iv_len_in_bytes = session->iv.length;
1414 job->iv = (uint8_t *)op + session->iv.offset;
1416 /* Set authentication parameters */
1417 job->hash_alg = session->auth.algo;
1419 /* Set digest output location */
1420 job->auth_tag_output = qp_data->temp_digests[*digest_idx];
1421 *digest_idx = (*digest_idx + 1) % IMB_MAX_JOBS;
1423 /* Set digest length */
1424 job->auth_tag_output_len_in_bytes = session->auth.gen_digest_len;
1426 /* Set data parameters */
1427 job->src = rte_pktmbuf_mtod(m_src, uint8_t *);
1428 job->dst = rte_pktmbuf_mtod_offset(m_dst, uint8_t *,
1429 sym->cipher.data.offset);
1431 job->cipher_start_src_offset_in_bytes = sym->cipher.data.offset;
1432 job->msg_len_to_cipher_in_bytes = sym->cipher.data.length;
1434 job->hash_start_src_offset_in_bytes = sym->auth.data.offset;
1435 job->msg_len_to_hash_in_bytes = sym->auth.data.length;
1437 job->user_data = op;
1443 verify_docsis_sec_crc(IMB_JOB *job, uint8_t *status)
1445 uint16_t crc_offset;
1448 if (!job->msg_len_to_hash_in_bytes)
1451 crc_offset = job->hash_start_src_offset_in_bytes +
1452 job->msg_len_to_hash_in_bytes -
1453 job->cipher_start_src_offset_in_bytes;
1454 crc = job->dst + crc_offset;
1456 /* Verify CRC (at the end of the message) */
1457 if (memcmp(job->auth_tag_output, crc, RTE_ETHER_CRC_LEN) != 0)
1458 *status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
1463 verify_digest(IMB_JOB *job, void *digest, uint16_t len, uint8_t *status)
1465 /* Verify digest if required */
1466 if (memcmp(job->auth_tag_output, digest, len) != 0)
1467 *status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
1471 generate_digest(IMB_JOB *job, struct rte_crypto_op *op,
1472 struct aesni_mb_session *sess)
1474 /* No extra copy needed */
1475 if (likely(sess->auth.req_digest_len == sess->auth.gen_digest_len))
1479 * This can only happen for HMAC, so only digest
1480 * for authentication algos is required
1482 memcpy(op->sym->auth.digest.data, job->auth_tag_output,
1483 sess->auth.req_digest_len);
1487 * Process a completed job and return rte_mbuf which job processed
1489 * @param qp Queue Pair to process
1490 * @param job IMB_JOB job to process
1493 * - Returns processed crypto operation.
1494 * - Returns NULL on invalid job
1496 static inline struct rte_crypto_op *
1497 post_process_mb_job(struct ipsec_mb_qp *qp, IMB_JOB *job)
1499 struct rte_crypto_op *op = (struct rte_crypto_op *)job->user_data;
1500 struct aesni_mb_session *sess = NULL;
1501 uint32_t driver_id = ipsec_mb_get_driver_id(
1502 IPSEC_MB_PMD_TYPE_AESNI_MB);
1504 #ifdef AESNI_MB_DOCSIS_SEC_ENABLED
1505 uint8_t is_docsis_sec = 0;
1507 if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
1509 * Assuming at this point that if it's a security type op, that
1510 * this is for DOCSIS
1513 sess = get_sec_session_private_data(op->sym->sec_session);
1517 sess = get_sym_session_private_data(op->sym->session,
1521 if (unlikely(sess == NULL)) {
1522 op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
1526 if (likely(op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)) {
1527 switch (job->status) {
1528 case IMB_STATUS_COMPLETED:
1529 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
1531 if (job->hash_alg == IMB_AUTH_NULL)
1534 if (sess->auth.operation == RTE_CRYPTO_AUTH_OP_VERIFY) {
1535 if (is_aead_algo(job->hash_alg,
1538 op->sym->aead.digest.data,
1539 sess->auth.req_digest_len,
1541 #ifdef AESNI_MB_DOCSIS_SEC_ENABLED
1542 else if (is_docsis_sec)
1543 verify_docsis_sec_crc(job,
1548 op->sym->auth.digest.data,
1549 sess->auth.req_digest_len,
1552 generate_digest(job, op, sess);
1555 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
1559 /* Free session if a session-less crypto op */
1560 if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
1561 memset(sess, 0, sizeof(struct aesni_mb_session));
1562 memset(op->sym->session, 0,
1563 rte_cryptodev_sym_get_existing_header_session_size(
1565 rte_mempool_put(qp->sess_mp_priv, sess);
1566 rte_mempool_put(qp->sess_mp, op->sym->session);
1567 op->sym->session = NULL;
1574 post_process_mb_sync_job(IMB_JOB *job)
1578 st = job->user_data;
1579 st[0] = (job->status == IMB_STATUS_COMPLETED) ? 0 : EBADMSG;
1583 * Process a completed IMB_JOB job and keep processing jobs until
1584 * get_completed_job return NULL
1586 * @param qp Queue Pair to process
1587 * @param mb_mgr IMB_MGR to use
1588 * @param job IMB_JOB job
1589 * @param ops crypto ops to fill
1590 * @param nb_ops number of crypto ops
1593 * - Number of processed jobs
1596 handle_completed_jobs(struct ipsec_mb_qp *qp, IMB_MGR *mb_mgr,
1597 IMB_JOB *job, struct rte_crypto_op **ops,
1600 struct rte_crypto_op *op = NULL;
1601 uint16_t processed_jobs = 0;
1603 while (job != NULL) {
1604 op = post_process_mb_job(qp, job);
1607 ops[processed_jobs++] = op;
1608 qp->stats.dequeued_count++;
1610 qp->stats.dequeue_err_count++;
1613 if (processed_jobs == nb_ops)
1616 job = IMB_GET_COMPLETED_JOB(mb_mgr);
1619 return processed_jobs;
1622 static inline uint32_t
1623 handle_completed_sync_jobs(IMB_JOB *job, IMB_MGR *mb_mgr)
1627 for (i = 0; job != NULL; i++, job = IMB_GET_COMPLETED_JOB(mb_mgr))
1628 post_process_mb_sync_job(job);
1633 static inline uint32_t
1634 flush_mb_sync_mgr(IMB_MGR *mb_mgr)
1638 job = IMB_FLUSH_JOB(mb_mgr);
1639 return handle_completed_sync_jobs(job, mb_mgr);
1642 static inline uint16_t
1643 flush_mb_mgr(struct ipsec_mb_qp *qp, IMB_MGR *mb_mgr,
1644 struct rte_crypto_op **ops, uint16_t nb_ops)
1646 int processed_ops = 0;
1648 /* Flush the remaining jobs */
1649 IMB_JOB *job = IMB_FLUSH_JOB(mb_mgr);
1652 processed_ops += handle_completed_jobs(qp, mb_mgr, job,
1653 &ops[processed_ops], nb_ops - processed_ops);
1655 return processed_ops;
1658 static inline IMB_JOB *
1659 set_job_null_op(IMB_JOB *job, struct rte_crypto_op *op)
1661 job->chain_order = IMB_ORDER_HASH_CIPHER;
1662 job->cipher_mode = IMB_CIPHER_NULL;
1663 job->hash_alg = IMB_AUTH_NULL;
1664 job->cipher_direction = IMB_DIR_DECRYPT;
1666 /* Set user data to be crypto operation data struct */
1667 job->user_data = op;
1673 aesni_mb_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,
1676 struct ipsec_mb_qp *qp = queue_pair;
1677 IMB_MGR *mb_mgr = qp->mb_mgr;
1678 struct rte_crypto_op *op;
1680 int retval, processed_jobs = 0;
1682 if (unlikely(nb_ops == 0 || mb_mgr == NULL))
1685 uint8_t digest_idx = qp->digest_idx;
1688 /* Get next free mb job struct from mb manager */
1689 job = IMB_GET_NEXT_JOB(mb_mgr);
1690 if (unlikely(job == NULL)) {
1691 /* if no free mb job structs we need to flush mb_mgr */
1692 processed_jobs += flush_mb_mgr(qp, mb_mgr,
1693 &ops[processed_jobs],
1694 nb_ops - processed_jobs);
1696 if (nb_ops == processed_jobs)
1699 job = IMB_GET_NEXT_JOB(mb_mgr);
1703 * Get next operation to process from ingress queue.
1704 * There is no need to return the job to the IMB_MGR
1705 * if there are no more operations to process, since the IMB_MGR
1706 * can use that pointer again in next get_next calls.
1708 retval = rte_ring_dequeue(qp->ingress_queue, (void **)&op);
1712 #ifdef AESNI_MB_DOCSIS_SEC_ENABLED
1713 if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION)
1714 retval = set_sec_mb_job_params(job, qp, op,
1718 retval = set_mb_job_params(job, qp, op,
1721 if (unlikely(retval != 0)) {
1722 qp->stats.dequeue_err_count++;
1723 set_job_null_op(job, op);
1726 /* Submit job to multi-buffer for processing */
1727 #ifdef RTE_LIBRTE_PMD_AESNI_MB_DEBUG
1728 job = IMB_SUBMIT_JOB(mb_mgr);
1730 job = IMB_SUBMIT_JOB_NOCHECK(mb_mgr);
1733 * If submit returns a processed job then handle it,
1734 * before submitting subsequent jobs
1737 processed_jobs += handle_completed_jobs(qp, mb_mgr,
1738 job, &ops[processed_jobs],
1739 nb_ops - processed_jobs);
1741 } while (processed_jobs < nb_ops);
1743 qp->digest_idx = digest_idx;
1745 if (processed_jobs < 1)
1746 processed_jobs += flush_mb_mgr(qp, mb_mgr,
1747 &ops[processed_jobs],
1748 nb_ops - processed_jobs);
1750 return processed_jobs;
1755 ipsec_mb_fill_error_code(struct rte_crypto_sym_vec *vec, int32_t err)
1759 for (i = 0; i != vec->num; ++i)
1760 vec->status[i] = err;
1764 check_crypto_sgl(union rte_crypto_sym_ofs so, const struct rte_crypto_sgl *sgl)
1766 /* no multi-seg support with current AESNI-MB PMD */
1769 else if (so.ofs.cipher.head + so.ofs.cipher.tail > sgl->vec[0].len)
1774 static inline IMB_JOB *
1775 submit_sync_job(IMB_MGR *mb_mgr)
1777 #ifdef RTE_LIBRTE_PMD_AESNI_MB_DEBUG
1778 return IMB_SUBMIT_JOB(mb_mgr);
1780 return IMB_SUBMIT_JOB_NOCHECK(mb_mgr);
1784 static inline uint32_t
1785 generate_sync_dgst(struct rte_crypto_sym_vec *vec,
1786 const uint8_t dgst[][DIGEST_LENGTH_MAX], uint32_t len)
1790 for (i = 0, k = 0; i != vec->num; i++) {
1791 if (vec->status[i] == 0) {
1792 memcpy(vec->digest[i].va, dgst[i], len);
1800 static inline uint32_t
1801 verify_sync_dgst(struct rte_crypto_sym_vec *vec,
1802 const uint8_t dgst[][DIGEST_LENGTH_MAX], uint32_t len)
1806 for (i = 0, k = 0; i != vec->num; i++) {
1807 if (vec->status[i] == 0) {
1808 if (memcmp(vec->digest[i].va, dgst[i], len) != 0)
1809 vec->status[i] = EBADMSG;
1819 aesni_mb_process_bulk(struct rte_cryptodev *dev,
1820 struct rte_cryptodev_sym_session *sess, union rte_crypto_sym_ofs sofs,
1821 struct rte_crypto_sym_vec *vec)
1824 uint32_t i, j, k, len;
1828 struct aesni_mb_session *s;
1829 uint8_t tmp_dgst[vec->num][DIGEST_LENGTH_MAX];
1831 s = get_sym_session_private_data(sess, dev->driver_id);
1833 ipsec_mb_fill_error_code(vec, EINVAL);
1837 /* get per-thread MB MGR, create one if needed */
1838 mb_mgr = get_per_thread_mb_mgr();
1839 if (unlikely(mb_mgr == NULL))
1842 for (i = 0, j = 0, k = 0; i != vec->num; i++) {
1843 ret = check_crypto_sgl(sofs, vec->src_sgl + i);
1845 vec->status[i] = ret;
1849 buf = vec->src_sgl[i].vec[0].base;
1850 len = vec->src_sgl[i].vec[0].len;
1852 job = IMB_GET_NEXT_JOB(mb_mgr);
1854 k += flush_mb_sync_mgr(mb_mgr);
1855 job = IMB_GET_NEXT_JOB(mb_mgr);
1856 RTE_ASSERT(job != NULL);
1859 /* Submit job for processing */
1860 set_cpu_mb_job_params(job, s, sofs, buf, len, &vec->iv[i],
1861 &vec->aad[i], tmp_dgst[i], &vec->status[i]);
1862 job = submit_sync_job(mb_mgr);
1865 /* handle completed jobs */
1866 k += handle_completed_sync_jobs(job, mb_mgr);
1869 /* flush remaining jobs */
1871 k += flush_mb_sync_mgr(mb_mgr);
1873 /* finish processing for successful jobs: check/update digest */
1875 if (s->auth.operation == RTE_CRYPTO_AUTH_OP_VERIFY)
1876 k = verify_sync_dgst(vec,
1877 (const uint8_t (*)[DIGEST_LENGTH_MAX])tmp_dgst,
1878 s->auth.req_digest_len);
1880 k = generate_sync_dgst(vec,
1881 (const uint8_t (*)[DIGEST_LENGTH_MAX])tmp_dgst,
1882 s->auth.req_digest_len);
1888 struct rte_cryptodev_ops aesni_mb_pmd_ops = {
1889 .dev_configure = ipsec_mb_config,
1890 .dev_start = ipsec_mb_start,
1891 .dev_stop = ipsec_mb_stop,
1892 .dev_close = ipsec_mb_close,
1894 .stats_get = ipsec_mb_stats_get,
1895 .stats_reset = ipsec_mb_stats_reset,
1897 .dev_infos_get = ipsec_mb_info_get,
1899 .queue_pair_setup = ipsec_mb_qp_setup,
1900 .queue_pair_release = ipsec_mb_qp_release,
1902 .sym_cpu_process = aesni_mb_process_bulk,
1904 .sym_session_get_size = ipsec_mb_sym_session_get_size,
1905 .sym_session_configure = ipsec_mb_sym_session_configure,
1906 .sym_session_clear = ipsec_mb_sym_session_clear
1909 #ifdef AESNI_MB_DOCSIS_SEC_ENABLED
1911 * Configure a aesni multi-buffer session from a security session
1915 aesni_mb_pmd_sec_sess_create(void *dev, struct rte_security_session_conf *conf,
1916 struct rte_security_session *sess,
1917 struct rte_mempool *mempool)
1919 void *sess_private_data;
1920 struct rte_cryptodev *cdev = (struct rte_cryptodev *)dev;
1923 if (conf->action_type != RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL ||
1924 conf->protocol != RTE_SECURITY_PROTOCOL_DOCSIS) {
1925 IPSEC_MB_LOG(ERR, "Invalid security protocol");
1929 if (rte_mempool_get(mempool, &sess_private_data)) {
1930 IPSEC_MB_LOG(ERR, "Couldn't get object from session mempool");
1934 ret = aesni_mb_set_docsis_sec_session_parameters(cdev, conf,
1938 IPSEC_MB_LOG(ERR, "Failed to configure session parameters");
1940 /* Return session to mempool */
1941 rte_mempool_put(mempool, sess_private_data);
1945 set_sec_session_private_data(sess, sess_private_data);
1950 /** Clear the memory of session so it does not leave key material behind */
1952 aesni_mb_pmd_sec_sess_destroy(void *dev __rte_unused,
1953 struct rte_security_session *sess)
1955 void *sess_priv = get_sec_session_private_data(sess);
1958 struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
1960 memset(sess_priv, 0, sizeof(struct aesni_mb_session));
1961 set_sec_session_private_data(sess, NULL);
1962 rte_mempool_put(sess_mp, sess_priv);
1967 /** Get security capabilities for aesni multi-buffer */
1968 static const struct rte_security_capability *
1969 aesni_mb_pmd_sec_capa_get(void *device __rte_unused)
1971 return aesni_mb_pmd_security_cap;
1974 static struct rte_security_ops aesni_mb_pmd_sec_ops = {
1975 .session_create = aesni_mb_pmd_sec_sess_create,
1976 .session_update = NULL,
1977 .session_stats_get = NULL,
1978 .session_destroy = aesni_mb_pmd_sec_sess_destroy,
1979 .set_pkt_metadata = NULL,
1980 .capabilities_get = aesni_mb_pmd_sec_capa_get
1983 struct rte_security_ops *rte_aesni_mb_pmd_sec_ops = &aesni_mb_pmd_sec_ops;
1986 aesni_mb_configure_dev(struct rte_cryptodev *dev)
1988 struct rte_security_ctx *security_instance;
1990 security_instance = rte_malloc("aesni_mb_sec",
1991 sizeof(struct rte_security_ctx),
1992 RTE_CACHE_LINE_SIZE);
1993 if (security_instance != NULL) {
1994 security_instance->device = (void *)dev;
1995 security_instance->ops = rte_aesni_mb_pmd_sec_ops;
1996 security_instance->sess_cnt = 0;
1997 dev->security_ctx = security_instance;
2008 aesni_mb_probe(struct rte_vdev_device *vdev)
2010 return ipsec_mb_create(vdev, IPSEC_MB_PMD_TYPE_AESNI_MB);
2013 static struct rte_vdev_driver cryptodev_aesni_mb_pmd_drv = {
2014 .probe = aesni_mb_probe,
2015 .remove = ipsec_mb_remove
2018 static struct cryptodev_driver aesni_mb_crypto_drv;
2020 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_AESNI_MB_PMD,
2021 cryptodev_aesni_mb_pmd_drv);
2022 RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_AESNI_MB_PMD, cryptodev_aesni_mb_pmd);
2023 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_MB_PMD,
2024 "max_nb_queue_pairs=<int> socket_id=<int>");
2025 RTE_PMD_REGISTER_CRYPTO_DRIVER(
2026 aesni_mb_crypto_drv,
2027 cryptodev_aesni_mb_pmd_drv.driver,
2028 pmd_driver_id_aesni_mb);
2030 /* Constructor function to register aesni-mb PMD */
2031 RTE_INIT(ipsec_mb_register_aesni_mb)
2033 struct ipsec_mb_internals *aesni_mb_data =
2034 &ipsec_mb_pmds[IPSEC_MB_PMD_TYPE_AESNI_MB];
2036 aesni_mb_data->caps = aesni_mb_capabilities;
2037 aesni_mb_data->dequeue_burst = aesni_mb_dequeue_burst;
2038 aesni_mb_data->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
2039 RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
2040 RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT |
2041 RTE_CRYPTODEV_FF_SYM_CPU_CRYPTO |
2042 RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA |
2043 RTE_CRYPTODEV_FF_SYM_SESSIONLESS;
2045 aesni_mb_data->internals_priv_size = 0;
2046 aesni_mb_data->ops = &aesni_mb_pmd_ops;
2047 aesni_mb_data->qp_priv_size = sizeof(struct aesni_mb_qp_data);
2048 aesni_mb_data->queue_pair_configure = NULL;
2049 #ifdef AESNI_MB_DOCSIS_SEC_ENABLED
2050 aesni_mb_data->security_ops = &aesni_mb_pmd_sec_ops;
2051 aesni_mb_data->dev_config = aesni_mb_configure_dev;
2052 aesni_mb_data->feature_flags |= RTE_CRYPTODEV_FF_SECURITY;
2054 aesni_mb_data->session_configure = aesni_mb_session_configure;
2055 aesni_mb_data->session_priv_size = sizeof(struct aesni_mb_session);