crypto: qat - add VF and PF wrappers to common send function
authorMarco Chiappero <marco.chiappero@intel.com>
Tue, 28 Sep 2021 11:44:38 +0000 (12:44 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 8 Oct 2021 12:02:43 +0000 (20:02 +0800)
The send function, adf_iov_putmsg(), is shared by both PF and VF.
This commit provides two direction specific APIs, adf_send_pf2vf_msg()
and adf_send_vf2pf_msg() which decouple the implementation, which can
change and evolve over time, from the user.

With this change, the adf_iov_putmsg() is now isolated inside the file
adf_pf2vf_msg.c and has been marked as static.

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>
drivers/crypto/qat/qat_common/adf_common_drv.h
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
drivers/crypto/qat/qat_common/adf_vf2pf_msg.c

index 4261749fae8d45442f5afe5c0017d4ffdeecc788..dd82272019ecdcb2072aac87f2cf84037d1fb791 100644 (file)
@@ -62,7 +62,6 @@ int adf_dev_start(struct adf_accel_dev *accel_dev);
 void adf_dev_stop(struct adf_accel_dev *accel_dev);
 void adf_dev_shutdown(struct adf_accel_dev *accel_dev);
 
-int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr);
 void adf_pf2vf_notify_restarting(struct adf_accel_dev *accel_dev);
 int adf_enable_vf2pf_comms(struct adf_accel_dev *accel_dev);
 void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info);
@@ -200,7 +199,7 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
 void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
 void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
 void adf_schedule_vf2pf_handler(struct adf_accel_vf_info *vf_info);
-
+int adf_send_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 msg);
 int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev);
 void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev);
 int adf_init_pf_wq(void);
index 5459f295fcd9984486f447c8f732a51b2e2835c8..23bcbb2e22e2f0e8426730fd7dc75074ce7cbc2a 100644 (file)
@@ -138,7 +138,7 @@ out:
  *
  * Return: 0 on success, error code otherwise.
  */
-int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)
+static int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)
 {
        u32 count = 0;
        int ret;
@@ -152,6 +152,35 @@ int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)
        return ret;
 }
 
+/**
+ * adf_send_pf2vf_msg() - send PF to VF message
+ * @accel_dev: Pointer to acceleration device
+ * @vf_nr:     VF number to which the message will be sent
+ * @msg:       Message to send
+ *
+ * This function allows the PF to send a message to a specific VF.
+ *
+ * Return: 0 on success, error code otherwise.
+ */
+static int adf_send_pf2vf_msg(struct adf_accel_dev *accel_dev, u8 vf_nr, u32 msg)
+{
+       return adf_iov_putmsg(accel_dev, msg, vf_nr);
+}
+
+/**
+ * adf_send_vf2pf_msg() - send VF to PF message
+ * @accel_dev: Pointer to acceleration device
+ * @msg:       Message to send
+ *
+ * This function allows the VF to send a message to the PF.
+ *
+ * Return: 0 on success, error code otherwise.
+ */
+int adf_send_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 msg)
+{
+       return adf_iov_putmsg(accel_dev, msg, 0);
+}
+
 void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)
 {
        struct adf_accel_dev *accel_dev = vf_info->accel_dev;
@@ -248,7 +277,7 @@ void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)
                goto err;
        }
 
-       if (resp && adf_iov_putmsg(accel_dev, resp, vf_nr))
+       if (resp && adf_send_pf2vf_msg(accel_dev, vf_nr, resp))
                dev_err(&GET_DEV(accel_dev), "Failed to send response to VF\n");
 
 out:
@@ -269,7 +298,7 @@ void adf_pf2vf_notify_restarting(struct adf_accel_dev *accel_dev)
        int i, num_vfs = pci_num_vf(accel_to_pci_dev(accel_dev));
 
        for (i = 0, vf = accel_dev->pf.vf_info; i < num_vfs; i++, vf++) {
-               if (vf->init && adf_iov_putmsg(accel_dev, msg, i))
+               if (vf->init && adf_send_pf2vf_msg(accel_dev, i, msg))
                        dev_err(&GET_DEV(accel_dev),
                                "Failed to send restarting msg to VF%d\n", i);
        }
@@ -290,7 +319,7 @@ static int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev)
        reinit_completion(&accel_dev->vf.iov_msg_completion);
 
        /* Send request from VF to PF */
-       ret = adf_iov_putmsg(accel_dev, msg, 0);
+       ret = adf_send_vf2pf_msg(accel_dev, msg);
        if (ret) {
                dev_err(&GET_DEV(accel_dev),
                        "Failed to send Compatibility Version Request.\n");
index 3e25fac051b25f005a29cf6275fc9aa4a539f4bf..8d11bb24cea009e0576c7a2cef8477e9fe9c525d 100644 (file)
@@ -17,7 +17,7 @@ int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev)
        u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
                (ADF_VF2PF_MSGTYPE_INIT << ADF_VF2PF_MSGTYPE_SHIFT));
 
-       if (adf_iov_putmsg(accel_dev, msg, 0)) {
+       if (adf_send_vf2pf_msg(accel_dev, msg)) {
                dev_err(&GET_DEV(accel_dev),
                        "Failed to send Init event to PF\n");
                return -EFAULT;
@@ -41,7 +41,7 @@ void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev)
            (ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_VF2PF_MSGTYPE_SHIFT));
 
        if (test_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status))
-               if (adf_iov_putmsg(accel_dev, msg, 0))
+               if (adf_send_vf2pf_msg(accel_dev, msg))
                        dev_err(&GET_DEV(accel_dev),
                                "Failed to send Shutdown event to PF\n");
 }