1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2020 Broadcom 3 * All rights reserved. 4 */ 5 6 #ifndef _BCMFS_SYM_SESSION_H_ 7 #define _BCMFS_SYM_SESSION_H_ 8 9 #include <stdbool.h> 10 #include <rte_crypto.h> 11 #include <cryptodev_pmd.h> 12 13 #include "bcmfs_sym_defs.h" 14 #include "bcmfs_sym_req.h" 15 16 /* BCMFS_SYM operation order mode enumerator */ 17 enum bcmfs_sym_chain_order { 18 BCMFS_SYM_CHAIN_ONLY_CIPHER, 19 BCMFS_SYM_CHAIN_ONLY_AUTH, 20 BCMFS_SYM_CHAIN_CIPHER_AUTH, 21 BCMFS_SYM_CHAIN_AUTH_CIPHER, 22 BCMFS_SYM_CHAIN_AEAD, 23 BCMFS_SYM_CHAIN_NOT_SUPPORTED 24 }; 25 26 /* BCMFS_SYM crypto private session structure */ 27 struct __rte_cache_aligned bcmfs_sym_session { 28 enum bcmfs_sym_chain_order chain_order; 29 30 /* Cipher Parameters */ 31 struct { 32 enum rte_crypto_cipher_operation op; 33 /* Cipher operation */ 34 enum rte_crypto_cipher_algorithm algo; 35 /* Cipher algorithm */ 36 struct { 37 uint8_t data[BCMFS_MAX_KEY_SIZE]; 38 size_t length; 39 } key; 40 struct { 41 uint16_t offset; 42 uint16_t length; 43 } iv; 44 } cipher; 45 46 /* Authentication Parameters */ 47 struct { 48 enum rte_crypto_auth_operation op; 49 /* Auth operation */ 50 enum rte_crypto_auth_algorithm algo; 51 /* Auth algorithm */ 52 53 struct { 54 uint8_t data[BCMFS_MAX_KEY_SIZE]; 55 size_t length; 56 } key; 57 struct { 58 uint16_t offset; 59 uint16_t length; 60 } iv; 61 62 uint16_t digest_length; 63 } auth; 64 65 /* Aead Parameters */ 66 struct { 67 enum rte_crypto_aead_operation op; 68 /* AEAD operation */ 69 enum rte_crypto_aead_algorithm algo; 70 /* AEAD algorithm */ 71 struct { 72 uint8_t data[BCMFS_MAX_KEY_SIZE]; 73 size_t length; 74 } key; 75 struct { 76 uint16_t offset; 77 uint16_t length; 78 } iv; 79 80 uint16_t digest_length; 81 82 uint16_t aad_length; 83 } aead; 84 85 bool cipher_first; 86 }; 87 88 int 89 bcmfs_process_crypto_op(struct rte_crypto_op *op, 90 struct bcmfs_sym_session *sess, 91 struct bcmfs_sym_request *req); 92 93 int 94 bcmfs_sym_session_configure(struct rte_cryptodev *dev, 95 struct rte_crypto_sym_xform *xform, 96 struct rte_cryptodev_sym_session *sess); 97 98 void 99 bcmfs_sym_session_clear(struct rte_cryptodev *dev, 100 struct rte_cryptodev_sym_session *sess); 101 102 unsigned int 103 bcmfs_sym_session_get_private_size(struct rte_cryptodev *dev __rte_unused); 104 105 struct bcmfs_sym_session * 106 bcmfs_sym_get_session(struct rte_crypto_op *op); 107 108 #endif /* _BCMFS_SYM_SESSION_H_ */ 109