1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
7 #include <rte_bus_pci.h>
9 #include "qat_common.h"
11 #include "adf_transport_access_macros.h"
14 #define QAT_DETACHED (0)
15 #define QAT_ATTACHED (1)
17 #define QAT_DEV_NAME_MAX_LEN 64
19 #define SYM_ENQ_THRESHOLD_NAME "qat_sym_enq_threshold"
20 #define ASYM_ENQ_THRESHOLD_NAME "qat_asym_enq_threshold"
21 #define COMP_ENQ_THRESHOLD_NAME "qat_comp_enq_threshold"
22 #define MAX_QP_THRESHOLD_SIZE 32
25 * Function prototypes for GENx specific device operations.
27 typedef int (*qat_dev_reset_ring_pairs_t)
28 (struct qat_pci_device *);
29 typedef const struct rte_mem_resource* (*qat_dev_get_transport_bar_t)
30 (struct rte_pci_device *);
31 typedef int (*qat_dev_get_misc_bar_t)
32 (struct rte_mem_resource **, struct rte_pci_device *);
33 typedef int (*qat_dev_read_config_t)
34 (struct qat_pci_device *);
35 typedef int (*qat_dev_get_extra_size_t)(void);
37 struct qat_dev_hw_spec_funcs {
38 qat_dev_reset_ring_pairs_t qat_dev_reset_ring_pairs;
39 qat_dev_get_transport_bar_t qat_dev_get_transport_bar;
40 qat_dev_get_misc_bar_t qat_dev_get_misc_bar;
41 qat_dev_read_config_t qat_dev_read_config;
42 qat_dev_get_extra_size_t qat_dev_get_extra_size;
45 extern struct qat_dev_hw_spec_funcs *qat_dev_hw_spec[];
47 struct qat_dev_cmd_param {
52 struct qat_device_info {
53 const struct rte_memzone *mz;
54 /**< mz to store the qat_pci_device so it can be
55 * shared across processes
57 struct rte_pci_device *pci_dev;
58 struct rte_device sym_rte_dev;
59 /**< This represents the crypto sym subset of this pci device.
60 * Register with this rather than with the one in
61 * pci_dev so that its driver can have a crypto-specific name
64 struct rte_device asym_rte_dev;
65 /**< This represents the crypto asym subset of this pci device.
66 * Register with this rather than with the one in
67 * pci_dev so that its driver can have a crypto-specific name
70 struct rte_device comp_rte_dev;
71 /**< This represents the compression subset of this pci device.
72 * Register with this rather than with the one in
73 * pci_dev so that its driver can have a compression-specific name
77 extern struct qat_device_info qat_pci_devs[];
79 struct qat_sym_dev_private;
80 struct qat_asym_dev_private;
81 struct qat_comp_dev_private;
84 * This struct holds all the data about a QAT pci device
85 * including data about all services it supports.
90 * Note: as this data can be shared in a multi-process scenario,
91 * any pointers in it must also point to shared memory.
93 struct qat_pci_device {
95 /* Data used by all services */
96 char name[QAT_DEV_NAME_MAX_LEN];
97 /**< Name of qat pci device */
99 /**< Id of device instance for this qat pci device */
100 enum qat_device_gen qat_dev_gen;
101 /**< QAT device generation */
102 rte_spinlock_t arb_csr_lock;
103 /**< lock to protect accesses to the arbiter CSR */
105 struct qat_qp *qps_in_use[QAT_MAX_SERVICES][ADF_MAX_QPS_ON_ANY_SERVICE];
106 /**< links to qps set up for each service, index same as on API */
108 /* Data relating to symmetric crypto service */
109 struct qat_sym_dev_private *sym_dev;
110 /**< link back to cryptodev private data */
112 int qat_sym_driver_id;
113 /**< Symmetric driver id used by this device */
115 /* Data relating to asymmetric crypto service */
116 struct qat_asym_dev_private *asym_dev;
117 /**< link back to cryptodev private data */
119 int qat_asym_driver_id;
120 /**< Symmetric driver id used by this device */
122 /* Data relating to compression service */
123 struct qat_comp_dev_private *comp_dev;
124 /**< link back to compressdev private data */
125 void *misc_bar_io_addr;
126 /**< Address of misc bar */
128 /**< Per generation specific information */
131 struct qat_gen_hw_data {
132 enum qat_device_gen dev_gen;
133 const struct qat_qp_hw_data (*qp_hw_data)[ADF_MAX_QPS_ON_ANY_SERVICE];
134 struct qat_pf2vf_dev *pf2vf_dev;
137 struct qat_pf2vf_dev {
138 uint32_t pf2vf_offset;
139 uint32_t vf2pf_offset;
140 int pf2vf_type_shift;
141 uint32_t pf2vf_type_mask;
142 int pf2vf_data_shift;
143 uint32_t pf2vf_data_mask;
146 extern struct qat_gen_hw_data qat_gen_config[];
148 struct qat_pci_device *
149 qat_pci_device_allocate(struct rte_pci_device *pci_dev,
150 struct qat_dev_cmd_param *qat_dev_cmd_param);
152 struct qat_pci_device *
153 qat_get_qat_dev_from_pci_dev(struct rte_pci_device *pci_dev);
155 /* declaration needed for weak functions */
157 qat_sym_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused,
158 struct qat_dev_cmd_param *qat_dev_cmd_param);
161 qat_asym_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused,
162 struct qat_dev_cmd_param *qat_dev_cmd_param);
165 qat_sym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused);
168 qat_asym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused);
171 qat_comp_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused,
172 struct qat_dev_cmd_param *qat_dev_cmd_param);
175 qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused);
177 #endif /* _QAT_DEVICE_H_ */