OSDN Git Service

crypto: qat - set PFVF_MSGORIGIN just before sending
authorMarco Chiappero <marco.chiappero@intel.com>
Thu, 16 Dec 2021 09:13:19 +0000 (09:13 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 24 Dec 2021 03:18:25 +0000 (14:18 +1100)
In this implementation of the PFVF protocol every egressing message must
include the ADF_PFVF_MSGORIGIN_SYSTEM flag. However, this flag can be set
on all the outbound messages just before sending them rather than at
message build time, as currently done.

Remove the unnecessary code duplication by setting the
ADF_PFVF_MSGORIGIN_SYSTEM flag only once at send time in
adf_gen2_pfvf_send().

Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Fiona Trahe <fiona.trahe@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c
drivers/crypto/qat/qat_common/adf_pfvf_pf_msg.c
drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c
drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c

index 1e45f32..97bef41 100644 (file)
@@ -149,6 +149,7 @@ static int adf_gen2_pfvf_send(struct adf_accel_dev *accel_dev, u32 msg,
        /* Pre-calculate message, shifting it in place and setting
         * the in use pattern
         */
+       msg |= ADF_PFVF_MSGORIGIN_SYSTEM;
        msg = gen2_csr_msg_to_position(msg, local_offset);
        gen2_csr_set_in_use(&msg, remote_offset);
 
index 4057d7d..f6d05cd 100644 (file)
@@ -9,8 +9,7 @@
 void adf_pf2vf_notify_restarting(struct adf_accel_dev *accel_dev)
 {
        struct adf_accel_vf_info *vf;
-       u32 msg = (ADF_PFVF_MSGORIGIN_SYSTEM |
-               (ADF_PF2VF_MSGTYPE_RESTARTING << ADF_PFVF_MSGTYPE_SHIFT));
+       u32 msg = ADF_PF2VF_MSGTYPE_RESTARTING << ADF_PFVF_MSGTYPE_SHIFT;
        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++) {
index 4e4daec..9f4baa9 100644 (file)
@@ -64,7 +64,6 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr,
                else
                        compat = ADF_PF2VF_VF_COMPAT_UNKNOWN;
 
-               resp =  ADF_PFVF_MSGORIGIN_SYSTEM;
                resp |= ADF_PF2VF_MSGTYPE_VERSION_RESP <<
                        ADF_PFVF_MSGTYPE_SHIFT;
                resp |= ADF_PFVF_COMPAT_THIS_VERSION <<
@@ -83,7 +82,6 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr,
                /* PF always newer than legacy VF */
                compat = ADF_PF2VF_VF_COMPATIBLE;
 
-               resp = ADF_PFVF_MSGORIGIN_SYSTEM;
                resp |= ADF_PF2VF_MSGTYPE_VERSION_RESP <<
                        ADF_PFVF_MSGTYPE_SHIFT;
                /* Set legacy major and minor version num */
index c9e9296..0463743 100644 (file)
@@ -16,8 +16,7 @@
  */
 int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev)
 {
-       u32 msg = (ADF_PFVF_MSGORIGIN_SYSTEM |
-               (ADF_VF2PF_MSGTYPE_INIT << ADF_PFVF_MSGTYPE_SHIFT));
+       u32 msg = ADF_VF2PF_MSGTYPE_INIT << ADF_PFVF_MSGTYPE_SHIFT;
 
        if (adf_send_vf2pf_msg(accel_dev, msg)) {
                dev_err(&GET_DEV(accel_dev),
@@ -39,8 +38,7 @@ EXPORT_SYMBOL_GPL(adf_vf2pf_notify_init);
  */
 void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev)
 {
-       u32 msg = (ADF_PFVF_MSGORIGIN_SYSTEM |
-           (ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_PFVF_MSGTYPE_SHIFT));
+       u32 msg = ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_PFVF_MSGTYPE_SHIFT;
 
        if (test_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status))
                if (adf_send_vf2pf_msg(accel_dev, msg))
@@ -57,9 +55,9 @@ int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev)
        u32 resp;
        int ret;
 
-       msg = ADF_PFVF_MSGORIGIN_SYSTEM;
-       msg |= ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ << ADF_PFVF_MSGTYPE_SHIFT;
-       msg |= ADF_PFVF_COMPAT_THIS_VERSION << ADF_VF2PF_COMPAT_VER_REQ_SHIFT;
+       msg = ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ << ADF_PFVF_MSGTYPE_SHIFT |
+             ADF_PFVF_COMPAT_THIS_VERSION << ADF_VF2PF_COMPAT_VER_REQ_SHIFT;
+
        BUILD_BUG_ON(ADF_PFVF_COMPAT_THIS_VERSION > 255);
 
        ret = adf_send_vf2pf_req(accel_dev, msg, &resp);