blob: 980e07475012043ece2c2447307a5818cb53b2c0 [file] [log] [blame]
Tadeusz Strukd8cba252014-06-05 13:42:39 -07001/*
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
Allan, Bruce W551d7ed2015-05-07 17:00:42 -070056#define ADF_MAJOR_VERSION 0
Tadeusz Struk1a72d3a2015-12-04 16:56:28 -080057#define ADF_MINOR_VERSION 6
Tadeusz Struked8ccae2015-08-07 11:34:25 -070058#define ADF_BUILD_VERSION 0
Allan, Bruce W551d7ed2015-05-07 17:00:42 -070059#define ADF_DRV_VERSION __stringify(ADF_MAJOR_VERSION) "." \
60 __stringify(ADF_MINOR_VERSION) "." \
61 __stringify(ADF_BUILD_VERSION)
62
Tadeusz Strukd8cba252014-06-05 13:42:39 -070063#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
Tadeusz Struk25c6ffb2016-04-15 10:37:59 -070070#define ADF_STATUS_PF_RUNNING 7
Tadeusz Strukd8cba252014-06-05 13:42:39 -070071#define ADF_STATUS_IRQ_ALLOCATED 8
72
73enum adf_dev_reset_mode {
74 ADF_DEV_RESET_ASYNC = 0,
75 ADF_DEV_RESET_SYNC
76};
77
78enum 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
87struct 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;
Tadeusz Strukd8cba252014-06-05 13:42:39 -070094};
95
Tadeusz Struka9905322015-07-15 15:28:38 -070096static inline int get_current_node(void)
97{
Tadeusz Struked8ccae2015-08-07 11:34:25 -070098 return topology_physical_package_id(smp_processor_id());
Tadeusz Struka9905322015-07-15 15:28:38 -070099}
100
Tadeusz Strukd8cba252014-06-05 13:42:39 -0700101int adf_service_register(struct service_hndl *service);
102int adf_service_unregister(struct service_hndl *service);
103
104int adf_dev_init(struct adf_accel_dev *accel_dev);
105int adf_dev_start(struct adf_accel_dev *accel_dev);
Tadeusz Strukf1420ce2016-03-29 10:21:07 -0700106void adf_dev_stop(struct adf_accel_dev *accel_dev);
Allan, Bruce W22e4dda2015-01-09 11:54:58 -0800107void adf_dev_shutdown(struct adf_accel_dev *accel_dev);
Tadeusz Strukd8cba252014-06-05 13:42:39 -0700108
Tadeusz Struked8ccae2015-08-07 11:34:25 -0700109int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr);
110void adf_pf2vf_notify_restarting(struct adf_accel_dev *accel_dev);
111int adf_enable_vf2pf_comms(struct adf_accel_dev *accel_dev);
Tadeusz Strukdf9e21e2015-08-24 11:56:02 -0700112void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info);
Tadeusz Struked8ccae2015-08-07 11:34:25 -0700113void adf_devmgr_update_class_index(struct adf_hw_device_data *hw_data);
114void adf_clean_vf_map(bool);
115
Tadeusz Strukd8cba252014-06-05 13:42:39 -0700116int adf_ctl_dev_register(void);
117void adf_ctl_dev_unregister(void);
118int adf_processes_dev_register(void);
119void adf_processes_dev_unregister(void);
120
Tadeusz Struked8ccae2015-08-07 11:34:25 -0700121int adf_devmgr_add_dev(struct adf_accel_dev *accel_dev,
122 struct adf_accel_dev *pf);
123void adf_devmgr_rm_dev(struct adf_accel_dev *accel_dev,
124 struct adf_accel_dev *pf);
Tadeusz Strukd8cba252014-06-05 13:42:39 -0700125struct list_head *adf_devmgr_get_head(void);
126struct adf_accel_dev *adf_devmgr_get_dev_by_id(uint32_t id);
127struct adf_accel_dev *adf_devmgr_get_first(void);
128struct adf_accel_dev *adf_devmgr_pci_to_accel_dev(struct pci_dev *pci_dev);
129int adf_devmgr_verify_id(uint32_t id);
130void adf_devmgr_get_num_dev(uint32_t *num);
131int adf_devmgr_in_reset(struct adf_accel_dev *accel_dev);
132int adf_dev_started(struct adf_accel_dev *accel_dev);
133int adf_dev_restarting_notify(struct adf_accel_dev *accel_dev);
134int adf_dev_restarted_notify(struct adf_accel_dev *accel_dev);
135int adf_ae_init(struct adf_accel_dev *accel_dev);
136int adf_ae_shutdown(struct adf_accel_dev *accel_dev);
137int adf_ae_fw_load(struct adf_accel_dev *accel_dev);
Tadeusz Strukb4e97052015-04-03 08:41:17 -0700138void adf_ae_fw_release(struct adf_accel_dev *accel_dev);
Tadeusz Strukd8cba252014-06-05 13:42:39 -0700139int adf_ae_start(struct adf_accel_dev *accel_dev);
140int adf_ae_stop(struct adf_accel_dev *accel_dev);
141
142int adf_enable_aer(struct adf_accel_dev *accel_dev, struct pci_driver *adf);
143void adf_disable_aer(struct adf_accel_dev *accel_dev);
Conor McLoughline24860f22016-07-04 16:26:00 +0100144void adf_reset_sbr(struct adf_accel_dev *accel_dev);
145void adf_reset_flr(struct adf_accel_dev *accel_dev);
Tadeusz Struk1a72d3a2015-12-04 16:56:28 -0800146void adf_dev_restore(struct adf_accel_dev *accel_dev);
Tadeusz Strukd8cba252014-06-05 13:42:39 -0700147int adf_init_aer(void);
148void adf_exit_aer(void);
Tadeusz Struka5733132015-08-07 11:34:20 -0700149int adf_init_admin_comms(struct adf_accel_dev *accel_dev);
150void adf_exit_admin_comms(struct adf_accel_dev *accel_dev);
151int adf_send_admin_init(struct adf_accel_dev *accel_dev);
152int adf_init_arb(struct adf_accel_dev *accel_dev);
153void adf_exit_arb(struct adf_accel_dev *accel_dev);
154void adf_update_ring_arb(struct adf_etr_ring_data *ring);
Tadeusz Strukd8cba252014-06-05 13:42:39 -0700155
156int adf_dev_get(struct adf_accel_dev *accel_dev);
157void adf_dev_put(struct adf_accel_dev *accel_dev);
158int adf_dev_in_use(struct adf_accel_dev *accel_dev);
159int adf_init_etr_data(struct adf_accel_dev *accel_dev);
160void adf_cleanup_etr_data(struct adf_accel_dev *accel_dev);
161int qat_crypto_register(void);
162int qat_crypto_unregister(void);
Tadeusz Struk1a72d3a2015-12-04 16:56:28 -0800163int qat_crypto_dev_config(struct adf_accel_dev *accel_dev);
Tadeusz Strukd8cba252014-06-05 13:42:39 -0700164struct qat_crypto_instance *qat_crypto_get_instance_node(int node);
165void qat_crypto_put_instance(struct qat_crypto_instance *inst);
166void qat_alg_callback(void *resp);
Tadeusz Struka9905322015-07-15 15:28:38 -0700167void qat_alg_asym_callback(void *resp);
Tadeusz Strukd8cba252014-06-05 13:42:39 -0700168int qat_algs_register(void);
Tadeusz Strukbe2cfac2015-09-22 11:57:47 -0700169void qat_algs_unregister(void);
Tadeusz Struka9905322015-07-15 15:28:38 -0700170int qat_asym_algs_register(void);
171void qat_asym_algs_unregister(void);
Tadeusz Strukd8cba252014-06-05 13:42:39 -0700172
Tadeusz Struk1a72d3a2015-12-04 16:56:28 -0800173int adf_isr_resource_alloc(struct adf_accel_dev *accel_dev);
174void adf_isr_resource_free(struct adf_accel_dev *accel_dev);
175int adf_vf_isr_resource_alloc(struct adf_accel_dev *accel_dev);
176void adf_vf_isr_resource_free(struct adf_accel_dev *accel_dev);
177
Tadeusz Strukd8cba252014-06-05 13:42:39 -0700178int qat_hal_init(struct adf_accel_dev *accel_dev);
179void qat_hal_deinit(struct icp_qat_fw_loader_handle *handle);
180void qat_hal_start(struct icp_qat_fw_loader_handle *handle, unsigned char ae,
181 unsigned int ctx_mask);
182void qat_hal_stop(struct icp_qat_fw_loader_handle *handle, unsigned char ae,
183 unsigned int ctx_mask);
184void qat_hal_reset(struct icp_qat_fw_loader_handle *handle);
185int qat_hal_clr_reset(struct icp_qat_fw_loader_handle *handle);
186void qat_hal_set_live_ctx(struct icp_qat_fw_loader_handle *handle,
187 unsigned char ae, unsigned int ctx_mask);
Pingchao Yangb0272272015-12-04 16:56:23 -0800188int qat_hal_check_ae_active(struct icp_qat_fw_loader_handle *handle,
189 unsigned int ae);
Tadeusz Strukd8cba252014-06-05 13:42:39 -0700190int qat_hal_set_ae_lm_mode(struct icp_qat_fw_loader_handle *handle,
191 unsigned char ae, enum icp_qat_uof_regtype lm_type,
192 unsigned char mode);
193int qat_hal_set_ae_ctx_mode(struct icp_qat_fw_loader_handle *handle,
194 unsigned char ae, unsigned char mode);
195int qat_hal_set_ae_nn_mode(struct icp_qat_fw_loader_handle *handle,
196 unsigned char ae, unsigned char mode);
197void qat_hal_set_pc(struct icp_qat_fw_loader_handle *handle,
198 unsigned char ae, unsigned int ctx_mask, unsigned int upc);
199void qat_hal_wr_uwords(struct icp_qat_fw_loader_handle *handle,
200 unsigned char ae, unsigned int uaddr,
201 unsigned int words_num, uint64_t *uword);
202void qat_hal_wr_umem(struct icp_qat_fw_loader_handle *handle, unsigned char ae,
203 unsigned int uword_addr, unsigned int words_num,
204 unsigned int *data);
205int qat_hal_get_ins_num(void);
206int qat_hal_batch_wr_lm(struct icp_qat_fw_loader_handle *handle,
207 unsigned char ae,
208 struct icp_qat_uof_batch_init *lm_init_header);
209int qat_hal_init_gpr(struct icp_qat_fw_loader_handle *handle,
210 unsigned char ae, unsigned char ctx_mask,
211 enum icp_qat_uof_regtype reg_type,
212 unsigned short reg_num, unsigned int regdata);
213int qat_hal_init_wr_xfer(struct icp_qat_fw_loader_handle *handle,
214 unsigned char ae, unsigned char ctx_mask,
215 enum icp_qat_uof_regtype reg_type,
216 unsigned short reg_num, unsigned int regdata);
217int qat_hal_init_rd_xfer(struct icp_qat_fw_loader_handle *handle,
218 unsigned char ae, unsigned char ctx_mask,
219 enum icp_qat_uof_regtype reg_type,
220 unsigned short reg_num, unsigned int regdata);
221int qat_hal_init_nn(struct icp_qat_fw_loader_handle *handle,
222 unsigned char ae, unsigned char ctx_mask,
223 unsigned short reg_num, unsigned int regdata);
224int qat_hal_wr_lm(struct icp_qat_fw_loader_handle *handle,
225 unsigned char ae, unsigned short lm_addr, unsigned int value);
226int qat_uclo_wr_all_uimage(struct icp_qat_fw_loader_handle *handle);
Tadeusz Struk8f312d62014-06-24 15:19:40 -0700227void qat_uclo_del_uof_obj(struct icp_qat_fw_loader_handle *handle);
Pingchao Yangb0272272015-12-04 16:56:23 -0800228int qat_uclo_wr_mimage(struct icp_qat_fw_loader_handle *handle, void *addr_ptr,
229 int mem_size);
230int qat_uclo_map_obj(struct icp_qat_fw_loader_handle *handle,
231 void *addr_ptr, int mem_size);
Tadeusz Struked8ccae2015-08-07 11:34:25 -0700232#if defined(CONFIG_PCI_IOV)
233int adf_sriov_configure(struct pci_dev *pdev, int numvfs);
234void adf_disable_sriov(struct adf_accel_dev *accel_dev);
235void adf_disable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
236 uint32_t vf_mask);
237void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
238 uint32_t vf_mask);
Tadeusz Struk1fa844e2015-12-23 06:49:58 -0800239void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
240void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
Tadeusz Struk02dc8d62016-04-15 10:37:58 -0700241
242int adf_vf2pf_init(struct adf_accel_dev *accel_dev);
243void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev);
Tadeusz Struk6dc5df72016-04-29 10:43:40 -0700244int adf_init_pf_wq(void);
245void adf_exit_pf_wq(void);
Tadeusz Strukd0c15bd2016-04-29 11:00:00 -0700246int adf_init_vf_wq(void);
247void adf_exit_vf_wq(void);
Tadeusz Struked8ccae2015-08-07 11:34:25 -0700248#else
249static inline int adf_sriov_configure(struct pci_dev *pdev, int numvfs)
250{
251 return 0;
252}
253
254static inline void adf_disable_sriov(struct adf_accel_dev *accel_dev)
255{
256}
Tadeusz Struk1fa844e2015-12-23 06:49:58 -0800257
258static inline void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev)
259{
260}
261
262static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev)
263{
264}
Tadeusz Struk02dc8d62016-04-15 10:37:58 -0700265
266static inline int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
267{
268 return 0;
269}
270
271static inline void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
272{
273}
Herbert Xu6dd4c832016-05-03 16:01:52 +0800274
Tadeusz Struk6dc5df72016-04-29 10:43:40 -0700275static inline int adf_init_pf_wq(void)
276{
277 return 0;
278}
279
280static inline void adf_exit_pf_wq(void)
281{
282}
Tadeusz Strukd0c15bd2016-04-29 11:00:00 -0700283
284static inline int adf_init_vf_wq(void)
285{
286 return 0;
287}
288
289static inline void adf_exit_vf_wq(void)
290{
291}
292
Tadeusz Struked8ccae2015-08-07 11:34:25 -0700293#endif
Tadeusz Strukd8cba252014-06-05 13:42:39 -0700294#endif