New upstream version 18.08
[deb_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 /*
20  * This struct holds all the data about a QAT pci device
21  * including data about all services it supports.
22  * It contains
23  *  - hw_data
24  *  - config data
25  *  - runtime data
26  */
27 struct qat_sym_dev_private;
28 struct qat_comp_dev_private;
29
30 struct qat_pci_device {
31
32         /* Data used by all services */
33         char name[QAT_DEV_NAME_MAX_LEN];
34         /**< Name of qat pci device */
35         uint8_t qat_dev_id;
36         /**< Device instance for this qat pci device */
37         struct rte_pci_device *pci_dev;
38         /**< PCI information. */
39         enum qat_device_gen qat_dev_gen;
40         /**< QAT device generation */
41         rte_spinlock_t arb_csr_lock;
42         /**< lock to protect accesses to the arbiter CSR */
43         __extension__
44         uint8_t attached : 1;
45         /**< Flag indicating the device is attached */
46
47         struct qat_qp *qps_in_use[QAT_MAX_SERVICES][ADF_MAX_QPS_ON_ANY_SERVICE];
48         /**< links to qps set up for each service, index same as on API */
49
50         /* Data relating to symmetric crypto service */
51         struct qat_sym_dev_private *sym_dev;
52         /**< link back to cryptodev private data */
53         struct rte_device sym_rte_dev;
54         /**< This represents the crypto subset of this pci device.
55          * Register with this rather than with the one in
56          * pci_dev so that its driver can have a crypto-specific name
57          */
58
59         /* Data relating to compression service */
60         struct qat_comp_dev_private *comp_dev;
61         /**< link back to compressdev private data */
62
63         /* Data relating to asymmetric crypto service */
64
65 };
66
67 struct qat_gen_hw_data {
68         enum qat_device_gen dev_gen;
69         const struct qat_qp_hw_data (*qp_hw_data)[ADF_MAX_QPS_ON_ANY_SERVICE];
70 };
71
72 extern struct qat_gen_hw_data qat_gen_config[];
73
74 struct qat_pci_device *
75 qat_pci_device_allocate(struct rte_pci_device *pci_dev);
76
77 int
78 qat_pci_device_release(struct rte_pci_device *pci_dev);
79
80 struct qat_pci_device *
81 qat_get_qat_dev_from_pci_dev(struct rte_pci_device *pci_dev);
82
83 /* declaration needed for weak functions */
84 int
85 qat_sym_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused);
86
87 int
88 qat_asym_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused);
89
90 int
91 qat_sym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused);
92
93 int
94 qat_asym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused);
95
96 int
97 qat_comp_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused);
98
99 int
100 qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused);
101
102 #endif /* _QAT_DEVICE_H_ */