DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tejasree Kondoj <ktejasree@marvell.com>
To: Akhil Goyal <gakhil@marvell.com>
Cc: Anoob Joseph <anoobj@marvell.com>,
	Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>,
	<dev@dpdk.org>
Subject: [PATCH v2 06/11] common/cnxk: ensure flush inval completion with CSR read
Date: Fri, 24 Feb 2023 15:10:09 +0530	[thread overview]
Message-ID: <20230224094014.3246764-7-ktejasree@marvell.com> (raw)
In-Reply-To: <20230224094014.3246764-1-ktejasree@marvell.com>

From: Anoob Joseph <anoobj@marvell.com>

If a CSR read is issued after a write, the read would block till the
write operation is complete. This would help in determining when the
FLUSH+INVALIDATE operation is complete.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
---
 drivers/common/cnxk/hw/cpt.h             | 11 +++++++++++
 drivers/common/cnxk/roc_cpt.c            | 16 ++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c |  4 ----
 3 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/common/cnxk/hw/cpt.h b/drivers/common/cnxk/hw/cpt.h
index d378a4eadd..44ff8b08b2 100644
--- a/drivers/common/cnxk/hw/cpt.h
+++ b/drivers/common/cnxk/hw/cpt.h
@@ -100,6 +100,17 @@ union cpt_lf_ctx_flush {
 	} s;
 };
 
+union cpt_lf_ctx_err {
+	uint64_t u;
+	struct {
+		uint64_t flush_st_flt : 1;
+		uint64_t busy_flr : 1;
+		uint64_t busy_sw_flush : 1;
+		uint64_t reload_faulted : 1;
+		uint64_t reserved_4_63 : 1;
+	} s;
+};
+
 union cpt_lf_ctx_reload {
 	uint64_t u;
 	struct {
diff --git a/drivers/common/cnxk/roc_cpt.c b/drivers/common/cnxk/roc_cpt.c
index cf514be69f..dff2fbf2a4 100644
--- a/drivers/common/cnxk/roc_cpt.c
+++ b/drivers/common/cnxk/roc_cpt.c
@@ -783,6 +783,7 @@ int
 roc_cpt_lf_ctx_flush(struct roc_cpt_lf *lf, void *cptr, bool inval)
 {
 	union cpt_lf_ctx_flush reg;
+	union cpt_lf_ctx_err err;
 
 	if (lf == NULL) {
 		plt_err("Could not trigger CTX flush");
@@ -795,6 +796,21 @@ roc_cpt_lf_ctx_flush(struct roc_cpt_lf *lf, void *cptr, bool inval)
 
 	plt_write64(reg.u, lf->rbase + CPT_LF_CTX_FLUSH);
 
+	plt_atomic_thread_fence(__ATOMIC_ACQ_REL);
+
+	/* Read a CSR to ensure that the FLUSH operation is complete */
+	err.u = plt_read64(lf->rbase + CPT_LF_CTX_ERR);
+
+	if (err.s.busy_sw_flush && inval) {
+		plt_err("CTX entry could not be invalidated due to active usage.");
+		return -EAGAIN;
+	}
+
+	if (err.s.flush_st_flt) {
+		plt_err("CTX flush could not complete due to store fault");
+		abort();
+	}
+
 	return 0;
 }
 
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c
index f03646fe1a..67bd7e3243 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c
@@ -737,8 +737,6 @@ sym_session_clear(struct rte_cryptodev_sym_session *sess, bool is_session_less)
 	/* Trigger CTX flush + invalidate to remove from CTX_CACHE */
 	roc_cpt_lf_ctx_flush(sess_priv->lf, &sess_priv->roc_se_ctx.se_ctx, true);
 
-	plt_delay_ms(1);
-
 	if (sess_priv->roc_se_ctx.auth_key != NULL)
 		plt_free(sess_priv->roc_se_ctx.auth_key);
 
@@ -767,8 +765,6 @@ cnxk_ae_session_clear(struct rte_cryptodev *dev, struct rte_cryptodev_asym_sessi
 	/* Trigger CTX flush + invalidate to remove from CTX_CACHE */
 	roc_cpt_lf_ctx_flush(priv->lf, &priv->hw_ctx, true);
 
-	plt_delay_ms(1);
-
 	/* Free resources allocated in session_cfg */
 	cnxk_ae_free_session_parameters(priv);
 
-- 
2.25.1


  parent reply	other threads:[~2023-02-24  9:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24  9:40 [PATCH v2 00/11] fixes and improvements to cnxk crypto PMD Tejasree Kondoj
2023-02-24  9:40 ` [PATCH v2 01/11] common/cnxk: fix incorrect auth key length Tejasree Kondoj
2023-02-24  9:40 ` [PATCH v2 02/11] crypto/cnxk: make sg version check const Tejasree Kondoj
2023-02-24  9:40 ` [PATCH v2 03/11] crypto/cnxk: use version field directly Tejasree Kondoj
2023-02-24  9:40 ` [PATCH v2 04/11] crypto/cnxk: use direct mode for zero aad length Tejasree Kondoj
2023-02-24  9:40 ` [PATCH v2 05/11] crypto/cnxk: set ctx for AE Tejasree Kondoj
2023-02-27 17:38   ` Akhil Goyal
2023-02-28  5:40     ` Tejasree Kondoj
2023-02-24  9:40 ` Tejasree Kondoj [this message]
2023-02-24  9:40 ` [PATCH v2 07/11] common/cnxk: add errata function for CPT set ctx Tejasree Kondoj
2023-02-24  9:40 ` [PATCH v2 08/11] common/cnxk: replace CPT revision check with caps Tejasree Kondoj
2023-02-24  9:40 ` [PATCH v2 09/11] crypto/cnxk: support cn10k IPsec SG mode Tejasree Kondoj
2023-02-24  9:40 ` [PATCH v2 10/11] crypto/cnxk: fix order of ECFPM params Tejasree Kondoj
2023-02-24  9:40 ` [PATCH v2 11/11] crypto/cnxk: add model check for pdcp chain Tejasree Kondoj
2023-03-01 12:09 ` [PATCH v2 00/11] fixes and improvements to cnxk crypto PMD Akhil Goyal

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=20230224094014.3246764-7-ktejasree@marvell.com \
    --to=ktejasree@marvell.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=gmuthukrishn@marvell.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;
as well as URLs for NNTP newsgroup(s).