Merge tag 'dt-5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-microblaze.git] / 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_iov_putmsg(accel_dev, msg, 0)) {
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_iov_putmsg(accel_dev, msg, 0))
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);