Blob Blame History Raw
From 4d03135faa059443a2cfcbee758d9db8bada7fe1 Mon Sep 17 00:00:00 2001
From: Marco Chiappero <marco.chiappero@intel.com>
Date: Thu, 16 Dec 2021 09:13:24 +0000
Subject: [PATCH] crypto: qat - store the PFVF protocol version of the
 endpoints
Git-commit: 4d03135faa059443a2cfcbee758d9db8bada7fe1
Patch-mainline: v5.17-rc1
References: jsc#PED-1073

This patch adds an entry for storing the PFVF protocol version for both
PF and VFs. While not currently used, knowing and storing the remote
protocol version enables more complex compatibility checks and/or newer
features for compatible PFVF endpoints in the future.

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>
Signed-off-by: Torsten Duwe <duwe@suse.de>

---
 drivers/crypto/qat/qat_common/adf_accel_devices.h | 3 ++-
 drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c | 5 +++++
 drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c   | 2 +-
 drivers/crypto/qat/qat_common/adf_sriov.c         | 1 +
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_accel_devices.h b/drivers/crypto/qat/qat_common/adf_accel_devices.h
index d5ccefc041535..1fb32f3e78df6 100644
--- a/drivers/crypto/qat/qat_common/adf_accel_devices.h
+++ b/drivers/crypto/qat/qat_common/adf_accel_devices.h
@@ -249,6 +249,7 @@ struct adf_accel_vf_info {
 	struct ratelimit_state vf2pf_ratelimit;
 	u32 vf_nr;
 	bool init;
+	u8 vf_compat_ver;
 };
 
 struct adf_accel_dev {
@@ -278,7 +279,7 @@ struct adf_accel_dev {
 			struct mutex vf2pf_lock; /* protect CSR access */
 			struct completion msg_received;
 			struct pfvf_message response; /* temp field holding pf2vf response */
-			u8 pf_version;
+			u8 pf_compat_ver;
 		} vf;
 	};
 	bool is_vf;
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 8785b9d1df91a..f461aa0a95c7e 100644
--- a/drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c
+++ b/drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c
@@ -64,6 +64,8 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u8 vf_nr,
 		else
 			compat = ADF_PF2VF_VF_COMPAT_UNKNOWN;
 
+		vf_info->vf_compat_ver = vf_compat_ver;
+
 		resp->type = ADF_PF2VF_MSGTYPE_VERSION_RESP;
 		resp->data = FIELD_PREP(ADF_PF2VF_VERSION_RESP_VERS_MASK,
 					ADF_PFVF_COMPAT_THIS_VERSION) |
@@ -78,6 +80,9 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u8 vf_nr,
 			"Legacy VersionRequest received from VF%d to PF (vers 1.1)\n",
 			vf_nr);
 
+		/* legacy driver, VF compat_ver is 0 */
+		vf_info->vf_compat_ver = 0;
+
 		/* PF always newer than legacy VF */
 		compat = ADF_PF2VF_VF_COMPATIBLE;
 
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 130d7b9c12ea7..307d593042f3e 100644
--- a/drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c
+++ b/drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c
@@ -89,6 +89,6 @@ int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev)
 		return -EINVAL;
 	}
 
-	accel_dev->vf.pf_version = pf_version;
+	accel_dev->vf.pf_compat_ver = pf_version;
 	return 0;
 }
diff --git a/drivers/crypto/qat/qat_common/adf_sriov.c b/drivers/crypto/qat/qat_common/adf_sriov.c
index 429990c5e0f34..6366622ff8fd1 100644
--- a/drivers/crypto/qat/qat_common/adf_sriov.c
+++ b/drivers/crypto/qat/qat_common/adf_sriov.c
@@ -58,6 +58,7 @@ static int adf_enable_sriov(struct adf_accel_dev *accel_dev)
 		/* This ptr will be populated when VFs will be created */
 		vf_info->accel_dev = accel_dev;
 		vf_info->vf_nr = i;
+		vf_info->vf_compat_ver = 0;
 
 		mutex_init(&vf_info->pf2vf_lock);
 		ratelimit_state_init(&vf_info->vf2pf_ratelimit,
-- 
2.35.3