xref: /dpdk/drivers/crypto/ccp/ccp_pmd_private.h (revision 3c20cf98e2c99e6178585299056f3fb6d08467f3)
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 
10 #define CRYPTODEV_NAME_CCP_PMD crypto_ccp
11 
12 #define CCP_LOG_ERR(fmt, args...) \
13 	RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n",  \
14 			RTE_STR(CRYPTODEV_NAME_CCP_PMD), \
15 			__func__, __LINE__, ## args)
16 
17 #ifdef RTE_LIBRTE_CCP_DEBUG
18 #define CCP_LOG_INFO(fmt, args...) \
19 	RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
20 			RTE_STR(CRYPTODEV_NAME_CCP_PMD), \
21 			__func__, __LINE__, ## args)
22 
23 #define CCP_LOG_DBG(fmt, args...) \
24 	RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
25 			RTE_STR(CRYPTODEV_NAME_CCP_PMD), \
26 			__func__, __LINE__, ## args)
27 #else
28 #define CCP_LOG_INFO(fmt, args...)
29 #define CCP_LOG_DBG(fmt, args...)
30 #endif
31 
32 /**< Maximum queue pairs supported by CCP PMD */
33 #define CCP_PMD_MAX_QUEUE_PAIRS	1
34 #define CCP_NB_MAX_DESCRIPTORS 1024
35 #define CCP_MAX_BURST 64
36 
37 #include "ccp_dev.h"
38 
39 /* private data structure for each CCP crypto device */
40 struct ccp_private {
41 	unsigned int max_nb_qpairs;	/**< Max number of queue pairs */
42 	unsigned int max_nb_sessions;	/**< Max number of sessions */
43 	uint8_t crypto_num_dev;		/**< Number of working crypto devices */
44 	struct ccp_device *last_dev;	/**< Last working crypto device */
45 };
46 
47 /* CCP batch info */
48 struct ccp_batch_info {
49 	struct rte_crypto_op *op[CCP_MAX_BURST];
50 	/**< optable populated at enque time from app*/
51 	int op_idx;
52 	struct ccp_queue *cmd_q;
53 	uint16_t opcnt;
54 	/**< no. of crypto ops in batch*/
55 	int desccnt;
56 	/**< no. of ccp queue descriptors*/
57 	uint32_t head_offset;
58 	/**< ccp queue head tail offsets time of enqueue*/
59 	uint32_t tail_offset;
60 	uint8_t lsb_buf[CCP_SB_BYTES * CCP_MAX_BURST];
61 	phys_addr_t lsb_buf_phys;
62 	/**< LSB intermediate buf for passthru */
63 	int lsb_buf_idx;
64 } __rte_cache_aligned;
65 
66 /**< CCP crypto queue pair */
67 struct 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 } __rte_cache_aligned;
85 
86 
87 /**< device specific operations function pointer structure */
88 extern struct rte_cryptodev_ops *ccp_pmd_ops;
89 
90 uint16_t
91 ccp_cpu_pmd_enqueue_burst(void *queue_pair,
92 			  struct rte_crypto_op **ops,
93 			  uint16_t nb_ops);
94 uint16_t
95 ccp_cpu_pmd_dequeue_burst(void *queue_pair,
96 			  struct rte_crypto_op **ops,
97 			  uint16_t nb_ops);
98 
99 #endif /* _CCP_PMD_PRIVATE_H_ */
100