Merge branch 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
[deliverable/linux.git] / drivers / crypto / qat / qat_c3xxxvf / adf_c3xxxvf_hw_data.c
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) 2015 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) 2015 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 #include <adf_accel_devices.h>
48 #include <adf_pf2vf_msg.h>
49 #include <adf_common_drv.h>
50 #include "adf_c3xxxvf_hw_data.h"
51
52 static struct adf_hw_device_class c3xxxiov_class = {
53 .name = ADF_C3XXXVF_DEVICE_NAME,
54 .type = DEV_C3XXXVF,
55 .instances = 0
56 };
57
58 static u32 get_accel_mask(u32 fuse)
59 {
60 return ADF_C3XXXIOV_ACCELERATORS_MASK;
61 }
62
63 static u32 get_ae_mask(u32 fuse)
64 {
65 return ADF_C3XXXIOV_ACCELENGINES_MASK;
66 }
67
68 static u32 get_num_accels(struct adf_hw_device_data *self)
69 {
70 return ADF_C3XXXIOV_MAX_ACCELERATORS;
71 }
72
73 static u32 get_num_aes(struct adf_hw_device_data *self)
74 {
75 return ADF_C3XXXIOV_MAX_ACCELENGINES;
76 }
77
78 static u32 get_misc_bar_id(struct adf_hw_device_data *self)
79 {
80 return ADF_C3XXXIOV_PMISC_BAR;
81 }
82
83 static u32 get_etr_bar_id(struct adf_hw_device_data *self)
84 {
85 return ADF_C3XXXIOV_ETR_BAR;
86 }
87
88 static enum dev_sku_info get_sku(struct adf_hw_device_data *self)
89 {
90 return DEV_SKU_VF;
91 }
92
93 static u32 get_pf2vf_offset(u32 i)
94 {
95 return ADF_C3XXXIOV_PF2VF_OFFSET;
96 }
97
98 static u32 get_vintmsk_offset(u32 i)
99 {
100 return ADF_C3XXXIOV_VINTMSK_OFFSET;
101 }
102
103 static int adf_vf_int_noop(struct adf_accel_dev *accel_dev)
104 {
105 return 0;
106 }
107
108 static void adf_vf_void_noop(struct adf_accel_dev *accel_dev)
109 {
110 }
111
112 static int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
113 {
114 u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
115 (ADF_VF2PF_MSGTYPE_INIT << ADF_VF2PF_MSGTYPE_SHIFT));
116
117 if (adf_iov_putmsg(accel_dev, msg, 0)) {
118 dev_err(&GET_DEV(accel_dev),
119 "Failed to send Init event to PF\n");
120 return -EFAULT;
121 }
122 return 0;
123 }
124
125 static void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
126 {
127 u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
128 (ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_VF2PF_MSGTYPE_SHIFT));
129
130 if (adf_iov_putmsg(accel_dev, msg, 0))
131 dev_err(&GET_DEV(accel_dev),
132 "Failed to send Shutdown event to PF\n");
133 }
134
135 void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data)
136 {
137 hw_data->dev_class = &c3xxxiov_class;
138 hw_data->num_banks = ADF_C3XXXIOV_ETR_MAX_BANKS;
139 hw_data->num_accel = ADF_C3XXXIOV_MAX_ACCELERATORS;
140 hw_data->num_logical_accel = 1;
141 hw_data->num_engines = ADF_C3XXXIOV_MAX_ACCELENGINES;
142 hw_data->tx_rx_gap = ADF_C3XXXIOV_RX_RINGS_OFFSET;
143 hw_data->tx_rings_mask = ADF_C3XXXIOV_TX_RINGS_MASK;
144 hw_data->alloc_irq = adf_vf_isr_resource_alloc;
145 hw_data->free_irq = adf_vf_isr_resource_free;
146 hw_data->enable_error_correction = adf_vf_void_noop;
147 hw_data->init_admin_comms = adf_vf_int_noop;
148 hw_data->exit_admin_comms = adf_vf_void_noop;
149 hw_data->send_admin_init = adf_vf2pf_init;
150 hw_data->init_arb = adf_vf_int_noop;
151 hw_data->exit_arb = adf_vf_void_noop;
152 hw_data->disable_iov = adf_vf2pf_shutdown;
153 hw_data->get_accel_mask = get_accel_mask;
154 hw_data->get_ae_mask = get_ae_mask;
155 hw_data->get_num_accels = get_num_accels;
156 hw_data->get_num_aes = get_num_aes;
157 hw_data->get_etr_bar_id = get_etr_bar_id;
158 hw_data->get_misc_bar_id = get_misc_bar_id;
159 hw_data->get_pf2vf_offset = get_pf2vf_offset;
160 hw_data->get_vintmsk_offset = get_vintmsk_offset;
161 hw_data->get_sku = get_sku;
162 hw_data->enable_ints = adf_vf_void_noop;
163 hw_data->enable_vf2pf_comms = adf_enable_vf2pf_comms;
164 hw_data->min_iov_compat_ver = ADF_PFVF_COMPATIBILITY_VERSION;
165 hw_data->dev_class->instances++;
166 adf_devmgr_update_class_index(hw_data);
167 }
168
169 void adf_clean_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data)
170 {
171 hw_data->dev_class->instances--;
172 adf_devmgr_update_class_index(hw_data);
173 }
This page took 0.037171 seconds and 5 git commands to generate.