1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2018 Advanced Micro Devices, Inc. All rights reserved. 3 */ 4 5 #ifndef _CCP_PMD_PRIVATE_H_ 6 #define _CCP_PMD_PRIVATE_H_ 7 8 #include <rte_cryptodev.h> 9 #include "ccp_crypto.h" 10 11 extern int crypto_ccp_logtype; 12 #define RTE_LOGTYPE_CRYPTO_CCP crypto_ccp_logtype 13 14 #define CCP_LOG_ERR(fmt, args...) \ 15 RTE_LOG_LINE(ERR, CRYPTO_CCP, "%s() line %u: " fmt, __func__, __LINE__, ## args) 16 17 #ifdef RTE_LIBRTE_CCP_DEBUG 18 #define CCP_LOG_INFO(fmt, args...) \ 19 RTE_LOG_LINE(INFO, CRYPTO_CCP, "%s() line %u: " fmt, __func__, __LINE__, ## args) 20 21 #define CCP_LOG_DBG(fmt, args...) \ 22 RTE_LOG_LINE(DEBUG, CRYPTO_CCP, "%s() line %u: " fmt, __func__, __LINE__, ## args) 23 #else 24 #define CCP_LOG_INFO(fmt, args...) 25 #define CCP_LOG_DBG(fmt, args...) 26 #endif 27 28 /**< Maximum queue pairs supported by CCP PMD */ 29 #define CCP_PMD_MAX_QUEUE_PAIRS 8 30 #define CCP_NB_MAX_DESCRIPTORS 1024 31 #define CCP_MAX_BURST 256 32 33 #include "ccp_dev.h" 34 35 /* private data structure for each CCP crypto device */ 36 struct ccp_private { 37 unsigned int max_nb_qpairs; /**< Max number of queue pairs */ 38 uint8_t crypto_num_dev; /**< Number of working crypto devices */ 39 bool auth_opt; /**< Authentication offload option */ 40 struct ccp_device *last_dev; /**< Last working crypto device */ 41 }; 42 43 /* CCP batch info */ 44 struct __rte_cache_aligned ccp_batch_info { 45 struct rte_crypto_op *op[CCP_MAX_BURST]; 46 /**< optable populated at enque time from app*/ 47 int op_idx; 48 uint16_t b_idx; 49 struct ccp_queue *cmd_q; 50 uint16_t opcnt; 51 uint16_t total_nb_ops; 52 /**< no. of crypto ops in batch*/ 53 int desccnt; 54 /**< no. of ccp queue descriptors*/ 55 uint32_t head_offset; 56 /**< ccp queue head tail offsets time of enqueue*/ 57 uint32_t tail_offset; 58 uint8_t lsb_buf[CCP_SB_BYTES * CCP_MAX_BURST]; 59 phys_addr_t lsb_buf_phys; 60 /**< LSB intermediate buf for passthru */ 61 int lsb_buf_idx; 62 uint16_t auth_ctr; 63 /**< auth only ops batch for CPU based auth */ 64 }; 65 66 /**< CCP crypto queue pair */ 67 struct __rte_cache_aligned ccp_qp { 68 uint16_t id; 69 /**< Queue Pair Identifier */ 70 char name[RTE_CRYPTODEV_NAME_MAX_LEN]; 71 /**< Unique Queue Pair Name */ 72 struct rte_ring *processed_pkts; 73 /**< Ring for placing process packets */ 74 struct rte_mempool *sess_mp; 75 /**< Session Mempool */ 76 struct rte_mempool *batch_mp; 77 /**< Session Mempool for batch info */ 78 struct rte_cryptodev_stats qp_stats; 79 /**< Queue pair statistics */ 80 struct ccp_batch_info *b_info; 81 /**< Store ops pulled out of queue */ 82 struct rte_cryptodev *dev; 83 /**< rte crypto device to which this qp belongs */ 84 uint8_t temp_digest[DIGEST_LENGTH_MAX]; 85 /**< Buffer used to store the digest generated 86 * by the driver when verifying a digest provided 87 * by the user (using authentication verify operation) 88 */ 89 }; 90 91 92 /**< device specific operations function pointer structure */ 93 extern struct rte_cryptodev_ops *ccp_pmd_ops; 94 95 uint16_t 96 ccp_cpu_pmd_enqueue_burst(void *queue_pair, 97 struct rte_crypto_op **ops, 98 uint16_t nb_ops); 99 uint16_t 100 ccp_cpu_pmd_dequeue_burst(void *queue_pair, 101 struct rte_crypto_op **ops, 102 uint16_t nb_ops); 103 104 #endif /* _CCP_PMD_PRIVATE_H_ */ 105