Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: qat - reorganize PFVF code

Reorganize the structure of the PFVF code by moving the content of
adf_pf2vf_msg.c and adf_vf2pf_msg.c.

The logic that handles high level messages has been moved to
adf_pfvf_pf_msg.c and adf_pfvf_vf_msg.c.
The implementation of low level communication primitives and the
protocol is now included in adf_pfvf_pf_proto.c and adf_pfvf_vf_proto.c.

In addition, the file adf_pf2vf_msg.h has been renamed in adf_pfvf_msg.h
since it common to PF and VF and the copyright date for the touched
files has been updated.

Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Co-developed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Marco Chiappero and committed by
Herbert Xu
09ce899a 1ea7c2be

+341 -276
+2 -2
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c
··· 1 1 // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) 2 - /* Copyright(c) 2020 Intel Corporation */ 2 + /* Copyright(c) 2020 - 2021 Intel Corporation */ 3 3 #include <linux/iopoll.h> 4 4 #include <adf_accel_devices.h> 5 5 #include <adf_common_drv.h> 6 - #include <adf_pf2vf_msg.h> 7 6 #include <adf_gen4_hw_data.h> 7 + #include <adf_pfvf_msg.h> 8 8 #include "adf_4xxx_hw_data.h" 9 9 #include "icp_qat_hw.h" 10 10
+2 -2
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c
··· 1 1 // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) 2 - /* Copyright(c) 2014 - 2020 Intel Corporation */ 2 + /* Copyright(c) 2014 - 2021 Intel Corporation */ 3 3 #include <adf_accel_devices.h> 4 4 #include <adf_common_drv.h> 5 - #include <adf_pf2vf_msg.h> 6 5 #include <adf_gen2_hw_data.h> 7 6 #include <adf_gen2_pfvf.h> 7 + #include <adf_pfvf_msg.h> 8 8 #include "adf_c3xxx_hw_data.h" 9 9 #include "icp_qat_hw.h" 10 10
+3 -2
drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c
··· 1 1 // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) 2 - /* Copyright(c) 2015 - 2020 Intel Corporation */ 2 + /* Copyright(c) 2015 - 2021 Intel Corporation */ 3 3 #include <adf_accel_devices.h> 4 - #include <adf_pf2vf_msg.h> 5 4 #include <adf_common_drv.h> 6 5 #include <adf_gen2_hw_data.h> 7 6 #include <adf_gen2_pfvf.h> 7 + #include <adf_pfvf_msg.h> 8 + #include <adf_pfvf_vf_msg.h> 8 9 #include "adf_c3xxxvf_hw_data.h" 9 10 10 11 static struct adf_hw_device_class c3xxxiov_class = {
+2 -2
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c
··· 1 1 // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) 2 - /* Copyright(c) 2014 - 2020 Intel Corporation */ 2 + /* Copyright(c) 2014 - 2021 Intel Corporation */ 3 3 #include <adf_accel_devices.h> 4 4 #include <adf_common_drv.h> 5 - #include <adf_pf2vf_msg.h> 6 5 #include <adf_gen2_hw_data.h> 7 6 #include <adf_gen2_pfvf.h> 7 + #include <adf_pfvf_msg.h> 8 8 #include "adf_c62x_hw_data.h" 9 9 #include "icp_qat_hw.h" 10 10
+3 -2
drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c
··· 1 1 // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) 2 - /* Copyright(c) 2015 - 2020 Intel Corporation */ 2 + /* Copyright(c) 2015 - 2021 Intel Corporation */ 3 3 #include <adf_accel_devices.h> 4 - #include <adf_pf2vf_msg.h> 5 4 #include <adf_common_drv.h> 6 5 #include <adf_gen2_hw_data.h> 7 6 #include <adf_gen2_pfvf.h> 7 + #include <adf_pfvf_msg.h> 8 + #include <adf_pfvf_vf_msg.h> 8 9 #include "adf_c62xvf_hw_data.h" 9 10 10 11 static struct adf_hw_device_class c62xiov_class = {
+3 -2
drivers/crypto/qat/qat_common/Makefile
··· 19 19 qat_hal.o 20 20 21 21 intel_qat-$(CONFIG_DEBUG_FS) += adf_transport_debug.o 22 - intel_qat-$(CONFIG_PCI_IOV) += adf_sriov.o adf_pf2vf_msg.o \ 23 - adf_vf2pf_msg.o adf_vf_isr.o \ 22 + intel_qat-$(CONFIG_PCI_IOV) += adf_sriov.o adf_vf_isr.o \ 23 + adf_pfvf_pf_msg.o adf_pfvf_pf_proto.o \ 24 + adf_pfvf_vf_msg.o adf_pfvf_vf_proto.o \ 24 25 adf_gen2_pfvf.o
+1 -21
drivers/crypto/qat/qat_common/adf_common_drv.h
··· 1 1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ 2 - /* Copyright(c) 2014 - 2020 Intel Corporation */ 2 + /* Copyright(c) 2014 - 2021 Intel Corporation */ 3 3 #ifndef ADF_DRV_H 4 4 #define ADF_DRV_H 5 5 ··· 62 62 void adf_dev_stop(struct adf_accel_dev *accel_dev); 63 63 void adf_dev_shutdown(struct adf_accel_dev *accel_dev); 64 64 65 - void adf_pf2vf_notify_restarting(struct adf_accel_dev *accel_dev); 66 - int adf_enable_vf2pf_comms(struct adf_accel_dev *accel_dev); 67 65 void adf_devmgr_update_class_index(struct adf_hw_device_data *hw_data); 68 66 void adf_clean_vf_map(bool); 69 67 ··· 197 199 bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev); 198 200 bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr); 199 201 int adf_pf2vf_handle_pf_restarting(struct adf_accel_dev *accel_dev); 200 - int adf_enable_pf2vf_comms(struct adf_accel_dev *accel_dev); 201 202 void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev); 202 203 void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev); 203 204 void adf_schedule_vf2pf_handler(struct adf_accel_vf_info *vf_info); 204 - int adf_send_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 msg); 205 - int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev); 206 - void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev); 207 205 int adf_init_pf_wq(void); 208 206 void adf_exit_pf_wq(void); 209 207 int adf_init_vf_wq(void); ··· 207 213 void adf_flush_vf_wq(struct adf_accel_dev *accel_dev); 208 214 #else 209 215 #define adf_sriov_configure NULL 210 - 211 - static inline int adf_enable_pf2vf_comms(struct adf_accel_dev *accel_dev) 212 - { 213 - return 0; 214 - } 215 216 216 217 static inline void adf_disable_sriov(struct adf_accel_dev *accel_dev) 217 218 { ··· 217 228 } 218 229 219 230 static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev) 220 - { 221 - } 222 - 223 - static inline int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev) 224 - { 225 - return 0; 226 - } 227 - 228 - static inline void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev) 229 231 { 230 232 } 231 233
+3 -1
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c
··· 6 6 #include "adf_accel_devices.h" 7 7 #include "adf_common_drv.h" 8 8 #include "adf_gen2_pfvf.h" 9 - #include "adf_pf2vf_msg.h" 9 + #include "adf_pfvf_msg.h" 10 + #include "adf_pfvf_pf_proto.h" 11 + #include "adf_pfvf_vf_proto.h" 10 12 11 13 /* VF2PF interrupts */ 12 14 #define ADF_GEN2_ERR_REG_VF2PF(vf_src) (((vf_src) & 0x01FFFE00) >> 9)
+6 -131
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c
··· 1 1 // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) 2 - /* Copyright(c) 2015 - 2020 Intel Corporation */ 2 + /* Copyright(c) 2015 - 2021 Intel Corporation */ 3 + #include <linux/spinlock.h> 4 + #include <linux/types.h> 3 5 #include "adf_accel_devices.h" 4 6 #include "adf_common_drv.h" 5 - #include "adf_pf2vf_msg.h" 6 - 7 - #define ADF_PFVF_MSG_COLLISION_DETECT_DELAY 10 8 - #define ADF_PFVF_MSG_ACK_DELAY 2 9 - #define ADF_PFVF_MSG_ACK_MAX_RETRY 100 10 - #define ADF_PFVF_MSG_RESP_TIMEOUT (ADF_PFVF_MSG_ACK_DELAY * \ 11 - ADF_PFVF_MSG_ACK_MAX_RETRY + \ 12 - ADF_PFVF_MSG_COLLISION_DETECT_DELAY) 7 + #include "adf_pfvf_msg.h" 8 + #include "adf_pfvf_pf_proto.h" 13 9 14 10 /** 15 11 * adf_send_pf2vf_msg() - send PF to VF message ··· 17 21 * 18 22 * Return: 0 on success, error code otherwise. 19 23 */ 20 - static int adf_send_pf2vf_msg(struct adf_accel_dev *accel_dev, u8 vf_nr, u32 msg) 24 + int adf_send_pf2vf_msg(struct adf_accel_dev *accel_dev, u8 vf_nr, u32 msg) 21 25 { 22 26 return GET_PFVF_OPS(accel_dev)->send_msg(accel_dev, msg, vf_nr); 23 - } 24 - 25 - /** 26 - * adf_send_vf2pf_msg() - send VF to PF message 27 - * @accel_dev: Pointer to acceleration device 28 - * @msg: Message to send 29 - * 30 - * This function allows the VF to send a message to the PF. 31 - * 32 - * Return: 0 on success, error code otherwise. 33 - */ 34 - int adf_send_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 msg) 35 - { 36 - return GET_PFVF_OPS(accel_dev)->send_msg(accel_dev, msg, 0); 37 27 } 38 28 39 29 /** ··· 34 52 static u32 adf_recv_vf2pf_msg(struct adf_accel_dev *accel_dev, u8 vf_nr) 35 53 { 36 54 return GET_PFVF_OPS(accel_dev)->recv_msg(accel_dev, vf_nr); 37 - } 38 - 39 - /** 40 - * adf_send_vf2pf_req() - send VF2PF request message 41 - * @accel_dev: Pointer to acceleration device. 42 - * @msg: Request message to send 43 - * 44 - * This function sends a message that requires a response from the VF to the PF 45 - * and waits for a reply. 46 - * 47 - * Return: 0 on success, error code otherwise. 48 - */ 49 - static int adf_send_vf2pf_req(struct adf_accel_dev *accel_dev, u32 msg) 50 - { 51 - unsigned long timeout = msecs_to_jiffies(ADF_PFVF_MSG_RESP_TIMEOUT); 52 - int ret; 53 - 54 - reinit_completion(&accel_dev->vf.iov_msg_completion); 55 - 56 - /* Send request from VF to PF */ 57 - ret = adf_send_vf2pf_msg(accel_dev, msg); 58 - if (ret) { 59 - dev_err(&GET_DEV(accel_dev), 60 - "Failed to send request msg to PF\n"); 61 - return ret; 62 - } 63 - 64 - /* Wait for response */ 65 - if (!wait_for_completion_timeout(&accel_dev->vf.iov_msg_completion, 66 - timeout)) { 67 - dev_err(&GET_DEV(accel_dev), 68 - "PFVF request/response message timeout expired\n"); 69 - return -EIO; 70 - } 71 - 72 - return 0; 73 55 } 74 56 75 57 static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr, ··· 138 192 139 193 return true; 140 194 } 141 - 142 - void adf_pf2vf_notify_restarting(struct adf_accel_dev *accel_dev) 143 - { 144 - struct adf_accel_vf_info *vf; 145 - u32 msg = (ADF_PF2VF_MSGORIGIN_SYSTEM | 146 - (ADF_PF2VF_MSGTYPE_RESTARTING << ADF_PF2VF_MSGTYPE_SHIFT)); 147 - int i, num_vfs = pci_num_vf(accel_to_pci_dev(accel_dev)); 148 - 149 - for (i = 0, vf = accel_dev->pf.vf_info; i < num_vfs; i++, vf++) { 150 - if (vf->init && adf_send_pf2vf_msg(accel_dev, i, msg)) 151 - dev_err(&GET_DEV(accel_dev), 152 - "Failed to send restarting msg to VF%d\n", i); 153 - } 154 - } 155 - 156 - static int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev) 157 - { 158 - struct adf_hw_device_data *hw_data = accel_dev->hw_device; 159 - u32 msg = 0; 160 - int ret; 161 - 162 - msg = ADF_VF2PF_MSGORIGIN_SYSTEM; 163 - msg |= ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ << ADF_VF2PF_MSGTYPE_SHIFT; 164 - msg |= ADF_PFVF_COMPAT_THIS_VERSION << ADF_VF2PF_COMPAT_VER_REQ_SHIFT; 165 - BUILD_BUG_ON(ADF_PFVF_COMPAT_THIS_VERSION > 255); 166 - 167 - ret = adf_send_vf2pf_req(accel_dev, msg); 168 - if (ret) { 169 - dev_err(&GET_DEV(accel_dev), 170 - "Failed to send Compatibility Version Request.\n"); 171 - return ret; 172 - } 173 - 174 - /* Response from PF received, check compatibility */ 175 - switch (accel_dev->vf.compatible) { 176 - case ADF_PF2VF_VF_COMPATIBLE: 177 - break; 178 - case ADF_PF2VF_VF_COMPAT_UNKNOWN: 179 - /* VF is newer than PF and decides whether it is compatible */ 180 - if (accel_dev->vf.pf_version >= hw_data->min_iov_compat_ver) { 181 - accel_dev->vf.compatible = ADF_PF2VF_VF_COMPATIBLE; 182 - break; 183 - } 184 - fallthrough; 185 - case ADF_PF2VF_VF_INCOMPATIBLE: 186 - dev_err(&GET_DEV(accel_dev), 187 - "PF (vers %d) and VF (vers %d) are not compatible\n", 188 - accel_dev->vf.pf_version, 189 - ADF_PFVF_COMPAT_THIS_VERSION); 190 - return -EINVAL; 191 - default: 192 - dev_err(&GET_DEV(accel_dev), 193 - "Invalid response from PF; assume not compatible\n"); 194 - return -EINVAL; 195 - } 196 - return ret; 197 - } 198 - 199 - /** 200 - * adf_enable_vf2pf_comms() - Function enables communication from vf to pf 201 - * 202 - * @accel_dev: Pointer to acceleration device virtual function. 203 - * 204 - * Return: 0 on success, error code otherwise. 205 - */ 206 - int adf_enable_vf2pf_comms(struct adf_accel_dev *accel_dev) 207 - { 208 - adf_enable_pf2vf_interrupts(accel_dev); 209 - return adf_vf2pf_request_version(accel_dev); 210 - } 211 - EXPORT_SYMBOL_GPL(adf_enable_vf2pf_comms); 212 195 213 196 /** 214 197 * adf_enable_pf2vf_comms() - Function enables communication from pf to vf
+4 -4
drivers/crypto/qat/qat_common/adf_pf2vf_msg.h drivers/crypto/qat/qat_common/adf_pfvf_msg.h
··· 1 1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ 2 - /* Copyright(c) 2015 - 2020 Intel Corporation */ 3 - #ifndef ADF_PF2VF_MSG_H 4 - #define ADF_PF2VF_MSG_H 2 + /* Copyright(c) 2015 - 2021 Intel Corporation */ 3 + #ifndef ADF_PFVF_MSG_H 4 + #define ADF_PFVF_MSG_H 5 5 6 6 /* 7 7 * PF<->VF Messaging ··· 91 91 /* VF->PF Compatible Version Request */ 92 92 #define ADF_VF2PF_COMPAT_VER_REQ_SHIFT 22 93 93 94 - #endif /* ADF_IOV_MSG_H */ 94 + #endif /* ADF_PFVF_MSG_H */
+21
drivers/crypto/qat/qat_common/adf_pfvf_pf_msg.c
··· 1 + // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) 2 + /* Copyright(c) 2015 - 2021 Intel Corporation */ 3 + #include <linux/pci.h> 4 + #include "adf_accel_devices.h" 5 + #include "adf_pfvf_msg.h" 6 + #include "adf_pfvf_pf_msg.h" 7 + #include "adf_pfvf_pf_proto.h" 8 + 9 + void adf_pf2vf_notify_restarting(struct adf_accel_dev *accel_dev) 10 + { 11 + struct adf_accel_vf_info *vf; 12 + u32 msg = (ADF_PF2VF_MSGORIGIN_SYSTEM | 13 + (ADF_PF2VF_MSGTYPE_RESTARTING << ADF_PF2VF_MSGTYPE_SHIFT)); 14 + int i, num_vfs = pci_num_vf(accel_to_pci_dev(accel_dev)); 15 + 16 + for (i = 0, vf = accel_dev->pf.vf_info; i < num_vfs; i++, vf++) { 17 + if (vf->init && adf_send_pf2vf_msg(accel_dev, i, msg)) 18 + dev_err(&GET_DEV(accel_dev), 19 + "Failed to send restarting msg to VF%d\n", i); 20 + } 21 + }
+10
drivers/crypto/qat/qat_common/adf_pfvf_pf_msg.h
··· 1 + /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ 2 + /* Copyright(c) 2021 Intel Corporation */ 3 + #ifndef ADF_PFVF_PF_MSG_H 4 + #define ADF_PFVF_PF_MSG_H 5 + 6 + #include "adf_accel_devices.h" 7 + 8 + void adf_pf2vf_notify_restarting(struct adf_accel_dev *accel_dev); 9 + 10 + #endif /* ADF_PFVF_PF_MSG_H */
+13
drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.h
··· 1 + /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ 2 + /* Copyright(c) 2021 Intel Corporation */ 3 + #ifndef ADF_PFVF_PF_PROTO_H 4 + #define ADF_PFVF_PF_PROTO_H 5 + 6 + #include <linux/types.h> 7 + #include "adf_accel_devices.h" 8 + 9 + int adf_send_pf2vf_msg(struct adf_accel_dev *accel_dev, u8 vf_nr, u32 msg); 10 + 11 + int adf_enable_pf2vf_comms(struct adf_accel_dev *accel_dev); 12 + 13 + #endif /* ADF_PFVF_PF_PROTO_H */
+93
drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c
··· 1 + // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) 2 + /* Copyright(c) 2015 - 2021 Intel Corporation */ 3 + #include "adf_accel_devices.h" 4 + #include "adf_common_drv.h" 5 + #include "adf_pfvf_msg.h" 6 + #include "adf_pfvf_vf_msg.h" 7 + #include "adf_pfvf_vf_proto.h" 8 + 9 + /** 10 + * adf_vf2pf_notify_init() - send init msg to PF 11 + * @accel_dev: Pointer to acceleration VF device. 12 + * 13 + * Function sends an init message from the VF to a PF 14 + * 15 + * Return: 0 on success, error code otherwise. 16 + */ 17 + int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev) 18 + { 19 + u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM | 20 + (ADF_VF2PF_MSGTYPE_INIT << ADF_VF2PF_MSGTYPE_SHIFT)); 21 + 22 + if (adf_send_vf2pf_msg(accel_dev, msg)) { 23 + dev_err(&GET_DEV(accel_dev), 24 + "Failed to send Init event to PF\n"); 25 + return -EFAULT; 26 + } 27 + set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status); 28 + return 0; 29 + } 30 + EXPORT_SYMBOL_GPL(adf_vf2pf_notify_init); 31 + 32 + /** 33 + * adf_vf2pf_notify_shutdown() - send shutdown msg to PF 34 + * @accel_dev: Pointer to acceleration VF device. 35 + * 36 + * Function sends a shutdown message from the VF to a PF 37 + * 38 + * Return: void 39 + */ 40 + void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev) 41 + { 42 + u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM | 43 + (ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_VF2PF_MSGTYPE_SHIFT)); 44 + 45 + if (test_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status)) 46 + if (adf_send_vf2pf_msg(accel_dev, msg)) 47 + dev_err(&GET_DEV(accel_dev), 48 + "Failed to send Shutdown event to PF\n"); 49 + } 50 + EXPORT_SYMBOL_GPL(adf_vf2pf_notify_shutdown); 51 + 52 + int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev) 53 + { 54 + struct adf_hw_device_data *hw_data = accel_dev->hw_device; 55 + u32 msg = 0; 56 + int ret; 57 + 58 + msg = ADF_VF2PF_MSGORIGIN_SYSTEM; 59 + msg |= ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ << ADF_VF2PF_MSGTYPE_SHIFT; 60 + msg |= ADF_PFVF_COMPAT_THIS_VERSION << ADF_VF2PF_COMPAT_VER_REQ_SHIFT; 61 + BUILD_BUG_ON(ADF_PFVF_COMPAT_THIS_VERSION > 255); 62 + 63 + ret = adf_send_vf2pf_req(accel_dev, msg); 64 + if (ret) { 65 + dev_err(&GET_DEV(accel_dev), 66 + "Failed to send Compatibility Version Request.\n"); 67 + return ret; 68 + } 69 + 70 + /* Response from PF received, check compatibility */ 71 + switch (accel_dev->vf.compatible) { 72 + case ADF_PF2VF_VF_COMPATIBLE: 73 + break; 74 + case ADF_PF2VF_VF_COMPAT_UNKNOWN: 75 + /* VF is newer than PF and decides whether it is compatible */ 76 + if (accel_dev->vf.pf_version >= hw_data->min_iov_compat_ver) { 77 + accel_dev->vf.compatible = ADF_PF2VF_VF_COMPATIBLE; 78 + break; 79 + } 80 + fallthrough; 81 + case ADF_PF2VF_VF_INCOMPATIBLE: 82 + dev_err(&GET_DEV(accel_dev), 83 + "PF (vers %d) and VF (vers %d) are not compatible\n", 84 + accel_dev->vf.pf_version, 85 + ADF_PFVF_COMPAT_THIS_VERSION); 86 + return -EINVAL; 87 + default: 88 + dev_err(&GET_DEV(accel_dev), 89 + "Invalid response from PF; assume not compatible\n"); 90 + return -EINVAL; 91 + } 92 + return ret; 93 + }
+21
drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.h
··· 1 + /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ 2 + /* Copyright(c) 2021 Intel Corporation */ 3 + #ifndef ADF_PFVF_VF_MSG_H 4 + #define ADF_PFVF_VF_MSG_H 5 + 6 + #if defined(CONFIG_PCI_IOV) 7 + int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev); 8 + void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev); 9 + int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev); 10 + #else 11 + static inline int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev) 12 + { 13 + return 0; 14 + } 15 + 16 + static inline void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev) 17 + { 18 + } 19 + #endif 20 + 21 + #endif /* ADF_PFVF_VF_MSG_H */
+133
drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.c
··· 1 + // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) 2 + /* Copyright(c) 2015 - 2021 Intel Corporation */ 3 + #include <linux/completion.h> 4 + #include <linux/types.h> 5 + #include "adf_accel_devices.h" 6 + #include "adf_common_drv.h" 7 + #include "adf_pfvf_msg.h" 8 + #include "adf_pfvf_vf_msg.h" 9 + #include "adf_pfvf_vf_proto.h" 10 + 11 + #define ADF_PFVF_MSG_COLLISION_DETECT_DELAY 10 12 + #define ADF_PFVF_MSG_ACK_DELAY 2 13 + #define ADF_PFVF_MSG_ACK_MAX_RETRY 100 14 + 15 + #define ADF_PFVF_MSG_RESP_TIMEOUT (ADF_PFVF_MSG_ACK_DELAY * \ 16 + ADF_PFVF_MSG_ACK_MAX_RETRY + \ 17 + ADF_PFVF_MSG_COLLISION_DETECT_DELAY) 18 + 19 + /** 20 + * adf_send_vf2pf_msg() - send VF to PF message 21 + * @accel_dev: Pointer to acceleration device 22 + * @msg: Message to send 23 + * 24 + * This function allows the VF to send a message to the PF. 25 + * 26 + * Return: 0 on success, error code otherwise. 27 + */ 28 + int adf_send_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 msg) 29 + { 30 + return GET_PFVF_OPS(accel_dev)->send_msg(accel_dev, msg, 0); 31 + } 32 + 33 + /** 34 + * adf_recv_pf2vf_msg() - receive a PF to VF message 35 + * @accel_dev: Pointer to acceleration device 36 + * 37 + * This function allows the VF to receive a message from the PF. 38 + * 39 + * Return: a valid message on success, zero otherwise. 40 + */ 41 + static u32 adf_recv_pf2vf_msg(struct adf_accel_dev *accel_dev) 42 + { 43 + return GET_PFVF_OPS(accel_dev)->recv_msg(accel_dev, 0); 44 + } 45 + 46 + /** 47 + * adf_send_vf2pf_req() - send VF2PF request message 48 + * @accel_dev: Pointer to acceleration device. 49 + * @msg: Request message to send 50 + * 51 + * This function sends a message that requires a response from the VF to the PF 52 + * and waits for a reply. 53 + * 54 + * Return: 0 on success, error code otherwise. 55 + */ 56 + int adf_send_vf2pf_req(struct adf_accel_dev *accel_dev, u32 msg) 57 + { 58 + unsigned long timeout = msecs_to_jiffies(ADF_PFVF_MSG_RESP_TIMEOUT); 59 + int ret; 60 + 61 + reinit_completion(&accel_dev->vf.iov_msg_completion); 62 + 63 + /* Send request from VF to PF */ 64 + ret = adf_send_vf2pf_msg(accel_dev, msg); 65 + if (ret) { 66 + dev_err(&GET_DEV(accel_dev), 67 + "Failed to send request msg to PF\n"); 68 + return ret; 69 + } 70 + 71 + /* Wait for response */ 72 + if (!wait_for_completion_timeout(&accel_dev->vf.iov_msg_completion, 73 + timeout)) { 74 + dev_err(&GET_DEV(accel_dev), 75 + "PFVF request/response message timeout expired\n"); 76 + return -EIO; 77 + } 78 + 79 + return 0; 80 + } 81 + 82 + static bool adf_handle_pf2vf_msg(struct adf_accel_dev *accel_dev, u32 msg) 83 + { 84 + switch ((msg & ADF_PF2VF_MSGTYPE_MASK) >> ADF_PF2VF_MSGTYPE_SHIFT) { 85 + case ADF_PF2VF_MSGTYPE_RESTARTING: 86 + dev_dbg(&GET_DEV(accel_dev), 87 + "Restarting msg received from PF 0x%x\n", msg); 88 + 89 + adf_pf2vf_handle_pf_restarting(accel_dev); 90 + return false; 91 + case ADF_PF2VF_MSGTYPE_VERSION_RESP: 92 + dev_dbg(&GET_DEV(accel_dev), 93 + "Version resp received from PF 0x%x\n", msg); 94 + accel_dev->vf.pf_version = 95 + (msg & ADF_PF2VF_VERSION_RESP_VERS_MASK) >> 96 + ADF_PF2VF_VERSION_RESP_VERS_SHIFT; 97 + accel_dev->vf.compatible = 98 + (msg & ADF_PF2VF_VERSION_RESP_RESULT_MASK) >> 99 + ADF_PF2VF_VERSION_RESP_RESULT_SHIFT; 100 + complete(&accel_dev->vf.iov_msg_completion); 101 + return true; 102 + default: 103 + dev_err(&GET_DEV(accel_dev), 104 + "Unknown PF2VF message(0x%x)\n", msg); 105 + } 106 + 107 + return false; 108 + } 109 + 110 + bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev) 111 + { 112 + u32 msg; 113 + 114 + msg = adf_recv_pf2vf_msg(accel_dev); 115 + if (msg) 116 + return adf_handle_pf2vf_msg(accel_dev, msg); 117 + 118 + return true; 119 + } 120 + 121 + /** 122 + * adf_enable_vf2pf_comms() - Function enables communication from vf to pf 123 + * 124 + * @accel_dev: Pointer to acceleration device virtual function. 125 + * 126 + * Return: 0 on success, error code otherwise. 127 + */ 128 + int adf_enable_vf2pf_comms(struct adf_accel_dev *accel_dev) 129 + { 130 + adf_enable_pf2vf_interrupts(accel_dev); 131 + return adf_vf2pf_request_version(accel_dev); 132 + } 133 + EXPORT_SYMBOL_GPL(adf_enable_vf2pf_comms);
+14
drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.h
··· 1 + /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ 2 + /* Copyright(c) 2021 Intel Corporation */ 3 + #ifndef ADF_PFVF_VF_PROTO_H 4 + #define ADF_PFVF_VF_PROTO_H 5 + 6 + #include <linux/types.h> 7 + #include "adf_accel_devices.h" 8 + 9 + int adf_send_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 msg); 10 + int adf_send_vf2pf_req(struct adf_accel_dev *accel_dev, u32 msg); 11 + 12 + int adf_enable_vf2pf_comms(struct adf_accel_dev *accel_dev); 13 + 14 + #endif /* ADF_PFVF_VF_PROTO_H */
+2 -2
drivers/crypto/qat/qat_common/adf_sriov.c
··· 1 1 // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) 2 - /* Copyright(c) 2015 - 2020 Intel Corporation */ 2 + /* Copyright(c) 2015 - 2021 Intel Corporation */ 3 3 #include <linux/workqueue.h> 4 4 #include <linux/pci.h> 5 5 #include <linux/device.h> 6 6 #include <linux/iommu.h> 7 7 #include "adf_common_drv.h" 8 8 #include "adf_cfg.h" 9 - #include "adf_pf2vf_msg.h" 9 + #include "adf_pfvf_pf_msg.h" 10 10 11 11 static struct workqueue_struct *pf2vf_resp_wq; 12 12
-100
drivers/crypto/qat/qat_common/adf_vf2pf_msg.c
··· 1 - // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) 2 - /* Copyright(c) 2015 - 2020 Intel Corporation */ 3 - #include "adf_accel_devices.h" 4 - #include "adf_common_drv.h" 5 - #include "adf_pf2vf_msg.h" 6 - 7 - /** 8 - * adf_vf2pf_notify_init() - send init msg to PF 9 - * @accel_dev: Pointer to acceleration VF device. 10 - * 11 - * Function sends an init message from the VF to a PF 12 - * 13 - * Return: 0 on success, error code otherwise. 14 - */ 15 - int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev) 16 - { 17 - u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM | 18 - (ADF_VF2PF_MSGTYPE_INIT << ADF_VF2PF_MSGTYPE_SHIFT)); 19 - 20 - if (adf_send_vf2pf_msg(accel_dev, msg)) { 21 - dev_err(&GET_DEV(accel_dev), 22 - "Failed to send Init event to PF\n"); 23 - return -EFAULT; 24 - } 25 - set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status); 26 - return 0; 27 - } 28 - EXPORT_SYMBOL_GPL(adf_vf2pf_notify_init); 29 - 30 - /** 31 - * adf_vf2pf_notify_shutdown() - send shutdown msg to PF 32 - * @accel_dev: Pointer to acceleration VF device. 33 - * 34 - * Function sends a shutdown message from the VF to a PF 35 - * 36 - * Return: void 37 - */ 38 - void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev) 39 - { 40 - u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM | 41 - (ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_VF2PF_MSGTYPE_SHIFT)); 42 - 43 - if (test_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status)) 44 - if (adf_send_vf2pf_msg(accel_dev, msg)) 45 - dev_err(&GET_DEV(accel_dev), 46 - "Failed to send Shutdown event to PF\n"); 47 - } 48 - EXPORT_SYMBOL_GPL(adf_vf2pf_notify_shutdown); 49 - 50 - /** 51 - * adf_recv_pf2vf_msg() - receive a PF to VF message 52 - * @accel_dev: Pointer to acceleration device 53 - * 54 - * This function allows the VF to receive a message from the PF. 55 - * 56 - * Return: a valid message on success, zero otherwise. 57 - */ 58 - static u32 adf_recv_pf2vf_msg(struct adf_accel_dev *accel_dev) 59 - { 60 - return GET_PFVF_OPS(accel_dev)->recv_msg(accel_dev, 0); 61 - } 62 - 63 - static bool adf_handle_pf2vf_msg(struct adf_accel_dev *accel_dev, u32 msg) 64 - { 65 - switch ((msg & ADF_PF2VF_MSGTYPE_MASK) >> ADF_PF2VF_MSGTYPE_SHIFT) { 66 - case ADF_PF2VF_MSGTYPE_RESTARTING: 67 - dev_dbg(&GET_DEV(accel_dev), 68 - "Restarting msg received from PF 0x%x\n", msg); 69 - 70 - adf_pf2vf_handle_pf_restarting(accel_dev); 71 - return false; 72 - case ADF_PF2VF_MSGTYPE_VERSION_RESP: 73 - dev_dbg(&GET_DEV(accel_dev), 74 - "Version resp received from PF 0x%x\n", msg); 75 - accel_dev->vf.pf_version = 76 - (msg & ADF_PF2VF_VERSION_RESP_VERS_MASK) >> 77 - ADF_PF2VF_VERSION_RESP_VERS_SHIFT; 78 - accel_dev->vf.compatible = 79 - (msg & ADF_PF2VF_VERSION_RESP_RESULT_MASK) >> 80 - ADF_PF2VF_VERSION_RESP_RESULT_SHIFT; 81 - complete(&accel_dev->vf.iov_msg_completion); 82 - return true; 83 - default: 84 - dev_err(&GET_DEV(accel_dev), 85 - "Unknown PF2VF message(0x%x)\n", msg); 86 - } 87 - 88 - return false; 89 - } 90 - 91 - bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev) 92 - { 93 - u32 msg; 94 - 95 - msg = adf_recv_pf2vf_msg(accel_dev); 96 - if (msg) 97 - return adf_handle_pf2vf_msg(accel_dev, msg); 98 - 99 - return true; 100 - }
-1
drivers/crypto/qat/qat_common/adf_vf_isr.c
··· 15 15 #include "adf_cfg_common.h" 16 16 #include "adf_transport_access_macros.h" 17 17 #include "adf_transport_internal.h" 18 - #include "adf_pf2vf_msg.h" 19 18 20 19 #define ADF_VINTSOU_OFFSET 0x204 21 20 #define ADF_VINTMSK_OFFSET 0x208
+2 -2
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c
··· 1 1 // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) 2 - /* Copyright(c) 2014 - 2020 Intel Corporation */ 2 + /* Copyright(c) 2014 - 2021 Intel Corporation */ 3 3 #include <adf_accel_devices.h> 4 - #include <adf_pf2vf_msg.h> 5 4 #include <adf_common_drv.h> 6 5 #include <adf_gen2_hw_data.h> 7 6 #include <adf_gen2_pfvf.h> 7 + #include <adf_pfvf_msg.h> 8 8 #include "adf_dh895xcc_hw_data.h" 9 9 #include "icp_qat_hw.h" 10 10
+3 -2
drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c
··· 1 1 // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) 2 - /* Copyright(c) 2015 - 2020 Intel Corporation */ 2 + /* Copyright(c) 2015 - 2021 Intel Corporation */ 3 3 #include <adf_accel_devices.h> 4 - #include <adf_pf2vf_msg.h> 5 4 #include <adf_common_drv.h> 6 5 #include <adf_gen2_hw_data.h> 7 6 #include <adf_gen2_pfvf.h> 7 + #include <adf_pfvf_msg.h> 8 + #include <adf_pfvf_vf_msg.h> 8 9 #include "adf_dh895xccvf_hw_data.h" 9 10 10 11 static struct adf_hw_device_class dh895xcciov_class = {