diff options
author | Tadeusz Struk <tadeusz.struk@intel.com> | 2016-04-15 13:37:58 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-04-18 06:49:47 -0400 |
commit | 02dc8d634b4f175d92aa8b0b217eb0e4db1a0c3b (patch) | |
tree | f1a1d21d82dc5b60db593196280c7a18bb5a934e | |
parent | 5f575efea79caae69b81f922d99b221302a2c003 (diff) |
crypto: qat - move vf2pf_init and vf2pf_exit to common
The vf2pf_init and vf2pf_exit are exactly the same for all VFs
so move them to common and reuse.
Tested-by: Suman Bangalore Sathyanarayana <sumanx.bangalore.sathyanarayana@intel.com>
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/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 23 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c | 23 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_common/Makefile | 2 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_common/adf_common_drv.h | 12 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_common/adf_vf2pf_msg.c | 90 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 23 |
6 files changed, 103 insertions, 70 deletions
diff --git a/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c b/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c index 1af321c2ce1a..d2d0ae445fd8 100644 --- a/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c +++ b/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | |||
@@ -109,29 +109,6 @@ static void adf_vf_void_noop(struct adf_accel_dev *accel_dev) | |||
109 | { | 109 | { |
110 | } | 110 | } |
111 | 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) | 112 | void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data) |
136 | { | 113 | { |
137 | hw_data->dev_class = &c3xxxiov_class; | 114 | hw_data->dev_class = &c3xxxiov_class; |
diff --git a/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c b/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c index baf4b509c892..38e4bc04f407 100644 --- a/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c +++ b/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c | |||
@@ -109,29 +109,6 @@ static void adf_vf_void_noop(struct adf_accel_dev *accel_dev) | |||
109 | { | 109 | { |
110 | } | 110 | } |
111 | 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) | 112 | void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data) |
136 | { | 113 | { |
137 | hw_data->dev_class = &c62xiov_class; | 114 | hw_data->dev_class = &c62xiov_class; |
diff --git a/drivers/crypto/qat/qat_common/Makefile b/drivers/crypto/qat/qat_common/Makefile index 29c7c53d2845..5873d22fc6cd 100644 --- a/drivers/crypto/qat/qat_common/Makefile +++ b/drivers/crypto/qat/qat_common/Makefile | |||
@@ -27,4 +27,4 @@ intel_qat-objs := adf_cfg.o \ | |||
27 | qat_hal.o | 27 | qat_hal.o |
28 | 28 | ||
29 | intel_qat-$(CONFIG_DEBUG_FS) += adf_transport_debug.o | 29 | intel_qat-$(CONFIG_DEBUG_FS) += adf_transport_debug.o |
30 | intel_qat-$(CONFIG_PCI_IOV) += adf_sriov.o adf_pf2vf_msg.o | 30 | intel_qat-$(CONFIG_PCI_IOV) += adf_sriov.o adf_pf2vf_msg.o adf_vf2pf_msg.o |
diff --git a/drivers/crypto/qat/qat_common/adf_common_drv.h b/drivers/crypto/qat/qat_common/adf_common_drv.h index fd096eda880f..a8100a37ee0c 100644 --- a/drivers/crypto/qat/qat_common/adf_common_drv.h +++ b/drivers/crypto/qat/qat_common/adf_common_drv.h | |||
@@ -238,6 +238,9 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev, | |||
238 | uint32_t vf_mask); | 238 | uint32_t vf_mask); |
239 | void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev); | 239 | void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev); |
240 | void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev); | 240 | void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev); |
241 | |||
242 | int adf_vf2pf_init(struct adf_accel_dev *accel_dev); | ||
243 | void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev); | ||
241 | #else | 244 | #else |
242 | static inline int adf_sriov_configure(struct pci_dev *pdev, int numvfs) | 245 | static inline int adf_sriov_configure(struct pci_dev *pdev, int numvfs) |
243 | { | 246 | { |
@@ -255,5 +258,14 @@ static inline void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev) | |||
255 | static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev) | 258 | static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev) |
256 | { | 259 | { |
257 | } | 260 | } |
261 | |||
262 | static inline int adf_vf2pf_init(struct adf_accel_dev *accel_dev) | ||
263 | { | ||
264 | return 0; | ||
265 | } | ||
266 | |||
267 | static inline void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev) | ||
268 | { | ||
269 | } | ||
258 | #endif | 270 | #endif |
259 | #endif | 271 | #endif |
diff --git a/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c b/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c new file mode 100644 index 000000000000..5f1d863ae802 --- /dev/null +++ b/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c | |||
@@ -0,0 +1,90 @@ | |||
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_common_drv.h" | ||
49 | #include "adf_pf2vf_msg.h" | ||
50 | |||
51 | /** | ||
52 | * adf_vf2pf_init() - send init msg to PF | ||
53 | * @accel_dev: Pointer to acceleration VF device. | ||
54 | * | ||
55 | * Function sends an init messge from the VF to a PF | ||
56 | * | ||
57 | * Return: 0 on success, error code otherwise. | ||
58 | */ | ||
59 | int adf_vf2pf_init(struct adf_accel_dev *accel_dev) | ||
60 | { | ||
61 | u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM | | ||
62 | (ADF_VF2PF_MSGTYPE_INIT << ADF_VF2PF_MSGTYPE_SHIFT)); | ||
63 | |||
64 | if (adf_iov_putmsg(accel_dev, msg, 0)) { | ||
65 | dev_err(&GET_DEV(accel_dev), | ||
66 | "Failed to send Init event to PF\n"); | ||
67 | return -EFAULT; | ||
68 | } | ||
69 | return 0; | ||
70 | } | ||
71 | EXPORT_SYMBOL_GPL(adf_vf2pf_init); | ||
72 | |||
73 | /** | ||
74 | * adf_vf2pf_shutdown() - send shutdown msg to PF | ||
75 | * @accel_dev: Pointer to acceleration VF device. | ||
76 | * | ||
77 | * Function sends a shutdown messge from the VF to a PF | ||
78 | * | ||
79 | * Return: void | ||
80 | */ | ||
81 | void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev) | ||
82 | { | ||
83 | u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM | | ||
84 | (ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_VF2PF_MSGTYPE_SHIFT)); | ||
85 | |||
86 | if (adf_iov_putmsg(accel_dev, msg, 0)) | ||
87 | dev_err(&GET_DEV(accel_dev), | ||
88 | "Failed to send Shutdown event to PF\n"); | ||
89 | } | ||
90 | EXPORT_SYMBOL_GPL(adf_vf2pf_shutdown); | ||
diff --git a/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c b/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c index dc04ab68d24d..a3b4dd8099a7 100644 --- a/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c +++ b/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c | |||
@@ -109,29 +109,6 @@ static void adf_vf_void_noop(struct adf_accel_dev *accel_dev) | |||
109 | { | 109 | { |
110 | } | 110 | } |
111 | 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_dh895xcciov(struct adf_hw_device_data *hw_data) | 112 | void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data) |
136 | { | 113 | { |
137 | hw_data->dev_class = &dh895xcciov_class; | 114 | hw_data->dev_class = &dh895xcciov_class; |