summaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorMarco Chiappero <marco.chiappero@intel.com>2021-12-16 09:13:21 +0000
committerHerbert Xu <herbert@gondor.apana.org.au>2021-12-24 14:18:25 +1100
commit952f4e81274131eda4ab0d751d6f2700b0356542 (patch)
treec8a24e42961d40e589ead6ea1792f3cf88e10312 /drivers/crypto
parentdb1c034801c402b1f600ef7f753494479950f78e (diff)
downloadlinux-952f4e81274131eda4ab0d751d6f2700b0356542.tar.gz
linux-952f4e81274131eda4ab0d751d6f2700b0356542.tar.bz2
linux-952f4e81274131eda4ab0d751d6f2700b0356542.zip
crypto: qat - leverage bitfield.h utils for PFVF messages
The PFVF protocol defines messages composed of a number of control bitfields. Replace all the code setting and retrieving such bits with the utilities from bitfield.h, to improve code quality and readability. 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>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/qat/qat_common/adf_pfvf_msg.h8
-rw-r--r--drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c13
-rw-r--r--drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c7
3 files changed, 14 insertions, 14 deletions
diff --git a/drivers/crypto/qat/qat_common/adf_pfvf_msg.h b/drivers/crypto/qat/qat_common/adf_pfvf_msg.h
index 26eb27853e83..daee3d7ceb8c 100644
--- a/drivers/crypto/qat/qat_common/adf_pfvf_msg.h
+++ b/drivers/crypto/qat/qat_common/adf_pfvf_msg.h
@@ -3,6 +3,8 @@
#ifndef ADF_PFVF_MSG_H
#define ADF_PFVF_MSG_H
+#include <linux/bits.h>
+
/*
* PF<->VF Messaging
* The PF has an array of 32-bit PF2VF registers, one for each VF. The
@@ -86,10 +88,8 @@ enum pfvf_compatibility_version {
};
/* PF->VF Version Response */
-#define ADF_PF2VF_VERSION_RESP_VERS_SHIFT 0
-#define ADF_PF2VF_VERSION_RESP_VERS_MASK 0xFF
-#define ADF_PF2VF_VERSION_RESP_RESULT_SHIFT 8
-#define ADF_PF2VF_VERSION_RESP_RESULT_MASK 0x03
+#define ADF_PF2VF_VERSION_RESP_VERS_MASK GENMASK(7, 0)
+#define ADF_PF2VF_VERSION_RESP_RESULT_MASK GENMASK(9, 8)
enum pf2vf_compat_response {
ADF_PF2VF_VF_COMPATIBLE = 0x01,
diff --git a/drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c b/drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c
index bb4d7db68579..8785b9d1df91 100644
--- a/drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c
+++ b/drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only)
/* Copyright(c) 2015 - 2021 Intel Corporation */
+#include <linux/bitfield.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include "adf_accel_devices.h"
@@ -64,9 +65,9 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u8 vf_nr,
compat = ADF_PF2VF_VF_COMPAT_UNKNOWN;
resp->type = ADF_PF2VF_MSGTYPE_VERSION_RESP;
- resp->data = ADF_PFVF_COMPAT_THIS_VERSION <<
- ADF_PF2VF_VERSION_RESP_VERS_SHIFT;
- resp->data |= compat << ADF_PF2VF_VERSION_RESP_RESULT_SHIFT;
+ resp->data = FIELD_PREP(ADF_PF2VF_VERSION_RESP_VERS_MASK,
+ ADF_PFVF_COMPAT_THIS_VERSION) |
+ FIELD_PREP(ADF_PF2VF_VERSION_RESP_RESULT_MASK, compat);
}
break;
case ADF_VF2PF_MSGTYPE_VERSION_REQ:
@@ -80,10 +81,10 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u8 vf_nr,
/* PF always newer than legacy VF */
compat = ADF_PF2VF_VF_COMPATIBLE;
- resp->type = ADF_PF2VF_MSGTYPE_VERSION_RESP;
/* Set legacy major and minor version to the latest, 1.1 */
- resp->data |= 0x11;
- resp->data |= compat << ADF_PF2VF_VERSION_RESP_RESULT_SHIFT;
+ resp->type = ADF_PF2VF_MSGTYPE_VERSION_RESP;
+ resp->data = FIELD_PREP(ADF_PF2VF_VERSION_RESP_VERS_MASK, 0x11) |
+ FIELD_PREP(ADF_PF2VF_VERSION_RESP_RESULT_MASK, compat);
}
break;
case ADF_VF2PF_MSGTYPE_INIT:
diff --git a/drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c b/drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c
index 5184a77598d2..130d7b9c12ea 100644
--- a/drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c
+++ b/drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only)
/* Copyright(c) 2015 - 2021 Intel Corporation */
+#include <linux/bitfield.h>
#include "adf_accel_devices.h"
#include "adf_common_drv.h"
#include "adf_pfvf_msg.h"
@@ -67,10 +68,8 @@ int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev)
return ret;
}
- pf_version = (resp.data >> ADF_PF2VF_VERSION_RESP_VERS_SHIFT)
- & ADF_PF2VF_VERSION_RESP_VERS_MASK;
- compat = (resp.data >> ADF_PF2VF_VERSION_RESP_RESULT_SHIFT)
- & ADF_PF2VF_VERSION_RESP_RESULT_MASK;
+ pf_version = FIELD_GET(ADF_PF2VF_VERSION_RESP_VERS_MASK, resp.data);
+ compat = FIELD_GET(ADF_PF2VF_VERSION_RESP_RESULT_MASK, resp.data);
/* Response from PF received, check compatibility */
switch (compat) {