crypto/qat: add asymmetric crypto PMD
[dpdk.git] / drivers / common / qat / qat_device.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Intel Corporation
3  */
4 #ifndef _QAT_DEVICE_H_
5 #define _QAT_DEVICE_H_
6
7 #include <rte_bus_pci.h>
8
9 #include "qat_common.h"
10 #include "qat_logs.h"
11 #include "adf_transport_access_macros.h"
12 #include "qat_qp.h"
13
14 #define QAT_DETACHED  (0)
15 #define QAT_ATTACHED  (1)
16
17 #define QAT_DEV_NAME_MAX_LEN    64
18
19 enum qat_comp_num_im_buffers {
20         QAT_NUM_INTERM_BUFS_GEN1 = 12,
21         QAT_NUM_INTERM_BUFS_GEN2 = 20,
22         QAT_NUM_INTERM_BUFS_GEN3 = 20
23 };
24
25 /*
26  * This struct holds all the data about a QAT pci device
27  * including data about all services it supports.
28  * It contains
29  *  - hw_data
30  *  - config data
31  *  - runtime data
32  */
33 struct qat_sym_dev_private;
34 struct qat_asym_dev_private;
35 struct qat_comp_dev_private;
36
37 struct qat_pci_device {
38
39         /* Data used by all services */
40         char name[QAT_DEV_NAME_MAX_LEN];
41         /**< Name of qat pci device */
42         uint8_t qat_dev_id;
43         /**< Device instance for this qat pci device */
44         struct rte_pci_device *pci_dev;
45         /**< PCI information. */
46         enum qat_device_gen qat_dev_gen;
47         /**< QAT device generation */
48         rte_spinlock_t arb_csr_lock;
49         /**< lock to protect accesses to the arbiter CSR */
50         __extension__
51         uint8_t attached : 1;
52         /**< Flag indicating the device is attached */
53
54         struct qat_qp *qps_in_use[QAT_MAX_SERVICES][ADF_MAX_QPS_ON_ANY_SERVICE];
55         /**< links to qps set up for each service, index same as on API */
56
57         /* Data relating to symmetric crypto service */
58         struct qat_sym_dev_private *sym_dev;
59         /**< link back to cryptodev private data */
60         struct rte_device sym_rte_dev;
61         /**< This represents the crypto sym subset of this pci device.
62          * Register with this rather than with the one in
63          * pci_dev so that its driver can have a crypto-specific name
64          */
65
66         /* Data relating to asymmetric crypto service */
67         struct qat_asym_dev_private *asym_dev;
68         /**< link back to cryptodev private data */
69         struct rte_device asym_rte_dev;
70         /**< This represents the crypto asym subset of this pci device.
71          * Register with this rather than with the one in
72          * pci_dev so that its driver can have a crypto-specific name
73          */
74
75         /* Data relating to compression service */
76         struct qat_comp_dev_private *comp_dev;
77         /**< link back to compressdev private data */
78         struct rte_device comp_rte_dev;
79         /**< This represents the compression subset of this pci device.
80          * Register with this rather than with the one in
81          * pci_dev so that its driver can have a compression-specific name
82          */
83
84         /* Data relating to asymmetric crypto service */
85
86 };
87
88 struct qat_gen_hw_data {
89         enum qat_device_gen dev_gen;
90         const struct qat_qp_hw_data (*qp_hw_data)[ADF_MAX_QPS_ON_ANY_SERVICE];
91         enum qat_comp_num_im_buffers comp_num_im_bufs_required;
92 };
93
94 extern struct qat_gen_hw_data qat_gen_config[];
95
96 struct qat_pci_device *
97 qat_pci_device_allocate(struct rte_pci_device *pci_dev);
98
99 int
100 qat_pci_device_release(struct rte_pci_device *pci_dev);
101
102 struct qat_pci_device *
103 qat_get_qat_dev_from_pci_dev(struct rte_pci_device *pci_dev);
104
105 /* declaration needed for weak functions */
106 int
107 qat_sym_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused);
108
109 int
110 qat_asym_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused);
111
112 int
113 qat_sym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused);
114
115 int
116 qat_asym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused);
117
118 int
119 qat_comp_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused);
120
121 int
122 qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused);
123
124 #endif /* _QAT_DEVICE_H_ */