1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2018 Advanced Micro Devices, Inc. All rights reserved. 3 */ 4 5 #include <string.h> 6 7 #include <rte_common.h> 8 #include <rte_cryptodev_pmd.h> 9 #include <rte_malloc.h> 10 11 #include "ccp_pmd_private.h" 12 #include "ccp_dev.h" 13 #include "ccp_crypto.h" 14 15 static const struct rte_cryptodev_capabilities ccp_pmd_capabilities[] = { 16 #ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH 17 { /* MD5 HMAC */ 18 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 19 {.sym = { 20 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 21 {.auth = { 22 .algo = RTE_CRYPTO_AUTH_MD5_HMAC, 23 .block_size = 64, 24 .key_size = { 25 .min = 1, 26 .max = 64, 27 .increment = 1 28 }, 29 .digest_size = { 30 .min = 16, 31 .max = 16, 32 .increment = 0 33 }, 34 .aad_size = { 0 } 35 }, } 36 }, } 37 }, 38 #endif 39 { /* SHA1 */ 40 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 41 {.sym = { 42 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 43 {.auth = { 44 .algo = RTE_CRYPTO_AUTH_SHA1, 45 .block_size = 64, 46 .key_size = { 47 .min = 0, 48 .max = 0, 49 .increment = 0 50 }, 51 .digest_size = { 52 .min = 20, 53 .max = 20, 54 .increment = 0 55 }, 56 .aad_size = { 0 } 57 }, } 58 }, } 59 }, 60 { /* SHA1 HMAC */ 61 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 62 {.sym = { 63 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 64 {.auth = { 65 .algo = RTE_CRYPTO_AUTH_SHA1_HMAC, 66 .block_size = 64, 67 .key_size = { 68 .min = 1, 69 .max = 64, 70 .increment = 1 71 }, 72 .digest_size = { 73 .min = 20, 74 .max = 20, 75 .increment = 0 76 }, 77 .aad_size = { 0 } 78 }, } 79 }, } 80 }, 81 { /* SHA224 */ 82 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 83 {.sym = { 84 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 85 {.auth = { 86 .algo = RTE_CRYPTO_AUTH_SHA224, 87 .block_size = 64, 88 .key_size = { 89 .min = 0, 90 .max = 0, 91 .increment = 0 92 }, 93 .digest_size = { 94 .min = 28, 95 .max = 28, 96 .increment = 0 97 }, 98 .aad_size = { 0 } 99 }, } 100 }, } 101 }, 102 { /* SHA224 HMAC */ 103 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 104 {.sym = { 105 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 106 {.auth = { 107 .algo = RTE_CRYPTO_AUTH_SHA224_HMAC, 108 .block_size = 64, 109 .key_size = { 110 .min = 1, 111 .max = 64, 112 .increment = 1 113 }, 114 .digest_size = { 115 .min = 28, 116 .max = 28, 117 .increment = 0 118 }, 119 .aad_size = { 0 } 120 }, } 121 }, } 122 }, 123 { /* SHA3-224 */ 124 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 125 {.sym = { 126 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 127 {.auth = { 128 .algo = RTE_CRYPTO_AUTH_SHA3_224, 129 .block_size = 144, 130 .key_size = { 131 .min = 0, 132 .max = 0, 133 .increment = 0 134 }, 135 .digest_size = { 136 .min = 28, 137 .max = 28, 138 .increment = 0 139 }, 140 .aad_size = { 0 } 141 }, } 142 }, } 143 }, 144 { /* SHA3-224 HMAC*/ 145 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 146 {.sym = { 147 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 148 {.auth = { 149 .algo = RTE_CRYPTO_AUTH_SHA3_224_HMAC, 150 .block_size = 144, 151 .key_size = { 152 .min = 1, 153 .max = 144, 154 .increment = 1 155 }, 156 .digest_size = { 157 .min = 28, 158 .max = 28, 159 .increment = 0 160 }, 161 .aad_size = { 0 } 162 }, } 163 }, } 164 }, 165 { /* SHA256 */ 166 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 167 {.sym = { 168 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 169 {.auth = { 170 .algo = RTE_CRYPTO_AUTH_SHA256, 171 .block_size = 64, 172 .key_size = { 173 .min = 0, 174 .max = 0, 175 .increment = 0 176 }, 177 .digest_size = { 178 .min = 32, 179 .max = 32, 180 .increment = 0 181 }, 182 .aad_size = { 0 } 183 }, } 184 }, } 185 }, 186 { /* SHA256 HMAC */ 187 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 188 {.sym = { 189 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 190 {.auth = { 191 .algo = RTE_CRYPTO_AUTH_SHA256_HMAC, 192 .block_size = 64, 193 .key_size = { 194 .min = 1, 195 .max = 64, 196 .increment = 1 197 }, 198 .digest_size = { 199 .min = 32, 200 .max = 32, 201 .increment = 0 202 }, 203 .aad_size = { 0 } 204 }, } 205 }, } 206 }, 207 { /* SHA3-256 */ 208 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 209 {.sym = { 210 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 211 {.auth = { 212 .algo = RTE_CRYPTO_AUTH_SHA3_256, 213 .block_size = 136, 214 .key_size = { 215 .min = 0, 216 .max = 0, 217 .increment = 0 218 }, 219 .digest_size = { 220 .min = 32, 221 .max = 32, 222 .increment = 0 223 }, 224 .aad_size = { 0 } 225 }, } 226 }, } 227 }, 228 { /* SHA3-256-HMAC */ 229 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 230 {.sym = { 231 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 232 {.auth = { 233 .algo = RTE_CRYPTO_AUTH_SHA3_256_HMAC, 234 .block_size = 136, 235 .key_size = { 236 .min = 1, 237 .max = 136, 238 .increment = 1 239 }, 240 .digest_size = { 241 .min = 32, 242 .max = 32, 243 .increment = 0 244 }, 245 .aad_size = { 0 } 246 }, } 247 }, } 248 }, 249 { /* SHA384 */ 250 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 251 {.sym = { 252 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 253 {.auth = { 254 .algo = RTE_CRYPTO_AUTH_SHA384, 255 .block_size = 128, 256 .key_size = { 257 .min = 0, 258 .max = 0, 259 .increment = 0 260 }, 261 .digest_size = { 262 .min = 48, 263 .max = 48, 264 .increment = 0 265 }, 266 .aad_size = { 0 } 267 }, } 268 }, } 269 }, 270 { /* SHA384 HMAC */ 271 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 272 {.sym = { 273 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 274 {.auth = { 275 .algo = RTE_CRYPTO_AUTH_SHA384_HMAC, 276 .block_size = 128, 277 .key_size = { 278 .min = 1, 279 .max = 128, 280 .increment = 1 281 }, 282 .digest_size = { 283 .min = 48, 284 .max = 48, 285 .increment = 0 286 }, 287 .aad_size = { 0 } 288 }, } 289 }, } 290 }, 291 { /* SHA3-384 */ 292 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 293 {.sym = { 294 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 295 {.auth = { 296 .algo = RTE_CRYPTO_AUTH_SHA3_384, 297 .block_size = 104, 298 .key_size = { 299 .min = 0, 300 .max = 0, 301 .increment = 0 302 }, 303 .digest_size = { 304 .min = 48, 305 .max = 48, 306 .increment = 0 307 }, 308 .aad_size = { 0 } 309 }, } 310 }, } 311 }, 312 { /* SHA3-384-HMAC */ 313 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 314 {.sym = { 315 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 316 {.auth = { 317 .algo = RTE_CRYPTO_AUTH_SHA3_384_HMAC, 318 .block_size = 104, 319 .key_size = { 320 .min = 1, 321 .max = 104, 322 .increment = 1 323 }, 324 .digest_size = { 325 .min = 48, 326 .max = 48, 327 .increment = 0 328 }, 329 .aad_size = { 0 } 330 }, } 331 }, } 332 }, 333 { /* SHA512 */ 334 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 335 {.sym = { 336 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 337 {.auth = { 338 .algo = RTE_CRYPTO_AUTH_SHA512, 339 .block_size = 128, 340 .key_size = { 341 .min = 0, 342 .max = 0, 343 .increment = 0 344 }, 345 .digest_size = { 346 .min = 64, 347 .max = 64, 348 .increment = 0 349 }, 350 .aad_size = { 0 } 351 }, } 352 }, } 353 }, 354 { /* SHA512 HMAC */ 355 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 356 {.sym = { 357 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 358 {.auth = { 359 .algo = RTE_CRYPTO_AUTH_SHA512_HMAC, 360 .block_size = 128, 361 .key_size = { 362 .min = 1, 363 .max = 128, 364 .increment = 1 365 }, 366 .digest_size = { 367 .min = 64, 368 .max = 64, 369 .increment = 0 370 }, 371 .aad_size = { 0 } 372 }, } 373 }, } 374 }, 375 { /* SHA3-512 */ 376 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 377 {.sym = { 378 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 379 {.auth = { 380 .algo = RTE_CRYPTO_AUTH_SHA3_512, 381 .block_size = 72, 382 .key_size = { 383 .min = 0, 384 .max = 0, 385 .increment = 0 386 }, 387 .digest_size = { 388 .min = 64, 389 .max = 64, 390 .increment = 0 391 }, 392 .aad_size = { 0 } 393 }, } 394 }, } 395 }, 396 { /* SHA3-512-HMAC */ 397 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 398 {.sym = { 399 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 400 {.auth = { 401 .algo = RTE_CRYPTO_AUTH_SHA3_512_HMAC, 402 .block_size = 72, 403 .key_size = { 404 .min = 1, 405 .max = 72, 406 .increment = 1 407 }, 408 .digest_size = { 409 .min = 64, 410 .max = 64, 411 .increment = 0 412 }, 413 .aad_size = { 0 } 414 }, } 415 }, } 416 }, 417 { /*AES-CMAC */ 418 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 419 {.sym = { 420 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 421 {.auth = { 422 .algo = RTE_CRYPTO_AUTH_AES_CMAC, 423 .block_size = 16, 424 .key_size = { 425 .min = 16, 426 .max = 32, 427 .increment = 8 428 }, 429 .digest_size = { 430 .min = 16, 431 .max = 16, 432 .increment = 0 433 }, 434 }, } 435 }, } 436 }, 437 { /* AES ECB */ 438 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 439 {.sym = { 440 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, 441 {.cipher = { 442 .algo = RTE_CRYPTO_CIPHER_AES_ECB, 443 .block_size = 16, 444 .key_size = { 445 .min = 16, 446 .max = 32, 447 .increment = 8 448 }, 449 .iv_size = { 450 .min = 0, 451 .max = 0, 452 .increment = 0 453 } 454 }, } 455 }, } 456 }, 457 { /* AES CBC */ 458 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 459 {.sym = { 460 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, 461 {.cipher = { 462 .algo = RTE_CRYPTO_CIPHER_AES_CBC, 463 .block_size = 16, 464 .key_size = { 465 .min = 16, 466 .max = 32, 467 .increment = 8 468 }, 469 .iv_size = { 470 .min = 16, 471 .max = 16, 472 .increment = 0 473 } 474 }, } 475 }, } 476 }, 477 { /* AES CTR */ 478 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 479 {.sym = { 480 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, 481 {.cipher = { 482 .algo = RTE_CRYPTO_CIPHER_AES_CTR, 483 .block_size = 16, 484 .key_size = { 485 .min = 16, 486 .max = 32, 487 .increment = 8 488 }, 489 .iv_size = { 490 .min = 16, 491 .max = 16, 492 .increment = 0 493 } 494 }, } 495 }, } 496 }, 497 { /* 3DES CBC */ 498 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 499 {.sym = { 500 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, 501 {.cipher = { 502 .algo = RTE_CRYPTO_CIPHER_3DES_CBC, 503 .block_size = 8, 504 .key_size = { 505 .min = 16, 506 .max = 24, 507 .increment = 8 508 }, 509 .iv_size = { 510 .min = 8, 511 .max = 8, 512 .increment = 0 513 } 514 }, } 515 }, } 516 }, 517 { /* AES GCM */ 518 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 519 {.sym = { 520 .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD, 521 {.aead = { 522 .algo = RTE_CRYPTO_AEAD_AES_GCM, 523 .block_size = 16, 524 .key_size = { 525 .min = 16, 526 .max = 32, 527 .increment = 8 528 }, 529 .digest_size = { 530 .min = 16, 531 .max = 16, 532 .increment = 0 533 }, 534 .aad_size = { 535 .min = 0, 536 .max = 65535, 537 .increment = 1 538 }, 539 .iv_size = { 540 .min = 12, 541 .max = 16, 542 .increment = 4 543 }, 544 }, } 545 }, } 546 }, 547 RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() 548 }; 549 550 static int 551 ccp_pmd_config(struct rte_cryptodev *dev __rte_unused, 552 struct rte_cryptodev_config *config __rte_unused) 553 { 554 return 0; 555 } 556 557 static int 558 ccp_pmd_start(struct rte_cryptodev *dev) 559 { 560 return ccp_dev_start(dev); 561 } 562 563 static void 564 ccp_pmd_stop(struct rte_cryptodev *dev __rte_unused) 565 { 566 567 } 568 569 static int 570 ccp_pmd_close(struct rte_cryptodev *dev __rte_unused) 571 { 572 return 0; 573 } 574 575 static void 576 ccp_pmd_stats_get(struct rte_cryptodev *dev, 577 struct rte_cryptodev_stats *stats) 578 { 579 int qp_id; 580 581 for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) { 582 struct ccp_qp *qp = dev->data->queue_pairs[qp_id]; 583 584 stats->enqueued_count += qp->qp_stats.enqueued_count; 585 stats->dequeued_count += qp->qp_stats.dequeued_count; 586 587 stats->enqueue_err_count += qp->qp_stats.enqueue_err_count; 588 stats->dequeue_err_count += qp->qp_stats.dequeue_err_count; 589 } 590 591 } 592 593 static void 594 ccp_pmd_stats_reset(struct rte_cryptodev *dev) 595 { 596 int qp_id; 597 598 for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) { 599 struct ccp_qp *qp = dev->data->queue_pairs[qp_id]; 600 601 memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); 602 } 603 } 604 605 static void 606 ccp_pmd_info_get(struct rte_cryptodev *dev, 607 struct rte_cryptodev_info *dev_info) 608 { 609 struct ccp_private *internals = dev->data->dev_private; 610 611 if (dev_info != NULL) { 612 dev_info->driver_id = dev->driver_id; 613 dev_info->feature_flags = dev->feature_flags; 614 dev_info->capabilities = ccp_pmd_capabilities; 615 dev_info->max_nb_queue_pairs = internals->max_nb_qpairs; 616 dev_info->sym.max_nb_sessions = internals->max_nb_sessions; 617 } 618 } 619 620 static int 621 ccp_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id) 622 { 623 struct ccp_qp *qp; 624 625 if (dev->data->queue_pairs[qp_id] != NULL) { 626 qp = (struct ccp_qp *)dev->data->queue_pairs[qp_id]; 627 rte_ring_free(qp->processed_pkts); 628 rte_mempool_free(qp->batch_mp); 629 rte_free(qp); 630 dev->data->queue_pairs[qp_id] = NULL; 631 } 632 return 0; 633 } 634 635 static int 636 ccp_pmd_qp_set_unique_name(struct rte_cryptodev *dev, 637 struct ccp_qp *qp) 638 { 639 unsigned int n = snprintf(qp->name, sizeof(qp->name), 640 "ccp_pmd_%u_qp_%u", 641 dev->data->dev_id, qp->id); 642 643 if (n > sizeof(qp->name)) 644 return -1; 645 646 return 0; 647 } 648 649 static struct rte_ring * 650 ccp_pmd_qp_create_batch_info_ring(struct ccp_qp *qp, 651 unsigned int ring_size, int socket_id) 652 { 653 struct rte_ring *r; 654 655 r = rte_ring_lookup(qp->name); 656 if (r) { 657 if (r->size >= ring_size) { 658 CCP_LOG_INFO( 659 "Reusing ring %s for processed packets", 660 qp->name); 661 return r; 662 } 663 CCP_LOG_INFO( 664 "Unable to reuse ring %s for processed packets", 665 qp->name); 666 return NULL; 667 } 668 669 return rte_ring_create(qp->name, ring_size, socket_id, 670 RING_F_SP_ENQ | RING_F_SC_DEQ); 671 } 672 673 static int 674 ccp_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, 675 const struct rte_cryptodev_qp_conf *qp_conf, 676 int socket_id, struct rte_mempool *session_pool) 677 { 678 struct ccp_private *internals = dev->data->dev_private; 679 struct ccp_qp *qp; 680 int retval = 0; 681 682 if (qp_id >= internals->max_nb_qpairs) { 683 CCP_LOG_ERR("Invalid qp_id %u, should be less than %u", 684 qp_id, internals->max_nb_qpairs); 685 return (-EINVAL); 686 } 687 688 /* Free memory prior to re-allocation if needed. */ 689 if (dev->data->queue_pairs[qp_id] != NULL) 690 ccp_pmd_qp_release(dev, qp_id); 691 692 /* Allocate the queue pair data structure. */ 693 qp = rte_zmalloc_socket("CCP Crypto PMD Queue Pair", sizeof(*qp), 694 RTE_CACHE_LINE_SIZE, socket_id); 695 if (qp == NULL) { 696 CCP_LOG_ERR("Failed to allocate queue pair memory"); 697 return (-ENOMEM); 698 } 699 700 qp->dev = dev; 701 qp->id = qp_id; 702 dev->data->queue_pairs[qp_id] = qp; 703 704 retval = ccp_pmd_qp_set_unique_name(dev, qp); 705 if (retval) { 706 CCP_LOG_ERR("Failed to create unique name for ccp qp"); 707 goto qp_setup_cleanup; 708 } 709 710 qp->processed_pkts = ccp_pmd_qp_create_batch_info_ring(qp, 711 qp_conf->nb_descriptors, socket_id); 712 if (qp->processed_pkts == NULL) { 713 CCP_LOG_ERR("Failed to create batch info ring"); 714 goto qp_setup_cleanup; 715 } 716 717 qp->sess_mp = session_pool; 718 719 /* mempool for batch info */ 720 qp->batch_mp = rte_mempool_create( 721 qp->name, 722 qp_conf->nb_descriptors, 723 sizeof(struct ccp_batch_info), 724 RTE_CACHE_LINE_SIZE, 725 0, NULL, NULL, NULL, NULL, 726 SOCKET_ID_ANY, 0); 727 if (qp->batch_mp == NULL) 728 goto qp_setup_cleanup; 729 memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); 730 return 0; 731 732 qp_setup_cleanup: 733 dev->data->queue_pairs[qp_id] = NULL; 734 if (qp) 735 rte_free(qp); 736 return -1; 737 } 738 739 static int 740 ccp_pmd_qp_start(struct rte_cryptodev *dev __rte_unused, 741 uint16_t queue_pair_id __rte_unused) 742 { 743 return -ENOTSUP; 744 } 745 746 static int 747 ccp_pmd_qp_stop(struct rte_cryptodev *dev __rte_unused, 748 uint16_t queue_pair_id __rte_unused) 749 { 750 return -ENOTSUP; 751 } 752 753 static uint32_t 754 ccp_pmd_qp_count(struct rte_cryptodev *dev) 755 { 756 return dev->data->nb_queue_pairs; 757 } 758 759 static unsigned 760 ccp_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused) 761 { 762 return sizeof(struct ccp_session); 763 } 764 765 static int 766 ccp_pmd_session_configure(struct rte_cryptodev *dev, 767 struct rte_crypto_sym_xform *xform, 768 struct rte_cryptodev_sym_session *sess, 769 struct rte_mempool *mempool) 770 { 771 int ret; 772 void *sess_private_data; 773 774 if (unlikely(sess == NULL || xform == NULL)) { 775 CCP_LOG_ERR("Invalid session struct or xform"); 776 return -ENOMEM; 777 } 778 779 if (rte_mempool_get(mempool, &sess_private_data)) { 780 CCP_LOG_ERR("Couldn't get object from session mempool"); 781 return -ENOMEM; 782 } 783 ret = ccp_set_session_parameters(sess_private_data, xform); 784 if (ret != 0) { 785 CCP_LOG_ERR("failed configure session parameters"); 786 787 /* Return session to mempool */ 788 rte_mempool_put(mempool, sess_private_data); 789 return ret; 790 } 791 set_session_private_data(sess, dev->driver_id, 792 sess_private_data); 793 794 return 0; 795 } 796 797 static void 798 ccp_pmd_session_clear(struct rte_cryptodev *dev, 799 struct rte_cryptodev_sym_session *sess) 800 { 801 uint8_t index = dev->driver_id; 802 void *sess_priv = get_session_private_data(sess, index); 803 804 if (sess_priv) { 805 struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); 806 807 rte_mempool_put(sess_mp, sess_priv); 808 memset(sess_priv, 0, sizeof(struct ccp_session)); 809 set_session_private_data(sess, index, NULL); 810 } 811 } 812 813 struct rte_cryptodev_ops ccp_ops = { 814 .dev_configure = ccp_pmd_config, 815 .dev_start = ccp_pmd_start, 816 .dev_stop = ccp_pmd_stop, 817 .dev_close = ccp_pmd_close, 818 819 .stats_get = ccp_pmd_stats_get, 820 .stats_reset = ccp_pmd_stats_reset, 821 822 .dev_infos_get = ccp_pmd_info_get, 823 824 .queue_pair_setup = ccp_pmd_qp_setup, 825 .queue_pair_release = ccp_pmd_qp_release, 826 .queue_pair_start = ccp_pmd_qp_start, 827 .queue_pair_stop = ccp_pmd_qp_stop, 828 .queue_pair_count = ccp_pmd_qp_count, 829 830 .session_get_size = ccp_pmd_session_get_size, 831 .session_configure = ccp_pmd_session_configure, 832 .session_clear = ccp_pmd_session_clear, 833 }; 834 835 struct rte_cryptodev_ops *ccp_pmd_ops = &ccp_ops; 836