xref: /dpdk/drivers/common/qat/qat_common.h (revision f0f369a6)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Intel Corporation
3  */
4 #ifndef _QAT_COMMON_H_
5 #define _QAT_COMMON_H_
6 
7 #include <stdint.h>
8 
9 #include <rte_mbuf.h>
10 
11 /**< Intel(R) QAT device name for PCI registration */
12 #define QAT_PCI_NAME	qat
13 #define QAT_64_BTYE_ALIGN_MASK (~0x3f)
14 
15 /* Intel(R) QuickAssist Technology device generation is enumerated
16  * from one according to the generation of the device.
17  * QAT_GEN* is used as the index to find all devices
18  */
19 enum qat_device_gen {
20 	QAT_GEN1,
21 	QAT_GEN2,
22 	QAT_GEN3,
23 	QAT_GEN4,
24 	QAT_N_GENS
25 };
26 
27 enum qat_service_type {
28 	QAT_SERVICE_ASYMMETRIC,
29 	QAT_SERVICE_SYMMETRIC,
30 	QAT_SERVICE_COMPRESSION,
31 	QAT_MAX_SERVICES
32 };
33 
34 #define QAT_SERVICE_INVALID	(QAT_MAX_SERVICES)
35 
36 enum qat_svc_list {
37 	QAT_SVC_UNUSED = 0,
38 	QAT_SVC_CRYPTO = 1,
39 	QAT_SVC_COMPRESSION = 2,
40 	QAT_SVC_SYM = 3,
41 	QAT_SVC_ASYM = 4,
42 };
43 
44 /**< Common struct for scatter-gather list operations */
45 struct qat_flat_buf {
46 	uint32_t len;
47 	uint32_t resrvd;
48 	uint64_t addr;
49 } __rte_packed;
50 
51 #define qat_sgl_hdr  struct { \
52 	uint64_t resrvd; \
53 	uint32_t num_bufs; \
54 	uint32_t num_mapped_bufs; \
55 }
56 
57 __extension__
58 struct qat_sgl {
59 	qat_sgl_hdr;
60 	/* flexible array of flat buffers*/
61 	struct qat_flat_buf buffers[0];
62 } __rte_packed __rte_cache_aligned;
63 
64 /** Common, i.e. not service-specific, statistics */
65 struct qat_common_stats {
66 	uint64_t enqueued_count;
67 	/**< Count of all operations enqueued */
68 	uint64_t dequeued_count;
69 	/**< Count of all operations dequeued */
70 
71 	uint64_t enqueue_err_count;
72 	/**< Total error count on operations enqueued */
73 	uint64_t dequeue_err_count;
74 	/**< Total error count on operations dequeued */
75 	uint64_t threshold_hit_count;
76 	/**< Total number of times min qp threshold condition was fulfilled */
77 
78 };
79 
80 struct qat_pci_device;
81 
82 int
83 qat_sgl_fill_array(struct rte_mbuf *buf, int64_t offset,
84 		void *list_in, uint32_t data_len,
85 		const uint16_t max_segs);
86 void
87 qat_stats_get(struct qat_pci_device *dev,
88 		struct qat_common_stats *stats,
89 		enum qat_service_type service);
90 void
91 qat_stats_reset(struct qat_pci_device *dev,
92 		enum qat_service_type service);
93 
94 const char *
95 qat_service_get_str(enum qat_service_type type);
96 
97 #endif /* _QAT_COMMON_H_ */
98