Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
To: herbert@gondor.apana.org.au
Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com,
	marco.chiappero@intel.com,
	Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Subject: [PATCH 08/24] crypto: qat - split PFVF message decoding from handling
Date: Wed, 10 Nov 2021 20:52:01 +0000	[thread overview]
Message-ID: <20211110205217.99903-9-giovanni.cabiddu@intel.com> (raw)
In-Reply-To: <20211110205217.99903-1-giovanni.cabiddu@intel.com>

From: Marco Chiappero <marco.chiappero@intel.com>

Refactor the receive and handle logic to separate the parsing and
handling of the PFVF message from the initial retrieval and ACK.

This is to allow the intoduction of the recv function in a subsequent
patch.

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>
---
 drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 68 ++++++++++++-------
 drivers/crypto/qat/qat_common/adf_vf2pf_msg.c | 62 ++++++++---------
 2 files changed, 71 insertions(+), 59 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
index 296f54805e33..201744825e23 100644
--- a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
+++ b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
@@ -178,30 +178,12 @@ static int adf_send_vf2pf_req(struct adf_accel_dev *accel_dev, u32 msg)
 	return 0;
 }
 
-bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr)
+static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr,
+				u32 msg, u32 *response)
 {
 	struct adf_accel_vf_info *vf_info = &accel_dev->pf.vf_info[vf_nr];
 	struct adf_hw_device_data *hw_data = accel_dev->hw_device;
-	int bar_id = hw_data->get_misc_bar_id(hw_data);
-	struct adf_bar *pmisc = &GET_BARS(accel_dev)[bar_id];
-	void __iomem *pmisc_addr = pmisc->virt_addr;
-	u32 msg, resp = 0;
-
-	/* Read message from the VF */
-	msg = ADF_CSR_RD(pmisc_addr, hw_data->get_pf2vf_offset(vf_nr));
-	if (!(msg & ADF_VF2PF_INT)) {
-		dev_info(&GET_DEV(accel_dev),
-			 "Spurious VF2PF interrupt, msg %X. Ignored\n", msg);
-		return true;
-	}
-
-	if (!(msg & ADF_VF2PF_MSGORIGIN_SYSTEM))
-		/* Ignore legacy non-system (non-kernel) VF2PF messages */
-		return true;
-
-	/* To ACK, clear the VF2PFINT bit */
-	msg &= ~ADF_VF2PF_INT;
-	ADF_CSR_WR(pmisc_addr, hw_data->get_pf2vf_offset(vf_nr), msg);
+	u32 resp = 0;
 
 	switch ((msg & ADF_VF2PF_MSGTYPE_MASK) >> ADF_VF2PF_MSGTYPE_SHIFT) {
 	case ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ:
@@ -271,17 +253,51 @@ bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr)
 		}
 		break;
 	default:
-		goto err;
+		dev_dbg(&GET_DEV(accel_dev), "Unknown message from VF%d (0x%x)\n",
+			vf_nr + 1, msg);
+		return -ENOMSG;
+	}
+
+	*response = resp;
+
+	return 0;
+}
+
+bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr)
+{
+	struct adf_hw_device_data *hw_data = accel_dev->hw_device;
+	int bar_id = hw_data->get_misc_bar_id(hw_data);
+	struct adf_bar *pmisc = &GET_BARS(accel_dev)[bar_id];
+	void __iomem *pmisc_addr = pmisc->virt_addr;
+	u32 msg, resp = 0;
+
+	/* Read message from the VF */
+	msg = ADF_CSR_RD(pmisc_addr, hw_data->get_pf2vf_offset(vf_nr));
+	if (!(msg & ADF_VF2PF_INT)) {
+		dev_info(&GET_DEV(accel_dev),
+			 "Spurious VF2PF interrupt, msg %X. Ignored\n", msg);
+		return true;
+	}
+
+	/* Ignore legacy non-system (non-kernel) VF2PF messages */
+	if (!(msg & ADF_VF2PF_MSGORIGIN_SYSTEM)) {
+		dev_dbg(&GET_DEV(accel_dev),
+			"Ignored non-system message from VF%d (0x%x);\n",
+			vf_nr + 1, msg);
+		return true;
 	}
 
+	/* To ACK, clear the VF2PFINT bit */
+	msg &= ~ADF_VF2PF_INT;
+	ADF_CSR_WR(pmisc_addr, hw_data->get_pf2vf_offset(vf_nr), msg);
+
+	if (adf_handle_vf2pf_msg(accel_dev, vf_nr, msg, &resp))
+		return false;
+
 	if (resp && adf_send_pf2vf_msg(accel_dev, vf_nr, resp))
 		dev_err(&GET_DEV(accel_dev), "Failed to send response to VF\n");
 
 	return true;
-err:
-	dev_dbg(&GET_DEV(accel_dev), "Unknown message from VF%d (0x%x);\n",
-		vf_nr + 1, msg);
-	return false;
 }
 
 void adf_pf2vf_notify_restarting(struct adf_accel_dev *accel_dev)
diff --git a/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c b/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c
index e383232b0685..01a6e68f256b 100644
--- a/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c
+++ b/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c
@@ -47,6 +47,34 @@ void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev)
 }
 EXPORT_SYMBOL_GPL(adf_vf2pf_notify_shutdown);
 
+static bool adf_handle_pf2vf_msg(struct adf_accel_dev *accel_dev, u32 msg)
+{
+	switch ((msg & ADF_PF2VF_MSGTYPE_MASK) >> ADF_PF2VF_MSGTYPE_SHIFT) {
+	case ADF_PF2VF_MSGTYPE_RESTARTING:
+		dev_dbg(&GET_DEV(accel_dev),
+			"Restarting msg received from PF 0x%x\n", msg);
+
+		adf_pf2vf_handle_pf_restarting(accel_dev);
+		return false;
+	case ADF_PF2VF_MSGTYPE_VERSION_RESP:
+		dev_dbg(&GET_DEV(accel_dev),
+			"Version resp received from PF 0x%x\n", msg);
+		accel_dev->vf.pf_version =
+			(msg & ADF_PF2VF_VERSION_RESP_VERS_MASK) >>
+			ADF_PF2VF_VERSION_RESP_VERS_SHIFT;
+		accel_dev->vf.compatible =
+			(msg & ADF_PF2VF_VERSION_RESP_RESULT_MASK) >>
+			ADF_PF2VF_VERSION_RESP_RESULT_SHIFT;
+		complete(&accel_dev->vf.iov_msg_completion);
+		return true;
+	default:
+		dev_err(&GET_DEV(accel_dev),
+			"Unknown PF2VF message(0x%x)\n", msg);
+	}
+
+	return false;
+}
+
 bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev)
 {
 	struct adf_hw_device_data *hw_data = accel_dev->hw_device;
@@ -54,7 +82,6 @@ bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev)
 			&GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)];
 	void __iomem *pmisc_bar_addr = pmisc->virt_addr;
 	u32 offset = hw_data->get_pf2vf_offset(0);
-	bool ret;
 	u32 msg;
 
 	/* Read the message from PF */
@@ -73,36 +100,5 @@ bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev)
 	msg &= ~ADF_PF2VF_INT;
 	ADF_CSR_WR(pmisc_bar_addr, offset, msg);
 
-	switch ((msg & ADF_PF2VF_MSGTYPE_MASK) >> ADF_PF2VF_MSGTYPE_SHIFT) {
-	case ADF_PF2VF_MSGTYPE_RESTARTING:
-		dev_dbg(&GET_DEV(accel_dev),
-			"Restarting msg received from PF 0x%x\n", msg);
-
-		adf_pf2vf_handle_pf_restarting(accel_dev);
-		ret = false;
-		break;
-	case ADF_PF2VF_MSGTYPE_VERSION_RESP:
-		dev_dbg(&GET_DEV(accel_dev),
-			"Version resp received from PF 0x%x\n", msg);
-		accel_dev->vf.pf_version =
-			(msg & ADF_PF2VF_VERSION_RESP_VERS_MASK) >>
-			ADF_PF2VF_VERSION_RESP_VERS_SHIFT;
-		accel_dev->vf.compatible =
-			(msg & ADF_PF2VF_VERSION_RESP_RESULT_MASK) >>
-			ADF_PF2VF_VERSION_RESP_RESULT_SHIFT;
-		complete(&accel_dev->vf.iov_msg_completion);
-		ret = true;
-		break;
-	default:
-		goto err;
-	}
-
-	return ret;
-
-err:
-	dev_err(&GET_DEV(accel_dev),
-		"Unknown message from PF (0x%x); leaving PF2VF ints disabled\n",
-		msg);
-
-	return false;
+	return adf_handle_pf2vf_msg(accel_dev, msg);
 }
-- 
2.33.1


  parent reply	other threads:[~2021-11-10 20:52 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-10 20:51 [PATCH 00/24] crypto: qat - PFVF refactoring Giovanni Cabiddu
2021-11-10 20:51 ` [PATCH 01/24] crypto: qat - fix undetected PFVF timeout in ACK loop Giovanni Cabiddu
2021-11-10 20:51 ` [PATCH 02/24] crypto: qat - refactor PF top half for PFVF Giovanni Cabiddu
2021-11-10 20:51 ` [PATCH 03/24] crypto: qat - move vf2pf interrupt helpers Giovanni Cabiddu
2021-11-10 20:51 ` [PATCH 04/24] crypto: qat - move VF message handler to adf_vf2pf_msg.c Giovanni Cabiddu
2021-11-10 20:51 ` [PATCH 05/24] crypto: qat - move interrupt code out of the PFVF handler Giovanni Cabiddu
2021-11-10 20:51 ` [PATCH 06/24] crypto: qat - change PFVF ACK behaviour Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 07/24] crypto: qat - re-enable interrupts for legacy PFVF messages Giovanni Cabiddu
2021-11-10 20:52 ` Giovanni Cabiddu [this message]
2021-11-10 20:52 ` [PATCH 09/24] crypto: qat - handle retries due to collisions in adf_iov_putmsg() Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 10/24] crypto: qat - relocate PFVF PF related logic Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 11/24] crypto: qat - relocate PFVF VF " Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 12/24] crypto: qat - relocate PFVF disabled function Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 13/24] crypto: qat - add pfvf_ops Giovanni Cabiddu
2021-11-12  9:43   ` kernel test robot
2021-11-12 10:20     ` Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 14/24] crypto: qat - differentiate between pf2vf and vf2pf offset Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 15/24] crypto: qat - abstract PFVF send function Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 16/24] crypto: qat - abstract PFVF receive logic Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 17/24] crypto: qat - reorganize PFVF code Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 18/24] crypto: qat - reorganize PFVF protocol definitions Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 19/24] crypto: qat - use enums for PFVF protocol codes Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 20/24] crypto: qat - pass the PF2VF responses back to the callers Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 21/24] crypto: qat - refactor pfvf version request messages Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 22/24] crypto: qat - do not rely on min version Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 23/24] crypto: qat - fix VF IDs in PFVF log messages Giovanni Cabiddu
2021-11-10 20:52 ` [PATCH 24/24] crypto: qat - improve logging of PFVF messages Giovanni Cabiddu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211110205217.99903-9-giovanni.cabiddu@intel.com \
    --to=giovanni.cabiddu@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=marco.chiappero@intel.com \
    --cc=qat-linux@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox