Commit | Line | Data |
---|---|---|
d8cba25d TS |
1 | /* |
2 | This file is provided under a dual BSD/GPLv2 license. When using or | |
3 | redistributing this file, you may do so under either license. | |
4 | ||
5 | GPL LICENSE SUMMARY | |
6 | Copyright(c) 2014 Intel Corporation. | |
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of version 2 of the GNU General Public License as | |
9 | published by the Free Software Foundation. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, but | |
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | General Public License for more details. | |
15 | ||
16 | Contact Information: | |
17 | qat-linux@intel.com | |
18 | ||
19 | BSD LICENSE | |
20 | Copyright(c) 2014 Intel Corporation. | |
21 | Redistribution and use in source and binary forms, with or without | |
22 | modification, are permitted provided that the following conditions | |
23 | are met: | |
24 | ||
25 | * Redistributions of source code must retain the above copyright | |
26 | notice, this list of conditions and the following disclaimer. | |
27 | * Redistributions in binary form must reproduce the above copyright | |
28 | notice, this list of conditions and the following disclaimer in | |
29 | the documentation and/or other materials provided with the | |
30 | distribution. | |
31 | * Neither the name of Intel Corporation nor the names of its | |
32 | contributors may be used to endorse or promote products derived | |
33 | from this software without specific prior written permission. | |
34 | ||
35 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
36 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
37 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
38 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
39 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
40 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
41 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
42 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
43 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
44 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
45 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
46 | */ | |
47 | #ifndef ADF_DRV_H | |
48 | #define ADF_DRV_H | |
49 | ||
50 | #include <linux/list.h> | |
51 | #include <linux/pci.h> | |
52 | #include "adf_accel_devices.h" | |
53 | #include "icp_qat_fw_loader_handle.h" | |
54 | #include "icp_qat_hal.h" | |
55 | ||
551d7ed2 AB |
56 | #define ADF_MAJOR_VERSION 0 |
57 | #define ADF_MINOR_VERSION 1 | |
58 | #define ADF_BUILD_VERSION 3 | |
59 | #define ADF_DRV_VERSION __stringify(ADF_MAJOR_VERSION) "." \ | |
60 | __stringify(ADF_MINOR_VERSION) "." \ | |
61 | __stringify(ADF_BUILD_VERSION) | |
62 | ||
d8cba25d TS |
63 | #define ADF_STATUS_RESTARTING 0 |
64 | #define ADF_STATUS_STARTING 1 | |
65 | #define ADF_STATUS_CONFIGURED 2 | |
66 | #define ADF_STATUS_STARTED 3 | |
67 | #define ADF_STATUS_AE_INITIALISED 4 | |
68 | #define ADF_STATUS_AE_UCODE_LOADED 5 | |
69 | #define ADF_STATUS_AE_STARTED 6 | |
70 | #define ADF_STATUS_ORPHAN_TH_RUNNING 7 | |
71 | #define ADF_STATUS_IRQ_ALLOCATED 8 | |
72 | ||
73 | enum adf_dev_reset_mode { | |
74 | ADF_DEV_RESET_ASYNC = 0, | |
75 | ADF_DEV_RESET_SYNC | |
76 | }; | |
77 | ||
78 | enum adf_event { | |
79 | ADF_EVENT_INIT = 0, | |
80 | ADF_EVENT_START, | |
81 | ADF_EVENT_STOP, | |
82 | ADF_EVENT_SHUTDOWN, | |
83 | ADF_EVENT_RESTARTING, | |
84 | ADF_EVENT_RESTARTED, | |
85 | }; | |
86 | ||
87 | struct service_hndl { | |
88 | int (*event_hld)(struct adf_accel_dev *accel_dev, | |
89 | enum adf_event event); | |
90 | unsigned long init_status; | |
91 | unsigned long start_status; | |
92 | char *name; | |
93 | struct list_head list; | |
94 | int admin; | |
95 | }; | |
96 | ||
97 | int adf_service_register(struct service_hndl *service); | |
98 | int adf_service_unregister(struct service_hndl *service); | |
99 | ||
100 | int adf_dev_init(struct adf_accel_dev *accel_dev); | |
101 | int adf_dev_start(struct adf_accel_dev *accel_dev); | |
102 | int adf_dev_stop(struct adf_accel_dev *accel_dev); | |
22e4dda0 | 103 | void adf_dev_shutdown(struct adf_accel_dev *accel_dev); |
d8cba25d TS |
104 | |
105 | int adf_ctl_dev_register(void); | |
106 | void adf_ctl_dev_unregister(void); | |
107 | int adf_processes_dev_register(void); | |
108 | void adf_processes_dev_unregister(void); | |
109 | ||
110 | int adf_devmgr_add_dev(struct adf_accel_dev *accel_dev); | |
111 | void adf_devmgr_rm_dev(struct adf_accel_dev *accel_dev); | |
112 | struct list_head *adf_devmgr_get_head(void); | |
113 | struct adf_accel_dev *adf_devmgr_get_dev_by_id(uint32_t id); | |
114 | struct adf_accel_dev *adf_devmgr_get_first(void); | |
115 | struct adf_accel_dev *adf_devmgr_pci_to_accel_dev(struct pci_dev *pci_dev); | |
116 | int adf_devmgr_verify_id(uint32_t id); | |
117 | void adf_devmgr_get_num_dev(uint32_t *num); | |
118 | int adf_devmgr_in_reset(struct adf_accel_dev *accel_dev); | |
119 | int adf_dev_started(struct adf_accel_dev *accel_dev); | |
120 | int adf_dev_restarting_notify(struct adf_accel_dev *accel_dev); | |
121 | int adf_dev_restarted_notify(struct adf_accel_dev *accel_dev); | |
122 | int adf_ae_init(struct adf_accel_dev *accel_dev); | |
123 | int adf_ae_shutdown(struct adf_accel_dev *accel_dev); | |
124 | int adf_ae_fw_load(struct adf_accel_dev *accel_dev); | |
b4e97050 | 125 | void adf_ae_fw_release(struct adf_accel_dev *accel_dev); |
d8cba25d TS |
126 | int adf_ae_start(struct adf_accel_dev *accel_dev); |
127 | int adf_ae_stop(struct adf_accel_dev *accel_dev); | |
128 | ||
129 | int adf_enable_aer(struct adf_accel_dev *accel_dev, struct pci_driver *adf); | |
130 | void adf_disable_aer(struct adf_accel_dev *accel_dev); | |
131 | int adf_init_aer(void); | |
132 | void adf_exit_aer(void); | |
133 | ||
134 | int adf_dev_get(struct adf_accel_dev *accel_dev); | |
135 | void adf_dev_put(struct adf_accel_dev *accel_dev); | |
136 | int adf_dev_in_use(struct adf_accel_dev *accel_dev); | |
137 | int adf_init_etr_data(struct adf_accel_dev *accel_dev); | |
138 | void adf_cleanup_etr_data(struct adf_accel_dev *accel_dev); | |
139 | int qat_crypto_register(void); | |
140 | int qat_crypto_unregister(void); | |
141 | struct qat_crypto_instance *qat_crypto_get_instance_node(int node); | |
142 | void qat_crypto_put_instance(struct qat_crypto_instance *inst); | |
143 | void qat_alg_callback(void *resp); | |
144 | int qat_algs_init(void); | |
145 | void qat_algs_exit(void); | |
146 | int qat_algs_register(void); | |
147 | int qat_algs_unregister(void); | |
148 | ||
149 | int qat_hal_init(struct adf_accel_dev *accel_dev); | |
150 | void qat_hal_deinit(struct icp_qat_fw_loader_handle *handle); | |
151 | void qat_hal_start(struct icp_qat_fw_loader_handle *handle, unsigned char ae, | |
152 | unsigned int ctx_mask); | |
153 | void qat_hal_stop(struct icp_qat_fw_loader_handle *handle, unsigned char ae, | |
154 | unsigned int ctx_mask); | |
155 | void qat_hal_reset(struct icp_qat_fw_loader_handle *handle); | |
156 | int qat_hal_clr_reset(struct icp_qat_fw_loader_handle *handle); | |
157 | void qat_hal_set_live_ctx(struct icp_qat_fw_loader_handle *handle, | |
158 | unsigned char ae, unsigned int ctx_mask); | |
159 | int qat_hal_set_ae_lm_mode(struct icp_qat_fw_loader_handle *handle, | |
160 | unsigned char ae, enum icp_qat_uof_regtype lm_type, | |
161 | unsigned char mode); | |
162 | int qat_hal_set_ae_ctx_mode(struct icp_qat_fw_loader_handle *handle, | |
163 | unsigned char ae, unsigned char mode); | |
164 | int qat_hal_set_ae_nn_mode(struct icp_qat_fw_loader_handle *handle, | |
165 | unsigned char ae, unsigned char mode); | |
166 | void qat_hal_set_pc(struct icp_qat_fw_loader_handle *handle, | |
167 | unsigned char ae, unsigned int ctx_mask, unsigned int upc); | |
168 | void qat_hal_wr_uwords(struct icp_qat_fw_loader_handle *handle, | |
169 | unsigned char ae, unsigned int uaddr, | |
170 | unsigned int words_num, uint64_t *uword); | |
171 | void qat_hal_wr_umem(struct icp_qat_fw_loader_handle *handle, unsigned char ae, | |
172 | unsigned int uword_addr, unsigned int words_num, | |
173 | unsigned int *data); | |
174 | int qat_hal_get_ins_num(void); | |
175 | int qat_hal_batch_wr_lm(struct icp_qat_fw_loader_handle *handle, | |
176 | unsigned char ae, | |
177 | struct icp_qat_uof_batch_init *lm_init_header); | |
178 | int qat_hal_init_gpr(struct icp_qat_fw_loader_handle *handle, | |
179 | unsigned char ae, unsigned char ctx_mask, | |
180 | enum icp_qat_uof_regtype reg_type, | |
181 | unsigned short reg_num, unsigned int regdata); | |
182 | int qat_hal_init_wr_xfer(struct icp_qat_fw_loader_handle *handle, | |
183 | unsigned char ae, unsigned char ctx_mask, | |
184 | enum icp_qat_uof_regtype reg_type, | |
185 | unsigned short reg_num, unsigned int regdata); | |
186 | int qat_hal_init_rd_xfer(struct icp_qat_fw_loader_handle *handle, | |
187 | unsigned char ae, unsigned char ctx_mask, | |
188 | enum icp_qat_uof_regtype reg_type, | |
189 | unsigned short reg_num, unsigned int regdata); | |
190 | int qat_hal_init_nn(struct icp_qat_fw_loader_handle *handle, | |
191 | unsigned char ae, unsigned char ctx_mask, | |
192 | unsigned short reg_num, unsigned int regdata); | |
193 | int qat_hal_wr_lm(struct icp_qat_fw_loader_handle *handle, | |
194 | unsigned char ae, unsigned short lm_addr, unsigned int value); | |
195 | int qat_uclo_wr_all_uimage(struct icp_qat_fw_loader_handle *handle); | |
8f312d64 | 196 | void qat_uclo_del_uof_obj(struct icp_qat_fw_loader_handle *handle); |
d8cba25d TS |
197 | int qat_uclo_map_uof_obj(struct icp_qat_fw_loader_handle *handle, |
198 | void *addr_ptr, int mem_size); | |
f3dd7e60 PY |
199 | void qat_uclo_wr_mimage(struct icp_qat_fw_loader_handle *handle, |
200 | void *addr_ptr, int mem_size); | |
d8cba25d | 201 | #endif |