• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_dh895xccvf_hw_data.h"
51 #include "adf_drv.h"
52 
53 static struct adf_hw_device_class dh895xcciov_class = {
54 	.name = ADF_DH895XCCVF_DEVICE_NAME,
55 	.type = DEV_DH895XCCVF,
56 	.instances = 0
57 };
58 
get_accel_mask(u32 fuse)59 static u32 get_accel_mask(u32 fuse)
60 {
61 	return ADF_DH895XCCIOV_ACCELERATORS_MASK;
62 }
63 
get_ae_mask(u32 fuse)64 static u32 get_ae_mask(u32 fuse)
65 {
66 	return ADF_DH895XCCIOV_ACCELENGINES_MASK;
67 }
68 
get_num_accels(struct adf_hw_device_data * self)69 static u32 get_num_accels(struct adf_hw_device_data *self)
70 {
71 	return ADF_DH895XCCIOV_MAX_ACCELERATORS;
72 }
73 
get_num_aes(struct adf_hw_device_data * self)74 static u32 get_num_aes(struct adf_hw_device_data *self)
75 {
76 	return ADF_DH895XCCIOV_MAX_ACCELENGINES;
77 }
78 
get_misc_bar_id(struct adf_hw_device_data * self)79 static u32 get_misc_bar_id(struct adf_hw_device_data *self)
80 {
81 	return ADF_DH895XCCIOV_PMISC_BAR;
82 }
83 
get_etr_bar_id(struct adf_hw_device_data * self)84 static u32 get_etr_bar_id(struct adf_hw_device_data *self)
85 {
86 	return ADF_DH895XCCIOV_ETR_BAR;
87 }
88 
get_sku(struct adf_hw_device_data * self)89 static enum dev_sku_info get_sku(struct adf_hw_device_data *self)
90 {
91 	return DEV_SKU_VF;
92 }
93 
get_pf2vf_offset(u32 i)94 static u32 get_pf2vf_offset(u32 i)
95 {
96 	return ADF_DH895XCCIOV_PF2VF_OFFSET;
97 }
98 
get_vintmsk_offset(u32 i)99 static u32 get_vintmsk_offset(u32 i)
100 {
101 	return ADF_DH895XCCIOV_VINTMSK_OFFSET;
102 }
103 
adf_vf_int_noop(struct adf_accel_dev * accel_dev)104 static int adf_vf_int_noop(struct adf_accel_dev *accel_dev)
105 {
106 	return 0;
107 }
108 
adf_vf_void_noop(struct adf_accel_dev * accel_dev)109 static void adf_vf_void_noop(struct adf_accel_dev *accel_dev)
110 {
111 }
112 
adf_vf2pf_init(struct adf_accel_dev * accel_dev)113 static int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
114 {
115 	u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
116 		(ADF_VF2PF_MSGTYPE_INIT << ADF_VF2PF_MSGTYPE_SHIFT));
117 
118 	if (adf_iov_putmsg(accel_dev, msg, 0)) {
119 		dev_err(&GET_DEV(accel_dev),
120 			"Failed to send Init event to PF\n");
121 		return -EFAULT;
122 	}
123 	return 0;
124 }
125 
adf_vf2pf_shutdown(struct adf_accel_dev * accel_dev)126 static void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
127 {
128 	u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
129 	    (ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_VF2PF_MSGTYPE_SHIFT));
130 
131 	if (adf_iov_putmsg(accel_dev, msg, 0))
132 		dev_err(&GET_DEV(accel_dev),
133 			"Failed to send Shutdown event to PF\n");
134 }
135 
adf_init_hw_data_dh895xcciov(struct adf_hw_device_data * hw_data)136 void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data)
137 {
138 	hw_data->dev_class = &dh895xcciov_class;
139 	hw_data->instance_id = dh895xcciov_class.instances++;
140 	hw_data->num_banks = ADF_DH895XCCIOV_ETR_MAX_BANKS;
141 	hw_data->num_accel = ADF_DH895XCCIOV_MAX_ACCELERATORS;
142 	hw_data->num_logical_accel = 1;
143 	hw_data->num_engines = ADF_DH895XCCIOV_MAX_ACCELENGINES;
144 	hw_data->tx_rx_gap = ADF_DH895XCCIOV_RX_RINGS_OFFSET;
145 	hw_data->tx_rings_mask = ADF_DH895XCCIOV_TX_RINGS_MASK;
146 	hw_data->alloc_irq = adf_vf_isr_resource_alloc;
147 	hw_data->free_irq = adf_vf_isr_resource_free;
148 	hw_data->enable_error_correction = adf_vf_void_noop;
149 	hw_data->init_admin_comms = adf_vf_int_noop;
150 	hw_data->exit_admin_comms = adf_vf_void_noop;
151 	hw_data->send_admin_init = adf_vf2pf_init;
152 	hw_data->init_arb = adf_vf_int_noop;
153 	hw_data->exit_arb = adf_vf_void_noop;
154 	hw_data->disable_iov = adf_vf2pf_shutdown;
155 	hw_data->get_accel_mask = get_accel_mask;
156 	hw_data->get_ae_mask = get_ae_mask;
157 	hw_data->get_num_accels = get_num_accels;
158 	hw_data->get_num_aes = get_num_aes;
159 	hw_data->get_etr_bar_id = get_etr_bar_id;
160 	hw_data->get_misc_bar_id = get_misc_bar_id;
161 	hw_data->get_pf2vf_offset = get_pf2vf_offset;
162 	hw_data->get_vintmsk_offset = get_vintmsk_offset;
163 	hw_data->get_sku = get_sku;
164 	hw_data->enable_ints = adf_vf_void_noop;
165 	hw_data->enable_vf2pf_comms = adf_enable_vf2pf_comms;
166 	hw_data->min_iov_compat_ver = ADF_PFVF_COMPATIBILITY_VERSION;
167 }
168 
adf_clean_hw_data_dh895xcciov(struct adf_hw_device_data * hw_data)169 void adf_clean_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data)
170 {
171 	hw_data->dev_class->instances--;
172 }
173