diff options
author | Tadeusz Struk <tadeusz.struk@intel.com> | 2015-12-04 19:56:51 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-12-09 07:03:56 -0500 |
commit | 3771df3cff7536da19cba2b4755ad628dc4bf371 (patch) | |
tree | 851f9a27f38c9d46184071b7c19b90cbc21cc840 | |
parent | 8b206f2d666f41f0aa83dec83504801ee945d3dc (diff) |
crypto: qat - add support for c62xvf accel type
Add support for c62x accelerator Virtual Function
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/qat/Kconfig | 11 | ||||
-rw-r--r-- | drivers/crypto/qat/Makefile | 1 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_c62xvf/Makefile | 3 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c | 173 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.h | 64 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_c62xvf/adf_drv.c | 305 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_common/adf_cfg_common.h | 1 |
7 files changed, 558 insertions, 0 deletions
diff --git a/drivers/crypto/qat/Kconfig b/drivers/crypto/qat/Kconfig index c2d1886603bc..d275d481ce73 100644 --- a/drivers/crypto/qat/Kconfig +++ b/drivers/crypto/qat/Kconfig | |||
@@ -67,3 +67,14 @@ config CRYPTO_DEV_QAT_C3XXXVF | |||
67 | 67 | ||
68 | To compile this as a module, choose M here: the module | 68 | To compile this as a module, choose M here: the module |
69 | will be called qat_c3xxxvf. | 69 | will be called qat_c3xxxvf. |
70 | |||
71 | config CRYPTO_DEV_QAT_C62XVF | ||
72 | tristate "Support for Intel(R) C62X Virtual Function" | ||
73 | depends on X86 && PCI | ||
74 | select CRYPTO_DEV_QAT | ||
75 | help | ||
76 | Support for Intel(R) C62x with Intel(R) QuickAssist Technology | ||
77 | Virtual Function for accelerating crypto and compression workloads. | ||
78 | |||
79 | To compile this as a module, choose M here: the module | ||
80 | will be called qat_c62xvf. | ||
diff --git a/drivers/crypto/qat/Makefile b/drivers/crypto/qat/Makefile index ac86281ae8af..8265106f1c8e 100644 --- a/drivers/crypto/qat/Makefile +++ b/drivers/crypto/qat/Makefile | |||
@@ -4,3 +4,4 @@ obj-$(CONFIG_CRYPTO_DEV_QAT_C3XXX) += qat_c3xxx/ | |||
4 | obj-$(CONFIG_CRYPTO_DEV_QAT_C62X) += qat_c62x/ | 4 | obj-$(CONFIG_CRYPTO_DEV_QAT_C62X) += qat_c62x/ |
5 | obj-$(CONFIG_CRYPTO_DEV_QAT_DH895xCCVF) += qat_dh895xccvf/ | 5 | obj-$(CONFIG_CRYPTO_DEV_QAT_DH895xCCVF) += qat_dh895xccvf/ |
6 | obj-$(CONFIG_CRYPTO_DEV_QAT_C3XXXVF) += qat_c3xxxvf/ | 6 | obj-$(CONFIG_CRYPTO_DEV_QAT_C3XXXVF) += qat_c3xxxvf/ |
7 | obj-$(CONFIG_CRYPTO_DEV_QAT_C62XVF) += qat_c62xvf/ | ||
diff --git a/drivers/crypto/qat/qat_c62xvf/Makefile b/drivers/crypto/qat/qat_c62xvf/Makefile new file mode 100644 index 000000000000..ecd708c213b2 --- /dev/null +++ b/drivers/crypto/qat/qat_c62xvf/Makefile | |||
@@ -0,0 +1,3 @@ | |||
1 | ccflags-y := -I$(src)/../qat_common | ||
2 | obj-$(CONFIG_CRYPTO_DEV_QAT_C62XVF) += qat_c62xvf.o | ||
3 | qat_c62xvf-objs := adf_drv.o adf_c62xvf_hw_data.o | ||
diff --git a/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c b/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c new file mode 100644 index 000000000000..baf4b509c892 --- /dev/null +++ b/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c | |||
@@ -0,0 +1,173 @@ | |||
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_c62xvf_hw_data.h" | ||
51 | |||
52 | static struct adf_hw_device_class c62xiov_class = { | ||
53 | .name = ADF_C62XVF_DEVICE_NAME, | ||
54 | .type = DEV_C62XVF, | ||
55 | .instances = 0 | ||
56 | }; | ||
57 | |||
58 | static u32 get_accel_mask(u32 fuse) | ||
59 | { | ||
60 | return ADF_C62XIOV_ACCELERATORS_MASK; | ||
61 | } | ||
62 | |||
63 | static u32 get_ae_mask(u32 fuse) | ||
64 | { | ||
65 | return ADF_C62XIOV_ACCELENGINES_MASK; | ||
66 | } | ||
67 | |||
68 | static u32 get_num_accels(struct adf_hw_device_data *self) | ||
69 | { | ||
70 | return ADF_C62XIOV_MAX_ACCELERATORS; | ||
71 | } | ||
72 | |||
73 | static u32 get_num_aes(struct adf_hw_device_data *self) | ||
74 | { | ||
75 | return ADF_C62XIOV_MAX_ACCELENGINES; | ||
76 | } | ||
77 | |||
78 | static u32 get_misc_bar_id(struct adf_hw_device_data *self) | ||
79 | { | ||
80 | return ADF_C62XIOV_PMISC_BAR; | ||
81 | } | ||
82 | |||
83 | static u32 get_etr_bar_id(struct adf_hw_device_data *self) | ||
84 | { | ||
85 | return ADF_C62XIOV_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_C62XIOV_PF2VF_OFFSET; | ||
96 | } | ||
97 | |||
98 | static u32 get_vintmsk_offset(u32 i) | ||
99 | { | ||
100 | return ADF_C62XIOV_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_c62xiov(struct adf_hw_device_data *hw_data) | ||
136 | { | ||
137 | hw_data->dev_class = &c62xiov_class; | ||
138 | hw_data->num_banks = ADF_C62XIOV_ETR_MAX_BANKS; | ||
139 | hw_data->num_accel = ADF_C62XIOV_MAX_ACCELERATORS; | ||
140 | hw_data->num_logical_accel = 1; | ||
141 | hw_data->num_engines = ADF_C62XIOV_MAX_ACCELENGINES; | ||
142 | hw_data->tx_rx_gap = ADF_C62XIOV_RX_RINGS_OFFSET; | ||
143 | hw_data->tx_rings_mask = ADF_C62XIOV_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_c62xiov(struct adf_hw_device_data *hw_data) | ||
170 | { | ||
171 | hw_data->dev_class->instances--; | ||
172 | adf_devmgr_update_class_index(hw_data); | ||
173 | } | ||
diff --git a/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.h b/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.h new file mode 100644 index 000000000000..a28d83e77422 --- /dev/null +++ b/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.h | |||
@@ -0,0 +1,64 @@ | |||
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 | #ifndef ADF_C62XVF_HW_DATA_H_ | ||
48 | #define ADF_C62XVF_HW_DATA_H_ | ||
49 | |||
50 | #define ADF_C62XIOV_PMISC_BAR 1 | ||
51 | #define ADF_C62XIOV_ACCELERATORS_MASK 0x1 | ||
52 | #define ADF_C62XIOV_ACCELENGINES_MASK 0x1 | ||
53 | #define ADF_C62XIOV_MAX_ACCELERATORS 1 | ||
54 | #define ADF_C62XIOV_MAX_ACCELENGINES 1 | ||
55 | #define ADF_C62XIOV_RX_RINGS_OFFSET 8 | ||
56 | #define ADF_C62XIOV_TX_RINGS_MASK 0xFF | ||
57 | #define ADF_C62XIOV_ETR_BAR 0 | ||
58 | #define ADF_C62XIOV_ETR_MAX_BANKS 1 | ||
59 | #define ADF_C62XIOV_PF2VF_OFFSET 0x200 | ||
60 | #define ADF_C62XIOV_VINTMSK_OFFSET 0x208 | ||
61 | |||
62 | void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data); | ||
63 | void adf_clean_hw_data_c62xiov(struct adf_hw_device_data *hw_data); | ||
64 | #endif | ||
diff --git a/drivers/crypto/qat/qat_c62xvf/adf_drv.c b/drivers/crypto/qat/qat_c62xvf/adf_drv.c new file mode 100644 index 000000000000..d2e4b928f3be --- /dev/null +++ b/drivers/crypto/qat/qat_c62xvf/adf_drv.c | |||
@@ -0,0 +1,305 @@ | |||
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 | #include <linux/kernel.h> | ||
48 | #include <linux/module.h> | ||
49 | #include <linux/pci.h> | ||
50 | #include <linux/init.h> | ||
51 | #include <linux/types.h> | ||
52 | #include <linux/fs.h> | ||
53 | #include <linux/slab.h> | ||
54 | #include <linux/errno.h> | ||
55 | #include <linux/device.h> | ||
56 | #include <linux/dma-mapping.h> | ||
57 | #include <linux/platform_device.h> | ||
58 | #include <linux/workqueue.h> | ||
59 | #include <linux/io.h> | ||
60 | #include <adf_accel_devices.h> | ||
61 | #include <adf_common_drv.h> | ||
62 | #include <adf_cfg.h> | ||
63 | #include "adf_c62xvf_hw_data.h" | ||
64 | |||
65 | #define ADF_SYSTEM_DEVICE(device_id) \ | ||
66 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)} | ||
67 | |||
68 | static const struct pci_device_id adf_pci_tbl[] = { | ||
69 | ADF_SYSTEM_DEVICE(ADF_C62XIOV_PCI_DEVICE_ID), | ||
70 | {0,} | ||
71 | }; | ||
72 | MODULE_DEVICE_TABLE(pci, adf_pci_tbl); | ||
73 | |||
74 | static int adf_probe(struct pci_dev *dev, const struct pci_device_id *ent); | ||
75 | static void adf_remove(struct pci_dev *dev); | ||
76 | |||
77 | static struct pci_driver adf_driver = { | ||
78 | .id_table = adf_pci_tbl, | ||
79 | .name = ADF_C62XVF_DEVICE_NAME, | ||
80 | .probe = adf_probe, | ||
81 | .remove = adf_remove, | ||
82 | }; | ||
83 | |||
84 | static void adf_cleanup_pci_dev(struct adf_accel_dev *accel_dev) | ||
85 | { | ||
86 | pci_release_regions(accel_dev->accel_pci_dev.pci_dev); | ||
87 | pci_disable_device(accel_dev->accel_pci_dev.pci_dev); | ||
88 | } | ||
89 | |||
90 | static void adf_cleanup_accel(struct adf_accel_dev *accel_dev) | ||
91 | { | ||
92 | struct adf_accel_pci *accel_pci_dev = &accel_dev->accel_pci_dev; | ||
93 | struct adf_accel_dev *pf; | ||
94 | int i; | ||
95 | |||
96 | for (i = 0; i < ADF_PCI_MAX_BARS; i++) { | ||
97 | struct adf_bar *bar = &accel_pci_dev->pci_bars[i]; | ||
98 | |||
99 | if (bar->virt_addr) | ||
100 | pci_iounmap(accel_pci_dev->pci_dev, bar->virt_addr); | ||
101 | } | ||
102 | |||
103 | if (accel_dev->hw_device) { | ||
104 | switch (accel_pci_dev->pci_dev->device) { | ||
105 | case ADF_C62XIOV_PCI_DEVICE_ID: | ||
106 | adf_clean_hw_data_c62xiov(accel_dev->hw_device); | ||
107 | break; | ||
108 | default: | ||
109 | break; | ||
110 | } | ||
111 | kfree(accel_dev->hw_device); | ||
112 | accel_dev->hw_device = NULL; | ||
113 | } | ||
114 | adf_cfg_dev_remove(accel_dev); | ||
115 | debugfs_remove(accel_dev->debugfs_dir); | ||
116 | pf = adf_devmgr_pci_to_accel_dev(accel_pci_dev->pci_dev->physfn); | ||
117 | adf_devmgr_rm_dev(accel_dev, pf); | ||
118 | } | ||
119 | |||
120 | static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | ||
121 | { | ||
122 | struct adf_accel_dev *accel_dev; | ||
123 | struct adf_accel_dev *pf; | ||
124 | struct adf_accel_pci *accel_pci_dev; | ||
125 | struct adf_hw_device_data *hw_data; | ||
126 | char name[ADF_DEVICE_NAME_LENGTH]; | ||
127 | unsigned int i, bar_nr; | ||
128 | int ret, bar_mask; | ||
129 | |||
130 | switch (ent->device) { | ||
131 | case ADF_C62XIOV_PCI_DEVICE_ID: | ||
132 | break; | ||
133 | default: | ||
134 | dev_err(&pdev->dev, "Invalid device 0x%x.\n", ent->device); | ||
135 | return -ENODEV; | ||
136 | } | ||
137 | |||
138 | accel_dev = kzalloc_node(sizeof(*accel_dev), GFP_KERNEL, | ||
139 | dev_to_node(&pdev->dev)); | ||
140 | if (!accel_dev) | ||
141 | return -ENOMEM; | ||
142 | |||
143 | accel_dev->is_vf = true; | ||
144 | pf = adf_devmgr_pci_to_accel_dev(pdev->physfn); | ||
145 | accel_pci_dev = &accel_dev->accel_pci_dev; | ||
146 | accel_pci_dev->pci_dev = pdev; | ||
147 | |||
148 | /* Add accel device to accel table */ | ||
149 | if (adf_devmgr_add_dev(accel_dev, pf)) { | ||
150 | dev_err(&pdev->dev, "Failed to add new accelerator device.\n"); | ||
151 | kfree(accel_dev); | ||
152 | return -EFAULT; | ||
153 | } | ||
154 | INIT_LIST_HEAD(&accel_dev->crypto_list); | ||
155 | |||
156 | accel_dev->owner = THIS_MODULE; | ||
157 | /* Allocate and configure device configuration structure */ | ||
158 | hw_data = kzalloc_node(sizeof(*hw_data), GFP_KERNEL, | ||
159 | dev_to_node(&pdev->dev)); | ||
160 | if (!hw_data) { | ||
161 | ret = -ENOMEM; | ||
162 | goto out_err; | ||
163 | } | ||
164 | accel_dev->hw_device = hw_data; | ||
165 | adf_init_hw_data_c62xiov(accel_dev->hw_device); | ||
166 | |||
167 | /* Get Accelerators and Accelerators Engines masks */ | ||
168 | hw_data->accel_mask = hw_data->get_accel_mask(hw_data->fuses); | ||
169 | hw_data->ae_mask = hw_data->get_ae_mask(hw_data->fuses); | ||
170 | accel_pci_dev->sku = hw_data->get_sku(hw_data); | ||
171 | |||
172 | /* Create dev top level debugfs entry */ | ||
173 | snprintf(name, sizeof(name), "%s%s_%02x:%02d.%02d", | ||
174 | ADF_DEVICE_NAME_PREFIX, hw_data->dev_class->name, | ||
175 | pdev->bus->number, PCI_SLOT(pdev->devfn), | ||
176 | PCI_FUNC(pdev->devfn)); | ||
177 | |||
178 | accel_dev->debugfs_dir = debugfs_create_dir(name, NULL); | ||
179 | if (!accel_dev->debugfs_dir) { | ||
180 | dev_err(&pdev->dev, "Could not create debugfs dir %s\n", name); | ||
181 | ret = -EINVAL; | ||
182 | goto out_err; | ||
183 | } | ||
184 | |||
185 | /* Create device configuration table */ | ||
186 | ret = adf_cfg_dev_add(accel_dev); | ||
187 | if (ret) | ||
188 | goto out_err; | ||
189 | |||
190 | /* enable PCI device */ | ||
191 | if (pci_enable_device(pdev)) { | ||
192 | ret = -EFAULT; | ||
193 | goto out_err; | ||
194 | } | ||
195 | |||
196 | /* set dma identifier */ | ||
197 | if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { | ||
198 | if ((pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))) { | ||
199 | dev_err(&pdev->dev, "No usable DMA configuration\n"); | ||
200 | ret = -EFAULT; | ||
201 | goto out_err_disable; | ||
202 | } else { | ||
203 | pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); | ||
204 | } | ||
205 | |||
206 | } else { | ||
207 | pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); | ||
208 | } | ||
209 | |||
210 | if (pci_request_regions(pdev, ADF_C62XVF_DEVICE_NAME)) { | ||
211 | ret = -EFAULT; | ||
212 | goto out_err_disable; | ||
213 | } | ||
214 | |||
215 | /* Find and map all the device's BARS */ | ||
216 | i = 0; | ||
217 | bar_mask = pci_select_bars(pdev, IORESOURCE_MEM); | ||
218 | for_each_set_bit(bar_nr, (const unsigned long *)&bar_mask, | ||
219 | ADF_PCI_MAX_BARS * 2) { | ||
220 | struct adf_bar *bar = &accel_pci_dev->pci_bars[i++]; | ||
221 | |||
222 | bar->base_addr = pci_resource_start(pdev, bar_nr); | ||
223 | if (!bar->base_addr) | ||
224 | break; | ||
225 | bar->size = pci_resource_len(pdev, bar_nr); | ||
226 | bar->virt_addr = pci_iomap(accel_pci_dev->pci_dev, bar_nr, 0); | ||
227 | if (!bar->virt_addr) { | ||
228 | dev_err(&pdev->dev, "Failed to map BAR %d\n", bar_nr); | ||
229 | ret = -EFAULT; | ||
230 | goto out_err_free_reg; | ||
231 | } | ||
232 | } | ||
233 | pci_set_master(pdev); | ||
234 | /* Completion for VF2PF request/response message exchange */ | ||
235 | init_completion(&accel_dev->vf.iov_msg_completion); | ||
236 | |||
237 | ret = qat_crypto_dev_config(accel_dev); | ||
238 | if (ret) | ||
239 | goto out_err_free_reg; | ||
240 | |||
241 | ret = adf_dev_init(accel_dev); | ||
242 | if (ret) | ||
243 | goto out_err_dev_shutdown; | ||
244 | |||
245 | ret = adf_dev_start(accel_dev); | ||
246 | if (ret) | ||
247 | goto out_err_dev_stop; | ||
248 | |||
249 | return ret; | ||
250 | |||
251 | out_err_dev_stop: | ||
252 | adf_dev_stop(accel_dev); | ||
253 | out_err_dev_shutdown: | ||
254 | adf_dev_shutdown(accel_dev); | ||
255 | out_err_free_reg: | ||
256 | pci_release_regions(accel_pci_dev->pci_dev); | ||
257 | out_err_disable: | ||
258 | pci_disable_device(accel_pci_dev->pci_dev); | ||
259 | out_err: | ||
260 | adf_cleanup_accel(accel_dev); | ||
261 | kfree(accel_dev); | ||
262 | return ret; | ||
263 | } | ||
264 | |||
265 | static void adf_remove(struct pci_dev *pdev) | ||
266 | { | ||
267 | struct adf_accel_dev *accel_dev = adf_devmgr_pci_to_accel_dev(pdev); | ||
268 | |||
269 | if (!accel_dev) { | ||
270 | pr_err("QAT: Driver removal failed\n"); | ||
271 | return; | ||
272 | } | ||
273 | if (adf_dev_stop(accel_dev)) | ||
274 | dev_err(&GET_DEV(accel_dev), "Failed to stop QAT accel dev\n"); | ||
275 | |||
276 | adf_dev_shutdown(accel_dev); | ||
277 | adf_cleanup_accel(accel_dev); | ||
278 | adf_cleanup_pci_dev(accel_dev); | ||
279 | kfree(accel_dev); | ||
280 | } | ||
281 | |||
282 | static int __init adfdrv_init(void) | ||
283 | { | ||
284 | request_module("intel_qat"); | ||
285 | |||
286 | if (pci_register_driver(&adf_driver)) { | ||
287 | pr_err("QAT: Driver initialization failed\n"); | ||
288 | return -EFAULT; | ||
289 | } | ||
290 | return 0; | ||
291 | } | ||
292 | |||
293 | static void __exit adfdrv_release(void) | ||
294 | { | ||
295 | pci_unregister_driver(&adf_driver); | ||
296 | adf_clean_vf_map(true); | ||
297 | } | ||
298 | |||
299 | module_init(adfdrv_init); | ||
300 | module_exit(adfdrv_release); | ||
301 | |||
302 | MODULE_LICENSE("Dual BSD/GPL"); | ||
303 | MODULE_AUTHOR("Intel"); | ||
304 | MODULE_DESCRIPTION("Intel(R) QuickAssist Technology"); | ||
305 | MODULE_VERSION(ADF_DRV_VERSION); | ||
diff --git a/drivers/crypto/qat/qat_common/adf_cfg_common.h b/drivers/crypto/qat/qat_common/adf_cfg_common.h index 59a5d2a8331e..673dbf73b147 100644 --- a/drivers/crypto/qat/qat_common/adf_cfg_common.h +++ b/drivers/crypto/qat/qat_common/adf_cfg_common.h | |||
@@ -73,6 +73,7 @@ enum adf_device_type { | |||
73 | DEV_DH895XCC, | 73 | DEV_DH895XCC, |
74 | DEV_DH895XCCVF, | 74 | DEV_DH895XCCVF, |
75 | DEV_C62X, | 75 | DEV_C62X, |
76 | DEV_C62XVF, | ||
76 | DEV_C3XXX, | 77 | DEV_C3XXX, |
77 | DEV_C3XXXVF | 78 | DEV_C3XXXVF |
78 | }; | 79 | }; |