New upstream version 18.08
[deb_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 };
22
23 enum qat_service_type {
24         QAT_SERVICE_ASYMMETRIC = 0,
25         QAT_SERVICE_SYMMETRIC,
26         QAT_SERVICE_COMPRESSION,
27         QAT_SERVICE_INVALID
28 };
29
30 #define QAT_MAX_SERVICES                (QAT_SERVICE_INVALID)
31
32 /**< Common struct for scatter-gather list operations */
33 struct qat_flat_buf {
34         uint32_t len;
35         uint32_t resrvd;
36         uint64_t addr;
37 } __rte_packed;
38
39 #define qat_sgl_hdr  struct { \
40         uint64_t resrvd; \
41         uint32_t num_bufs; \
42         uint32_t num_mapped_bufs; \
43 }
44
45 __extension__
46 struct qat_sgl {
47         qat_sgl_hdr;
48         /* flexible array of flat buffers*/
49         struct qat_flat_buf buffers[0];
50 } __rte_packed __rte_cache_aligned;
51
52 /** Common, i.e. not service-specific, statistics */
53 struct qat_common_stats {
54         uint64_t enqueued_count;
55         /**< Count of all operations enqueued */
56         uint64_t dequeued_count;
57         /**< Count of all operations dequeued */
58
59         uint64_t enqueue_err_count;
60         /**< Total error count on operations enqueued */
61         uint64_t dequeue_err_count;
62         /**< Total error count on operations dequeued */
63 };
64
65 struct qat_pci_device;
66
67 int
68 qat_sgl_fill_array(struct rte_mbuf *buf, int64_t offset,
69                 void *list_in, uint32_t data_len,
70                 const uint16_t max_segs);
71 void
72 qat_stats_get(struct qat_pci_device *dev,
73                 struct qat_common_stats *stats,
74                 enum qat_service_type service);
75 void
76 qat_stats_reset(struct qat_pci_device *dev,
77                 enum qat_service_type service);
78
79 #endif /* _QAT_COMMON_H_ */