common/qat: support GEN4 devices
[dpdk.git] / drivers / common / qat / qat_common.h
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  */
18 enum qat_device_gen {
19         QAT_GEN1 = 1,
20         QAT_GEN2,
21         QAT_GEN3,
22         QAT_GEN4
23 };
24
25 enum qat_service_type {
26         QAT_SERVICE_ASYMMETRIC = 0,
27         QAT_SERVICE_SYMMETRIC,
28         QAT_SERVICE_COMPRESSION,
29         QAT_SERVICE_INVALID
30 };
31
32 #define QAT_MAX_SERVICES                (QAT_SERVICE_INVALID)
33
34 /**< Common struct for scatter-gather list operations */
35 struct qat_flat_buf {
36         uint32_t len;
37         uint32_t resrvd;
38         uint64_t addr;
39 } __rte_packed;
40
41 #define qat_sgl_hdr  struct { \
42         uint64_t resrvd; \
43         uint32_t num_bufs; \
44         uint32_t num_mapped_bufs; \
45 }
46
47 __extension__
48 struct qat_sgl {
49         qat_sgl_hdr;
50         /* flexible array of flat buffers*/
51         struct qat_flat_buf buffers[0];
52 } __rte_packed __rte_cache_aligned;
53
54 /** Common, i.e. not service-specific, statistics */
55 struct qat_common_stats {
56         uint64_t enqueued_count;
57         /**< Count of all operations enqueued */
58         uint64_t dequeued_count;
59         /**< Count of all operations dequeued */
60
61         uint64_t enqueue_err_count;
62         /**< Total error count on operations enqueued */
63         uint64_t dequeue_err_count;
64         /**< Total error count on operations dequeued */
65         uint64_t threshold_hit_count;
66         /**< Total number of times min qp threshold condition was fulfilled */
67
68 };
69
70 struct qat_pci_device;
71
72 int
73 qat_sgl_fill_array(struct rte_mbuf *buf, int64_t offset,
74                 void *list_in, uint32_t data_len,
75                 const uint16_t max_segs);
76 void
77 qat_stats_get(struct qat_pci_device *dev,
78                 struct qat_common_stats *stats,
79                 enum qat_service_type service);
80 void
81 qat_stats_reset(struct qat_pci_device *dev,
82                 enum qat_service_type service);
83
84 #endif /* _QAT_COMMON_H_ */