Skip to content

Commit 02dc8d6

Browse files
tstrukherbertx
authored andcommitted
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>
1 parent 5f575ef commit 02dc8d6

File tree

6 files changed

+103
-70
lines changed

6 files changed

+103
-70
lines changed

drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -109,29 +109,6 @@ static void adf_vf_void_noop(struct adf_accel_dev *accel_dev)
109109
{
110110
}
111111

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-
135112
void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data)
136113
{
137114
hw_data->dev_class = &c3xxxiov_class;

drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -109,29 +109,6 @@ static void adf_vf_void_noop(struct adf_accel_dev *accel_dev)
109109
{
110110
}
111111

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-
135112
void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data)
136113
{
137114
hw_data->dev_class = &c62xiov_class;

drivers/crypto/qat/qat_common/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ intel_qat-objs := adf_cfg.o \
2727
qat_hal.o
2828

2929
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

drivers/crypto/qat/qat_common/adf_common_drv.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
238238
uint32_t vf_mask);
239239
void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
240240
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);
241244
#else
242245
static inline int adf_sriov_configure(struct pci_dev *pdev, int numvfs)
243246
{
@@ -255,5 +258,14 @@ static inline void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev)
255258
static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev)
256259
{
257260
}
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+
}
258270
#endif
259271
#endif
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -109,29 +109,6 @@ static void adf_vf_void_noop(struct adf_accel_dev *accel_dev)
109109
{
110110
}
111111

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-
135112
void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data)
136113
{
137114
hw_data->dev_class = &dh895xcciov_class;

0 commit comments

Comments
 (0)