crypto: qat - Fixed new checkpatch warnings
[linux-2.6-block.git] / drivers / crypto / qat / qat_common / adf_common_drv.h
CommitLineData
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
56#define ADF_STATUS_RESTARTING 0
57#define ADF_STATUS_STARTING 1
58#define ADF_STATUS_CONFIGURED 2
59#define ADF_STATUS_STARTED 3
60#define ADF_STATUS_AE_INITIALISED 4
61#define ADF_STATUS_AE_UCODE_LOADED 5
62#define ADF_STATUS_AE_STARTED 6
63#define ADF_STATUS_ORPHAN_TH_RUNNING 7
64#define ADF_STATUS_IRQ_ALLOCATED 8
65
66enum adf_dev_reset_mode {
67 ADF_DEV_RESET_ASYNC = 0,
68 ADF_DEV_RESET_SYNC
69};
70
71enum adf_event {
72 ADF_EVENT_INIT = 0,
73 ADF_EVENT_START,
74 ADF_EVENT_STOP,
75 ADF_EVENT_SHUTDOWN,
76 ADF_EVENT_RESTARTING,
77 ADF_EVENT_RESTARTED,
78};
79
80struct service_hndl {
81 int (*event_hld)(struct adf_accel_dev *accel_dev,
82 enum adf_event event);
83 unsigned long init_status;
84 unsigned long start_status;
85 char *name;
86 struct list_head list;
87 int admin;
88};
89
90int adf_service_register(struct service_hndl *service);
91int adf_service_unregister(struct service_hndl *service);
92
93int adf_dev_init(struct adf_accel_dev *accel_dev);
94int adf_dev_start(struct adf_accel_dev *accel_dev);
95int adf_dev_stop(struct adf_accel_dev *accel_dev);
96int adf_dev_shutdown(struct adf_accel_dev *accel_dev);
97
98int adf_ctl_dev_register(void);
99void adf_ctl_dev_unregister(void);
100int adf_processes_dev_register(void);
101void adf_processes_dev_unregister(void);
102
103int adf_devmgr_add_dev(struct adf_accel_dev *accel_dev);
104void adf_devmgr_rm_dev(struct adf_accel_dev *accel_dev);
105struct list_head *adf_devmgr_get_head(void);
106struct adf_accel_dev *adf_devmgr_get_dev_by_id(uint32_t id);
107struct adf_accel_dev *adf_devmgr_get_first(void);
108struct adf_accel_dev *adf_devmgr_pci_to_accel_dev(struct pci_dev *pci_dev);
109int adf_devmgr_verify_id(uint32_t id);
110void adf_devmgr_get_num_dev(uint32_t *num);
111int adf_devmgr_in_reset(struct adf_accel_dev *accel_dev);
112int adf_dev_started(struct adf_accel_dev *accel_dev);
113int adf_dev_restarting_notify(struct adf_accel_dev *accel_dev);
114int adf_dev_restarted_notify(struct adf_accel_dev *accel_dev);
115int adf_ae_init(struct adf_accel_dev *accel_dev);
116int adf_ae_shutdown(struct adf_accel_dev *accel_dev);
117int adf_ae_fw_load(struct adf_accel_dev *accel_dev);
118int adf_ae_fw_release(struct adf_accel_dev *accel_dev);
119int adf_ae_start(struct adf_accel_dev *accel_dev);
120int adf_ae_stop(struct adf_accel_dev *accel_dev);
121
122int adf_enable_aer(struct adf_accel_dev *accel_dev, struct pci_driver *adf);
123void adf_disable_aer(struct adf_accel_dev *accel_dev);
124int adf_init_aer(void);
125void adf_exit_aer(void);
126
127int adf_dev_get(struct adf_accel_dev *accel_dev);
128void adf_dev_put(struct adf_accel_dev *accel_dev);
129int adf_dev_in_use(struct adf_accel_dev *accel_dev);
130int adf_init_etr_data(struct adf_accel_dev *accel_dev);
131void adf_cleanup_etr_data(struct adf_accel_dev *accel_dev);
132int qat_crypto_register(void);
133int qat_crypto_unregister(void);
134struct qat_crypto_instance *qat_crypto_get_instance_node(int node);
135void qat_crypto_put_instance(struct qat_crypto_instance *inst);
136void qat_alg_callback(void *resp);
137int qat_algs_init(void);
138void qat_algs_exit(void);
139int qat_algs_register(void);
140int qat_algs_unregister(void);
141
142int qat_hal_init(struct adf_accel_dev *accel_dev);
143void qat_hal_deinit(struct icp_qat_fw_loader_handle *handle);
144void qat_hal_start(struct icp_qat_fw_loader_handle *handle, unsigned char ae,
145 unsigned int ctx_mask);
146void qat_hal_stop(struct icp_qat_fw_loader_handle *handle, unsigned char ae,
147 unsigned int ctx_mask);
148void qat_hal_reset(struct icp_qat_fw_loader_handle *handle);
149int qat_hal_clr_reset(struct icp_qat_fw_loader_handle *handle);
150void qat_hal_set_live_ctx(struct icp_qat_fw_loader_handle *handle,
151 unsigned char ae, unsigned int ctx_mask);
152int qat_hal_set_ae_lm_mode(struct icp_qat_fw_loader_handle *handle,
153 unsigned char ae, enum icp_qat_uof_regtype lm_type,
154 unsigned char mode);
155int qat_hal_set_ae_ctx_mode(struct icp_qat_fw_loader_handle *handle,
156 unsigned char ae, unsigned char mode);
157int qat_hal_set_ae_nn_mode(struct icp_qat_fw_loader_handle *handle,
158 unsigned char ae, unsigned char mode);
159void qat_hal_set_pc(struct icp_qat_fw_loader_handle *handle,
160 unsigned char ae, unsigned int ctx_mask, unsigned int upc);
161void qat_hal_wr_uwords(struct icp_qat_fw_loader_handle *handle,
162 unsigned char ae, unsigned int uaddr,
163 unsigned int words_num, uint64_t *uword);
164void qat_hal_wr_umem(struct icp_qat_fw_loader_handle *handle, unsigned char ae,
165 unsigned int uword_addr, unsigned int words_num,
166 unsigned int *data);
167int qat_hal_get_ins_num(void);
168int qat_hal_batch_wr_lm(struct icp_qat_fw_loader_handle *handle,
169 unsigned char ae,
170 struct icp_qat_uof_batch_init *lm_init_header);
171int qat_hal_init_gpr(struct icp_qat_fw_loader_handle *handle,
172 unsigned char ae, unsigned char ctx_mask,
173 enum icp_qat_uof_regtype reg_type,
174 unsigned short reg_num, unsigned int regdata);
175int qat_hal_init_wr_xfer(struct icp_qat_fw_loader_handle *handle,
176 unsigned char ae, unsigned char ctx_mask,
177 enum icp_qat_uof_regtype reg_type,
178 unsigned short reg_num, unsigned int regdata);
179int qat_hal_init_rd_xfer(struct icp_qat_fw_loader_handle *handle,
180 unsigned char ae, unsigned char ctx_mask,
181 enum icp_qat_uof_regtype reg_type,
182 unsigned short reg_num, unsigned int regdata);
183int qat_hal_init_nn(struct icp_qat_fw_loader_handle *handle,
184 unsigned char ae, unsigned char ctx_mask,
185 unsigned short reg_num, unsigned int regdata);
186int qat_hal_wr_lm(struct icp_qat_fw_loader_handle *handle,
187 unsigned char ae, unsigned short lm_addr, unsigned int value);
188int qat_uclo_wr_all_uimage(struct icp_qat_fw_loader_handle *handle);
189int qat_uclo_del_uof_obj(struct icp_qat_fw_loader_handle *handle);
190int qat_uclo_map_uof_obj(struct icp_qat_fw_loader_handle *handle,
191 void *addr_ptr, int mem_size);
192#endif