4 * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <rte_common.h>
36 #include <rte_hexdump.h>
37 #include <rte_cryptodev.h>
38 #include <rte_cryptodev_pmd.h>
39 #include <rte_bus_vdev.h>
40 #include <rte_malloc.h>
41 #include <rte_cpuflags.h>
43 #include "rte_aesni_mb_pmd_private.h"
45 static uint8_t cryptodev_driver_id;
47 typedef void (*hash_one_block_t)(const void *data, void *digest);
48 typedef void (*aes_keyexp_t)(const void *key, void *enc_exp_keys, void *dec_exp_keys);
51 * Calculate the authentication pre-computes
53 * @param one_block_hash Function pointer to calculate digest on ipad/opad
54 * @param ipad Inner pad output byte array
55 * @param opad Outer pad output byte array
56 * @param hkey Authentication key
57 * @param hkey_len Authentication key length
58 * @param blocksize Block size of selected hash algo
61 calculate_auth_precomputes(hash_one_block_t one_block_hash,
62 uint8_t *ipad, uint8_t *opad,
63 uint8_t *hkey, uint16_t hkey_len,
68 uint8_t ipad_buf[blocksize] __rte_aligned(16);
69 uint8_t opad_buf[blocksize] __rte_aligned(16);
71 /* Setup inner and outer pads */
72 memset(ipad_buf, HMAC_IPAD_VALUE, blocksize);
73 memset(opad_buf, HMAC_OPAD_VALUE, blocksize);
75 /* XOR hash key with inner and outer pads */
76 length = hkey_len > blocksize ? blocksize : hkey_len;
78 for (i = 0; i < length; i++) {
79 ipad_buf[i] ^= hkey[i];
80 opad_buf[i] ^= hkey[i];
83 /* Compute partial hashes */
84 (*one_block_hash)(ipad_buf, ipad);
85 (*one_block_hash)(opad_buf, opad);
88 memset(ipad_buf, 0, blocksize);
89 memset(opad_buf, 0, blocksize);
92 /** Get xform chain order */
93 static enum aesni_mb_operation
94 aesni_mb_get_chain_order(const struct rte_crypto_sym_xform *xform)
97 return AESNI_MB_OP_NOT_SUPPORTED;
99 if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER) {
100 if (xform->next == NULL)
101 return AESNI_MB_OP_CIPHER_ONLY;
102 if (xform->next->type == RTE_CRYPTO_SYM_XFORM_AUTH)
103 return AESNI_MB_OP_CIPHER_HASH;
106 if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH) {
107 if (xform->next == NULL)
108 return AESNI_MB_OP_HASH_ONLY;
109 if (xform->next->type == RTE_CRYPTO_SYM_XFORM_CIPHER)
110 return AESNI_MB_OP_HASH_CIPHER;
113 return AESNI_MB_OP_NOT_SUPPORTED;
116 /** Set session authentication parameters */
118 aesni_mb_set_session_auth_parameters(const struct aesni_mb_op_fns *mb_ops,
119 struct aesni_mb_session *sess,
120 const struct rte_crypto_sym_xform *xform)
122 hash_one_block_t hash_oneblock_fn;
125 sess->auth.algo = NULL_HASH;
129 if (xform->type != RTE_CRYPTO_SYM_XFORM_AUTH) {
130 MB_LOG_ERR("Crypto xform struct not of type auth");
134 /* Select auth generate/verify */
135 sess->auth.operation = xform->auth.op;
137 /* Set Authentication Parameters */
138 if (xform->auth.algo == RTE_CRYPTO_AUTH_AES_XCBC_MAC) {
139 sess->auth.algo = AES_XCBC;
140 (*mb_ops->aux.keyexp.aes_xcbc)(xform->auth.key.data,
141 sess->auth.xcbc.k1_expanded,
142 sess->auth.xcbc.k2, sess->auth.xcbc.k3);
146 switch (xform->auth.algo) {
147 case RTE_CRYPTO_AUTH_MD5_HMAC:
148 sess->auth.algo = MD5;
149 hash_oneblock_fn = mb_ops->aux.one_block.md5;
151 case RTE_CRYPTO_AUTH_SHA1_HMAC:
152 sess->auth.algo = SHA1;
153 hash_oneblock_fn = mb_ops->aux.one_block.sha1;
155 case RTE_CRYPTO_AUTH_SHA224_HMAC:
156 sess->auth.algo = SHA_224;
157 hash_oneblock_fn = mb_ops->aux.one_block.sha224;
159 case RTE_CRYPTO_AUTH_SHA256_HMAC:
160 sess->auth.algo = SHA_256;
161 hash_oneblock_fn = mb_ops->aux.one_block.sha256;
163 case RTE_CRYPTO_AUTH_SHA384_HMAC:
164 sess->auth.algo = SHA_384;
165 hash_oneblock_fn = mb_ops->aux.one_block.sha384;
167 case RTE_CRYPTO_AUTH_SHA512_HMAC:
168 sess->auth.algo = SHA_512;
169 hash_oneblock_fn = mb_ops->aux.one_block.sha512;
172 MB_LOG_ERR("Unsupported authentication algorithm selection");
176 /* Calculate Authentication precomputes */
177 calculate_auth_precomputes(hash_oneblock_fn,
178 sess->auth.pads.inner, sess->auth.pads.outer,
179 xform->auth.key.data,
180 xform->auth.key.length,
181 get_auth_algo_blocksize(sess->auth.algo));
186 /** Set session cipher parameters */
188 aesni_mb_set_session_cipher_parameters(const struct aesni_mb_op_fns *mb_ops,
189 struct aesni_mb_session *sess,
190 const struct rte_crypto_sym_xform *xform)
193 aes_keyexp_t aes_keyexp_fn;
196 sess->cipher.mode = NULL_CIPHER;
200 if (xform->type != RTE_CRYPTO_SYM_XFORM_CIPHER) {
201 MB_LOG_ERR("Crypto xform struct not of type cipher");
205 /* Select cipher direction */
206 switch (xform->cipher.op) {
207 case RTE_CRYPTO_CIPHER_OP_ENCRYPT:
208 sess->cipher.direction = ENCRYPT;
210 case RTE_CRYPTO_CIPHER_OP_DECRYPT:
211 sess->cipher.direction = DECRYPT;
214 MB_LOG_ERR("Invalid cipher operation parameter");
218 /* Select cipher mode */
219 switch (xform->cipher.algo) {
220 case RTE_CRYPTO_CIPHER_AES_CBC:
221 sess->cipher.mode = CBC;
224 case RTE_CRYPTO_CIPHER_AES_CTR:
225 sess->cipher.mode = CNTR;
228 case RTE_CRYPTO_CIPHER_AES_DOCSISBPI:
229 sess->cipher.mode = DOCSIS_SEC_BPI;
232 case RTE_CRYPTO_CIPHER_DES_CBC:
233 sess->cipher.mode = DES;
235 case RTE_CRYPTO_CIPHER_DES_DOCSISBPI:
236 sess->cipher.mode = DOCSIS_DES;
239 MB_LOG_ERR("Unsupported cipher mode parameter");
243 /* Set IV parameters */
244 sess->iv.offset = xform->cipher.iv.offset;
245 sess->iv.length = xform->cipher.iv.length;
247 /* Check key length and choose key expansion function for AES */
249 switch (xform->cipher.key.length) {
251 sess->cipher.key_length_in_bytes = AES_128_BYTES;
252 aes_keyexp_fn = mb_ops->aux.keyexp.aes128;
255 sess->cipher.key_length_in_bytes = AES_192_BYTES;
256 aes_keyexp_fn = mb_ops->aux.keyexp.aes192;
259 sess->cipher.key_length_in_bytes = AES_256_BYTES;
260 aes_keyexp_fn = mb_ops->aux.keyexp.aes256;
263 MB_LOG_ERR("Invalid cipher key length");
267 /* Expanded cipher keys */
268 (*aes_keyexp_fn)(xform->cipher.key.data,
269 sess->cipher.expanded_aes_keys.encode,
270 sess->cipher.expanded_aes_keys.decode);
273 if (xform->cipher.key.length != 8) {
274 MB_LOG_ERR("Invalid cipher key length");
277 sess->cipher.key_length_in_bytes = 8;
279 des_key_schedule((uint64_t *)sess->cipher.expanded_aes_keys.encode,
280 xform->cipher.key.data);
281 des_key_schedule((uint64_t *)sess->cipher.expanded_aes_keys.decode,
282 xform->cipher.key.data);
288 /** Parse crypto xform chain and set private session parameters */
290 aesni_mb_set_session_parameters(const struct aesni_mb_op_fns *mb_ops,
291 struct aesni_mb_session *sess,
292 const struct rte_crypto_sym_xform *xform)
294 const struct rte_crypto_sym_xform *auth_xform = NULL;
295 const struct rte_crypto_sym_xform *cipher_xform = NULL;
298 /* Select Crypto operation - hash then cipher / cipher then hash */
299 switch (aesni_mb_get_chain_order(xform)) {
300 case AESNI_MB_OP_HASH_CIPHER:
301 sess->chain_order = HASH_CIPHER;
303 cipher_xform = xform->next;
305 case AESNI_MB_OP_CIPHER_HASH:
306 sess->chain_order = CIPHER_HASH;
307 auth_xform = xform->next;
308 cipher_xform = xform;
310 case AESNI_MB_OP_HASH_ONLY:
311 sess->chain_order = HASH_CIPHER;
315 case AESNI_MB_OP_CIPHER_ONLY:
317 * Multi buffer library operates only at two modes,
318 * CIPHER_HASH and HASH_CIPHER. When doing ciphering only,
319 * chain order depends on cipher operation: encryption is always
320 * the first operation and decryption the last one.
322 if (xform->cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
323 sess->chain_order = CIPHER_HASH;
325 sess->chain_order = HASH_CIPHER;
327 cipher_xform = xform;
329 case AESNI_MB_OP_NOT_SUPPORTED:
331 MB_LOG_ERR("Unsupported operation chain order parameter");
335 /* Default IV length = 0 */
338 ret = aesni_mb_set_session_auth_parameters(mb_ops, sess, auth_xform);
340 MB_LOG_ERR("Invalid/unsupported authentication parameters");
344 ret = aesni_mb_set_session_cipher_parameters(mb_ops, sess,
347 MB_LOG_ERR("Invalid/unsupported cipher parameters");
355 * burst enqueue, place crypto operations on ingress queue for processing.
357 * @param __qp Queue Pair to process
358 * @param ops Crypto operations for processing
359 * @param nb_ops Number of crypto operations for processing
362 * - Number of crypto operations enqueued
365 aesni_mb_pmd_enqueue_burst(void *__qp, struct rte_crypto_op **ops,
368 struct aesni_mb_qp *qp = __qp;
370 unsigned int nb_enqueued;
372 nb_enqueued = rte_ring_enqueue_burst(qp->ingress_queue,
373 (void **)ops, nb_ops, NULL);
375 qp->stats.enqueued_count += nb_enqueued;
380 /** Get multi buffer session */
381 static inline struct aesni_mb_session *
382 get_session(struct aesni_mb_qp *qp, struct rte_crypto_op *op)
384 struct aesni_mb_session *sess = NULL;
386 if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
387 if (likely(op->sym->session != NULL))
388 sess = (struct aesni_mb_session *)
389 get_session_private_data(
391 cryptodev_driver_id);
394 void *_sess_private_data = NULL;
396 if (rte_mempool_get(qp->sess_mp, (void **)&_sess))
399 if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
402 sess = (struct aesni_mb_session *)_sess_private_data;
404 if (unlikely(aesni_mb_set_session_parameters(qp->op_fns,
405 sess, op->sym->xform) != 0)) {
406 rte_mempool_put(qp->sess_mp, _sess);
407 rte_mempool_put(qp->sess_mp, _sess_private_data);
410 op->sym->session = (struct rte_cryptodev_sym_session *)_sess;
411 set_session_private_data(op->sym->session, cryptodev_driver_id,
415 if (unlikely(sess == NULL))
416 op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
422 * Process a crypto operation and complete a JOB_AES_HMAC job structure for
423 * submission to the multi buffer library for processing.
425 * @param qp queue pair
426 * @param job JOB_AES_HMAC structure to fill
427 * @param m mbuf to process
430 * - Completed JOB_AES_HMAC structure pointer on success
431 * - NULL pointer if completion of JOB_AES_HMAC structure isn't possible
434 set_mb_job_params(JOB_AES_HMAC *job, struct aesni_mb_qp *qp,
435 struct rte_crypto_op *op, uint8_t *digest_idx)
437 struct rte_mbuf *m_src = op->sym->m_src, *m_dst;
438 struct aesni_mb_session *session;
439 uint16_t m_offset = 0;
441 session = get_session(qp, op);
442 if (session == NULL) {
443 op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
447 /* Set crypto operation */
448 job->chain_order = session->chain_order;
450 /* Set cipher parameters */
451 job->cipher_direction = session->cipher.direction;
452 job->cipher_mode = session->cipher.mode;
454 job->aes_key_len_in_bytes = session->cipher.key_length_in_bytes;
455 job->aes_enc_key_expanded = session->cipher.expanded_aes_keys.encode;
456 job->aes_dec_key_expanded = session->cipher.expanded_aes_keys.decode;
459 /* Set authentication parameters */
460 job->hash_alg = session->auth.algo;
461 if (job->hash_alg == AES_XCBC) {
462 job->_k1_expanded = session->auth.xcbc.k1_expanded;
463 job->_k2 = session->auth.xcbc.k2;
464 job->_k3 = session->auth.xcbc.k3;
466 job->hashed_auth_key_xor_ipad = session->auth.pads.inner;
467 job->hashed_auth_key_xor_opad = session->auth.pads.outer;
470 /* Mutable crypto operation parameters */
471 if (op->sym->m_dst) {
472 m_src = m_dst = op->sym->m_dst;
474 /* append space for output data to mbuf */
475 char *odata = rte_pktmbuf_append(m_dst,
476 rte_pktmbuf_data_len(op->sym->m_src));
478 MB_LOG_ERR("failed to allocate space in destination "
479 "mbuf for source data");
480 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
484 memcpy(odata, rte_pktmbuf_mtod(op->sym->m_src, void*),
485 rte_pktmbuf_data_len(op->sym->m_src));
488 m_offset = op->sym->cipher.data.offset;
491 /* Set digest output location */
492 if (job->hash_alg != NULL_HASH &&
493 session->auth.operation == RTE_CRYPTO_AUTH_OP_VERIFY) {
494 job->auth_tag_output = qp->temp_digests[*digest_idx];
495 *digest_idx = (*digest_idx + 1) % MAX_JOBS;
497 job->auth_tag_output = op->sym->auth.digest.data;
501 * Multi-buffer library current only support returning a truncated
502 * digest length as specified in the relevant IPsec RFCs
504 job->auth_tag_output_len_in_bytes =
505 get_truncated_digest_byte_length(job->hash_alg);
507 /* Set IV parameters */
508 job->iv = rte_crypto_op_ctod_offset(op, uint8_t *,
510 job->iv_len_in_bytes = session->iv.length;
513 job->src = rte_pktmbuf_mtod(m_src, uint8_t *);
514 job->dst = rte_pktmbuf_mtod_offset(m_dst, uint8_t *, m_offset);
516 job->cipher_start_src_offset_in_bytes = op->sym->cipher.data.offset;
517 job->msg_len_to_cipher_in_bytes = op->sym->cipher.data.length;
519 job->hash_start_src_offset_in_bytes = op->sym->auth.data.offset;
520 job->msg_len_to_hash_in_bytes = op->sym->auth.data.length;
522 /* Set user data to be crypto operation data struct */
529 verify_digest(struct aesni_mb_qp *qp __rte_unused, JOB_AES_HMAC *job,
530 struct rte_crypto_op *op) {
531 /* Verify digest if required */
532 if (memcmp(job->auth_tag_output, op->sym->auth.digest.data,
533 job->auth_tag_output_len_in_bytes) != 0)
534 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
538 * Process a completed job and return rte_mbuf which job processed
540 * @param qp Queue Pair to process
541 * @param job JOB_AES_HMAC job to process
544 * - Returns processed crypto operation.
545 * - Returns NULL on invalid job
547 static inline struct rte_crypto_op *
548 post_process_mb_job(struct aesni_mb_qp *qp, JOB_AES_HMAC *job)
550 struct rte_crypto_op *op = (struct rte_crypto_op *)job->user_data;
551 struct aesni_mb_session *sess = get_session_private_data(
553 cryptodev_driver_id);
555 if (likely(op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)) {
556 switch (job->status) {
558 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
560 if (job->hash_alg != NULL_HASH) {
561 if (sess->auth.operation ==
562 RTE_CRYPTO_AUTH_OP_VERIFY)
563 verify_digest(qp, job, op);
567 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
571 /* Free session if a session-less crypto op */
572 if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
573 memset(sess, 0, sizeof(struct aesni_mb_session));
574 memset(op->sym->session, 0,
575 rte_cryptodev_get_header_session_size());
576 rte_mempool_put(qp->sess_mp, sess);
577 rte_mempool_put(qp->sess_mp, op->sym->session);
578 op->sym->session = NULL;
585 * Process a completed JOB_AES_HMAC job and keep processing jobs until
586 * get_completed_job return NULL
588 * @param qp Queue Pair to process
589 * @param job JOB_AES_HMAC job
592 * - Number of processed jobs
595 handle_completed_jobs(struct aesni_mb_qp *qp, JOB_AES_HMAC *job,
596 struct rte_crypto_op **ops, uint16_t nb_ops)
598 struct rte_crypto_op *op = NULL;
599 unsigned processed_jobs = 0;
601 while (job != NULL) {
602 op = post_process_mb_job(qp, job);
605 ops[processed_jobs++] = op;
606 qp->stats.dequeued_count++;
608 qp->stats.dequeue_err_count++;
611 if (processed_jobs == nb_ops)
614 job = (*qp->op_fns->job.get_completed_job)(&qp->mb_mgr);
617 return processed_jobs;
620 static inline uint16_t
621 flush_mb_mgr(struct aesni_mb_qp *qp, struct rte_crypto_op **ops,
624 int processed_ops = 0;
626 /* Flush the remaining jobs */
627 JOB_AES_HMAC *job = (*qp->op_fns->job.flush_job)(&qp->mb_mgr);
630 processed_ops += handle_completed_jobs(qp, job,
631 &ops[processed_ops], nb_ops - processed_ops);
633 return processed_ops;
636 static inline JOB_AES_HMAC *
637 set_job_null_op(JOB_AES_HMAC *job, struct rte_crypto_op *op)
639 job->chain_order = HASH_CIPHER;
640 job->cipher_mode = NULL_CIPHER;
641 job->hash_alg = NULL_HASH;
642 job->cipher_direction = DECRYPT;
644 /* Set user data to be crypto operation data struct */
651 aesni_mb_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,
654 struct aesni_mb_qp *qp = queue_pair;
656 struct rte_crypto_op *op;
659 int retval, processed_jobs = 0;
661 if (unlikely(nb_ops == 0))
664 uint8_t digest_idx = qp->digest_idx;
666 /* Get next operation to process from ingress queue */
667 retval = rte_ring_dequeue(qp->ingress_queue, (void **)&op);
671 /* Get next free mb job struct from mb manager */
672 job = (*qp->op_fns->job.get_next)(&qp->mb_mgr);
673 if (unlikely(job == NULL)) {
674 /* if no free mb job structs we need to flush mb_mgr */
675 processed_jobs += flush_mb_mgr(qp,
676 &ops[processed_jobs],
677 (nb_ops - processed_jobs) - 1);
679 job = (*qp->op_fns->job.get_next)(&qp->mb_mgr);
682 retval = set_mb_job_params(job, qp, op, &digest_idx);
683 if (unlikely(retval != 0)) {
684 qp->stats.dequeue_err_count++;
685 set_job_null_op(job, op);
688 /* Submit job to multi-buffer for processing */
689 job = (*qp->op_fns->job.submit)(&qp->mb_mgr);
692 * If submit returns a processed job then handle it,
693 * before submitting subsequent jobs
696 processed_jobs += handle_completed_jobs(qp, job,
697 &ops[processed_jobs],
698 nb_ops - processed_jobs);
700 } while (processed_jobs < nb_ops);
702 qp->digest_idx = digest_idx;
704 if (processed_jobs < 1)
705 processed_jobs += flush_mb_mgr(qp,
706 &ops[processed_jobs],
707 nb_ops - processed_jobs);
709 return processed_jobs;
712 static int cryptodev_aesni_mb_remove(struct rte_vdev_device *vdev);
715 cryptodev_aesni_mb_create(const char *name,
716 struct rte_vdev_device *vdev,
717 struct rte_cryptodev_pmd_init_params *init_params)
719 struct rte_cryptodev *dev;
720 struct aesni_mb_private *internals;
721 enum aesni_mb_vector_mode vector_mode;
723 /* Check CPU for support for AES instruction set */
724 if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_AES)) {
725 MB_LOG_ERR("AES instructions not supported by CPU");
729 dev = rte_cryptodev_pmd_create(name, &vdev->device, init_params);
731 MB_LOG_ERR("failed to create cryptodev vdev");
735 /* Check CPU for supported vector instruction set */
736 if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
737 vector_mode = RTE_AESNI_MB_AVX512;
738 else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
739 vector_mode = RTE_AESNI_MB_AVX2;
740 else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX))
741 vector_mode = RTE_AESNI_MB_AVX;
743 vector_mode = RTE_AESNI_MB_SSE;
745 dev->driver_id = cryptodev_driver_id;
746 dev->dev_ops = rte_aesni_mb_pmd_ops;
748 /* register rx/tx burst functions for data path */
749 dev->dequeue_burst = aesni_mb_pmd_dequeue_burst;
750 dev->enqueue_burst = aesni_mb_pmd_enqueue_burst;
752 dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
753 RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
754 RTE_CRYPTODEV_FF_CPU_AESNI;
756 switch (vector_mode) {
757 case RTE_AESNI_MB_SSE:
758 dev->feature_flags |= RTE_CRYPTODEV_FF_CPU_SSE;
760 case RTE_AESNI_MB_AVX:
761 dev->feature_flags |= RTE_CRYPTODEV_FF_CPU_AVX;
763 case RTE_AESNI_MB_AVX2:
764 dev->feature_flags |= RTE_CRYPTODEV_FF_CPU_AVX2;
766 case RTE_AESNI_MB_AVX512:
767 dev->feature_flags |= RTE_CRYPTODEV_FF_CPU_AVX512;
773 /* Set vector instructions mode supported */
774 internals = dev->data->dev_private;
776 internals->vector_mode = vector_mode;
777 internals->max_nb_queue_pairs = init_params->max_nb_queue_pairs;
778 internals->max_nb_sessions = init_params->max_nb_sessions;
784 cryptodev_aesni_mb_probe(struct rte_vdev_device *vdev)
786 struct rte_cryptodev_pmd_init_params init_params = {
788 sizeof(struct aesni_mb_private),
790 RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS,
791 RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_SESSIONS
793 const char *name, *args;
796 name = rte_vdev_device_name(vdev);
800 args = rte_vdev_device_args(vdev);
802 retval = rte_cryptodev_pmd_parse_input_args(&init_params, args);
804 MB_LOG_ERR("Failed to parse initialisation arguments[%s]\n",
809 return cryptodev_aesni_mb_create(name, vdev, &init_params);
813 cryptodev_aesni_mb_remove(struct rte_vdev_device *vdev)
815 struct rte_cryptodev *cryptodev;
818 name = rte_vdev_device_name(vdev);
822 cryptodev = rte_cryptodev_pmd_get_named_dev(name);
823 if (cryptodev == NULL)
826 return rte_cryptodev_pmd_destroy(cryptodev);
829 static struct rte_vdev_driver cryptodev_aesni_mb_pmd_drv = {
830 .probe = cryptodev_aesni_mb_probe,
831 .remove = cryptodev_aesni_mb_remove
834 static struct cryptodev_driver aesni_mb_crypto_drv;
836 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_AESNI_MB_PMD, cryptodev_aesni_mb_pmd_drv);
837 RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_AESNI_MB_PMD, cryptodev_aesni_mb_pmd);
838 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_MB_PMD,
839 "max_nb_queue_pairs=<int> "
840 "max_nb_sessions=<int> "
842 RTE_PMD_REGISTER_CRYPTO_DRIVER(aesni_mb_crypto_drv,
843 cryptodev_aesni_mb_pmd_drv,
844 cryptodev_driver_id);