crypto/cnxk: use atomics to access CPT res
[dpdk.git] / drivers / crypto / qat / qat_crypto.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2021 Intel Corporation
3  */
4
5  #ifndef _QAT_CRYPTO_H_
6  #define _QAT_CRYPTO_H_
7
8 #include <rte_cryptodev.h>
9
10 #include "qat_device.h"
11
12 extern uint8_t qat_sym_driver_id;
13 extern uint8_t qat_asym_driver_id;
14
15 /** helper macro to set cryptodev capability range **/
16 #define CAP_RNG(n, l, r, i) .n = {.min = l, .max = r, .increment = i}
17
18 #define CAP_RNG_ZERO(n) .n = {.min = 0, .max = 0, .increment = 0}
19 /** helper macro to set cryptodev capability value **/
20 #define CAP_SET(n, v) .n = v
21
22 /** private data structure for a QAT device.
23  * there can be one of these on each qat_pci_device (VF).
24  */
25 struct qat_cryptodev_private {
26         struct qat_pci_device *qat_dev;
27         /**< The qat pci device hosting the service */
28         uint8_t dev_id;
29         /**< Device instance for this rte_cryptodev */
30         const struct rte_cryptodev_capabilities *qat_dev_capabilities;
31         /* QAT device symmetric crypto capabilities */
32         const struct rte_memzone *capa_mz;
33         /* Shared memzone for storing capabilities */
34         uint16_t min_enq_burst_threshold;
35         uint32_t internal_capabilities; /* see flags QAT_SYM_CAP_xxx */
36         enum qat_service_type service_type;
37 };
38
39 struct qat_capabilities_info {
40         struct rte_cryptodev_capabilities *data;
41         uint64_t size;
42 };
43
44 typedef struct qat_capabilities_info (*get_capabilities_info_t)
45                         (struct qat_pci_device *qat_dev);
46
47 typedef uint64_t (*get_feature_flags_t)(struct qat_pci_device *qat_dev);
48
49 typedef void * (*create_security_ctx_t)(void *cryptodev);
50
51 struct qat_crypto_gen_dev_ops {
52         get_feature_flags_t get_feature_flags;
53         get_capabilities_info_t get_capabilities;
54         struct rte_cryptodev_ops *cryptodev_ops;
55 #ifdef RTE_LIB_SECURITY
56         create_security_ctx_t create_security_ctx;
57 #endif
58 };
59
60 int
61 qat_cryptodev_config(struct rte_cryptodev *dev,
62                 struct rte_cryptodev_config *config);
63
64 int
65 qat_cryptodev_start(struct rte_cryptodev *dev);
66
67 void
68 qat_cryptodev_stop(struct rte_cryptodev *dev);
69
70 int
71 qat_cryptodev_close(struct rte_cryptodev *dev);
72
73 void
74 qat_cryptodev_info_get(struct rte_cryptodev *dev,
75                 struct rte_cryptodev_info *info);
76
77 void
78 qat_cryptodev_stats_get(struct rte_cryptodev *dev,
79                 struct rte_cryptodev_stats *stats);
80
81 void
82 qat_cryptodev_stats_reset(struct rte_cryptodev *dev);
83
84 int
85 qat_cryptodev_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
86         const struct rte_cryptodev_qp_conf *qp_conf, int socket_id);
87
88 int
89 qat_cryptodev_qp_release(struct rte_cryptodev *dev, uint16_t queue_pair_id);
90
91 #endif