Skip to contentSkip to conversation

common/cnxk: add CPT HW error callback register functions

PATCH Applied Srujana Challa 2 participants 8 messages Dec 21, 2022 – Jan 31, 2023 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 common/cnxk: add CPT HW error callback register functions

Adds functions to register callback API to report CPT_MISC_INT to the driver.

---
 drivers/common/cnxk/roc_cpt.c   | 31 +++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_cpt.h   |  8 +++++++-
 drivers/common/cnxk/version.map |  2 ++
 3 files changed, 40 insertions(+), 1 deletion(-)
drivers/common/cnxk/roc_cpt.c +31 -0
index fb97ec89b2..bf0d1cff9c 100644
@@ -25,6 +25,11 @@
 #define CPT_LF_DEFAULT_NB_DESC	1024
 #define CPT_LF_FC_MIN_THRESHOLD 32
 
+static struct cpt_int_cb {
+	roc_cpt_int_misc_cb_t cb;
+	void *cb_args;
+} int_cb;
+
 static void
 cpt_lf_misc_intr_enb_dis(struct roc_cpt_lf *lf, bool enb)
 {
@@ -57,6 +62,9 @@ cpt_lf_misc_irq(void *param)
 
 	/* Clear interrupt */
 	plt_write64(intr, lf->rbase + CPT_LF_MISC_INT);
+
+	if (int_cb.cb != NULL)
+		int_cb.cb(lf, int_cb.cb_args);
 }
 
 static int
@@ -1079,3 +1087,26 @@ roc_cpt_ctx_write(struct roc_cpt_lf *lf, void *sa_dptr, void *sa_cptr,
 
 	return 0;
 }
+
+void
+roc_cpt_int_misc_cb_register(roc_cpt_int_misc_cb_t cb, void *args)
+{
+	if (int_cb.cb != NULL)
+		return;
+
+	int_cb.cb = cb;
+	int_cb.cb_args = args;
+}
+
+int
+roc_cpt_int_misc_cb_unregister(roc_cpt_int_misc_cb_t cb, void *args)
+{
+	if (int_cb.cb == NULL)
+		return 0;
+	if (int_cb.cb != cb || int_cb.cb_args != args)
+		return -EINVAL;
+
+	int_cb.cb = NULL;
+	int_cb.cb_args = NULL;
+	return 0;
+}
drivers/common/cnxk/roc_cpt.h +7 -1
index bc9cc19edd..ac8be1b475 100644
@@ -131,7 +131,7 @@ struct roc_cpt {
 	union cpt_eng_caps hw_caps[CPT_MAX_ENG_TYPES];
 	uint8_t eng_grp[CPT_MAX_ENG_TYPES];
 	uint8_t cpt_revision;
-
+	void *opaque;
 #define ROC_CPT_MEM_SZ (6 * 1024)
 	uint8_t reserved[ROC_CPT_MEM_SZ] __plt_cache_aligned;
 } __plt_cache_aligned;
@@ -144,6 +144,9 @@ struct roc_cpt_rxc_time_cfg {
 	uint16_t zombie_thres;
 };
 
+/* CPT MISC interrupt callback */
+typedef void (*roc_cpt_int_misc_cb_t)(struct roc_cpt_lf *lf, void *args);
+
 int __roc_api roc_cpt_rxc_time_cfg(struct roc_cpt *roc_cpt,
 				   struct roc_cpt_rxc_time_cfg *cfg);
 int __roc_api roc_cpt_dev_init(struct roc_cpt *roc_cpt);
@@ -174,4 +177,7 @@ int __roc_api roc_cpt_lmtline_init(struct roc_cpt *roc_cpt,
 void __roc_api roc_cpt_parse_hdr_dump(const struct cpt_parse_hdr_s *cpth);
 int __roc_api roc_cpt_ctx_write(struct roc_cpt_lf *lf, void *sa_dptr,
 				void *sa_cptr, uint16_t sa_len);
+
+void __roc_api roc_cpt_int_misc_cb_register(roc_cpt_int_misc_cb_t cb, void *args);
+int __roc_api roc_cpt_int_misc_cb_unregister(roc_cpt_int_misc_cb_t cb, void *args);
 #endif /* _ROC_CPT_H_ */
drivers/common/cnxk/version.map +2 -0
index 17f0ec6b48..d6d96dd3eb 100644
@@ -78,6 +78,8 @@ INTERNAL {
 	roc_cpt_parse_hdr_dump;
 	roc_cpt_rxc_time_cfg;
 	roc_cpt_ctx_write;
+	roc_cpt_int_misc_cb_register;
+	roc_cpt_int_misc_cb_unregister;
 	roc_dpi_configure;
 	roc_dpi_dev_fini;
 	roc_dpi_dev_init;
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/4 crypto/cnxk: add callback to report CPT HW error

Adds and register callback to report CPT MISC error interrupts to the application using rte_cryptodev_pmd_callback_process.

---
 drivers/crypto/cnxk/cnxk_cryptodev.c     | 12 ++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev.h     |  1 +
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c |  8 ++++++++
 3 files changed, 21 insertions(+)
drivers/crypto/cnxk/cnxk_cryptodev.c +12 -0
index 35635f7831..fee272d425 100644
@@ -2,6 +2,7 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <cryptodev_pmd.h>
 #include <rte_cryptodev.h>
 
 #include "roc_cpt.h"
@@ -56,3 +57,14 @@ cnxk_cpt_eng_grp_add(struct roc_cpt *roc_cpt)
 
 	return 0;
 }
+
+void
+cnxk_cpt_int_misc_cb(struct roc_cpt_lf *lf, __rte_unused void *args)
+{
+	struct roc_cpt *roc_cpt = lf->roc_cpt;
+
+	if (roc_cpt == NULL)
+		return;
+
+	rte_cryptodev_pmd_callback_process(roc_cpt->opaque, RTE_CRYPTODEV_EVENT_ERROR);
+}
drivers/crypto/cnxk/cnxk_cryptodev.h +1 -0
index 48bd6e144c..fcb1c48b5a 100644
@@ -31,5 +31,6 @@ struct cnxk_cpt_vf {
 uint64_t cnxk_cpt_default_ff_get(void);
 int cnxk_cpt_eng_grp_add(struct roc_cpt *roc_cpt);
 int cnxk_cpt_parse_devargs(struct rte_devargs *devargs, struct cnxk_cpt_vf *vf);
+void cnxk_cpt_int_misc_cb(struct roc_cpt_lf *lf, void *args);
 
 #endif /* _CNXK_CRYPTODEV_H_ */
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +8 -0
index a9c42205e6..91c7a686c2 100644
@@ -91,6 +91,9 @@ cnxk_cpt_dev_config(struct rte_cryptodev *dev,
 			return ret;
 		}
 	}
+	roc_cpt->opaque = dev;
+	/* Register callback to handle CPT_MISC_INT */
+	roc_cpt_int_misc_cb_register(cnxk_cpt_int_misc_cb, NULL);
 
 	return 0;
 }
@@ -150,6 +153,11 @@ cnxk_cpt_dev_close(struct rte_cryptodev *dev)
 		roc_ae_ec_grp_put();
 	}
 
+	ret = roc_cpt_int_misc_cb_unregister(cnxk_cpt_int_misc_cb, NULL);
+	if (ret < 0) {
+		plt_err("Could not unregister CPT_MISC_INT cb");
+		return ret;
+	}
 	roc_cpt_dev_clear(&vf->cpt);
 
 	return 0;
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/4 cryptodev: introduce query API for error interrupt event

In reply to Srujana Challa

An event RTE_CRYPTODEV_EVENT_ERROR gets fired when crypto PMD receives an error interrupt. This patch adds query function for the application, to get more info about the event.

---
 lib/cryptodev/cryptodev_pmd.h |  9 +++++++++
 lib/cryptodev/rte_cryptodev.c | 19 +++++++++++++++++++
 lib/cryptodev/rte_cryptodev.h | 19 +++++++++++++++++++
 lib/cryptodev/version.map     |  3 +++
 4 files changed, 50 insertions(+)
lib/cryptodev/cryptodev_pmd.h +9 -0
index 0020102eb7..0dfad9e24f 100644
@@ -451,6 +451,13 @@ typedef int (*cryptodev_session_event_mdata_set_t)(
 	enum rte_crypto_op_sess_type sess_type,
 	void *ev_mdata);
 
+/**
+ * @internal Query queue pair error interrupt event.
+ * @see rte_cryptodev_queue_pair_event_error_query()
+ */
+typedef int (*cryptodev_queue_pair_event_error_query_t)(struct rte_cryptodev *dev,
+					uint16_t qp_id);
+
 /** Crypto device operations function pointer table */
 struct rte_cryptodev_ops {
 	cryptodev_configure_t dev_configure;	/**< Configure device. */
@@ -497,6 +504,8 @@ struct rte_cryptodev_ops {
 	};
 	cryptodev_session_event_mdata_set_t session_ev_mdata_set;
 	/**< Set a Crypto or Security session even meta data. */
+	cryptodev_queue_pair_event_error_query_t queue_pair_event_error_query;
+	/**< Query queue error interrupt event */
 };
 
 
lib/cryptodev/rte_cryptodev.c +19 -0
index 2165a0688c..89ff66d2ba 100644
@@ -1863,6 +1863,25 @@ rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 	rte_spinlock_unlock(&rte_cryptodev_cb_lock);
 }
 
+int
+rte_cryptodev_queue_pair_event_error_query(uint8_t dev_id, uint16_t qp_id)
+{
+	struct rte_cryptodev *dev;
+
+	if (!rte_cryptodev_is_valid_dev(dev_id)) {
+		CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
+		return -EINVAL;
+	}
+	dev = &rte_crypto_devices[dev_id];
+
+	if (qp_id >= dev->data->nb_queue_pairs)
+		return -EINVAL;
+	if (*dev->dev_ops->queue_pair_event_error_query == NULL)
+		return -ENOTSUP;
+
+	return dev->dev_ops->queue_pair_event_error_query(dev, qp_id);
+}
+
 struct rte_mempool *
 rte_cryptodev_sym_session_pool_create(const char *name, uint32_t nb_elts,
 	uint32_t elt_size, uint32_t cache_size, uint16_t user_data_size,
lib/cryptodev/rte_cryptodev.h +19 -0
index 86d792e2e7..5f11a538fb 100644
@@ -871,6 +871,25 @@ rte_cryptodev_callback_unregister(uint8_t dev_id,
 		enum rte_cryptodev_event_type event,
 		rte_cryptodev_cb_fn cb_fn, void *cb_arg);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Query a cryptodev queue pair if there are pending RTE_CRYPTODEV_EVENT_ERROR
+ * events.
+ *
+ * @param          dev_id	The device identifier.
+ * @param          qp_id	Queue pair index to be queried.
+ *
+ * @return
+ *   - 1 if requested queue has a pending event.
+ *   - 0 if no pending event is found.
+ *   - a negative value on failure
+ */
+__rte_experimental
+int
+rte_cryptodev_queue_pair_event_error_query(uint8_t dev_id, uint16_t qp_id);
+
 struct rte_cryptodev_callback;
 
 /** Structure to keep track of registered callbacks */
lib/cryptodev/version.map +3 -0
index 00c99fb45c..214c91a06f 100644
@@ -150,6 +150,9 @@ EXPERIMENTAL {
 	__rte_cryptodev_trace_sym_session_get_user_data;
 	__rte_cryptodev_trace_sym_session_set_user_data;
 	__rte_cryptodev_trace_count;
+
+	# added in 23.03
+	rte_cryptodev_queue_pair_event_error_query;
 };
 
 INTERNAL {
Signature · 1 line
2.25.1
Acked-by on v1 3/4
#3 lore raw

RE: [PATCH 3/4] cryptodev: introduce query API for error interrupt event

Quoted 7 lines

Subject: [PATCH 3/4] cryptodev: introduce query API for error interrupt event

An event RTE_CRYPTODEV_EVENT_ERROR gets fired when crypto PMD receives an error interrupt. This patch adds query function for the application, to get more info about the event.

#4 lore raw

PATCH 4/4 crypto/cnxk: add error interrupt event query handler

In reply to Srujana Challa

Adds RTE_CRYPTODEV_EVENT_ERROR query handler for cn9k/cn10k PMD. The query handler finds the next queue pair ID with pending error interrupt event if any, starting from the given queue pair index, for the device.

---
 drivers/common/cnxk/roc_cpt.c             |  4 +++-
 drivers/common/cnxk/roc_cpt.h             |  1 +
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c |  1 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  |  1 +
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c  | 15 +++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h  |  1 +
 6 files changed, 22 insertions(+), 1 deletion(-)
drivers/common/cnxk/roc_cpt.c +3 -1
index bf0d1cff9c..fd7a40d6e4 100644
@@ -63,8 +63,10 @@ cpt_lf_misc_irq(void *param)
 	/* Clear interrupt */
 	plt_write64(intr, lf->rbase + CPT_LF_MISC_INT);
 
-	if (int_cb.cb != NULL)
+	if (int_cb.cb != NULL) {
+		lf->error_event_pending = 1;
 		int_cb.cb(lf, int_cb.cb_args);
+	}
 }
 
 static int
drivers/common/cnxk/roc_cpt.h +1 -0
index ac8be1b475..e9ce4cb831 100644
@@ -119,6 +119,7 @@ struct roc_cpt_lf {
 	uint64_t io_addr;
 	uint8_t *iq_vaddr;
 	struct roc_nix *inl_outb_nix;
+	uint8_t error_event_pending;
 } __plt_cache_aligned;
 
 struct roc_cpt {
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +1 -0
index 7dad370047..009d26d433 100644
@@ -1082,4 +1082,5 @@ struct rte_cryptodev_ops cn10k_cpt_ops = {
 
 	/* Event crypto ops */
 	.session_ev_mdata_set = cn10k_cpt_crypto_adapter_ev_mdata_set,
+	.queue_pair_event_error_query = cnxk_cpt_queue_pair_event_error_query,
 };
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +1 -0
index 04c004bc7a..a86d45a40c 100644
@@ -759,5 +759,6 @@ struct rte_cryptodev_ops cn9k_cpt_ops = {
 
 	/* Event crypto ops */
 	.session_ev_mdata_set = cn9k_cpt_crypto_adapter_ev_mdata_set,
+	.queue_pair_event_error_query = cnxk_cpt_queue_pair_event_error_query,
 
 };
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +15 -0
index 91c7a686c2..d8cbe5cd74 100644
@@ -806,3 +806,18 @@ cnxk_cpt_dump_on_err(struct cnxk_cpt_qp *qp)
 	plt_print("");
 	roc_cpt_afs_print(qp->lf.roc_cpt);
 }
+
+int
+cnxk_cpt_queue_pair_event_error_query(struct rte_cryptodev *dev, uint16_t qp_id)
+{
+	struct cnxk_cpt_vf *vf = dev->data->dev_private;
+	struct roc_cpt *roc_cpt = &vf->cpt;
+	struct roc_cpt_lf *lf;
+
+	lf = roc_cpt->lf[qp_id];
+	if (lf && lf->error_event_pending) {
+		lf->error_event_pending = 0;
+		return 1;
+	}
+	return 0;
+}
drivers/crypto/cnxk/cnxk_cryptodev_ops.h +1 -0
index 13c90444d6..2b25cfe1c4 100644
@@ -128,6 +128,7 @@ int cnxk_ae_session_cfg(struct rte_cryptodev *dev,
 			struct rte_crypto_asym_xform *xform,
 			struct rte_cryptodev_asym_session *sess);
 void cnxk_cpt_dump_on_err(struct cnxk_cpt_qp *qp);
+int cnxk_cpt_queue_pair_event_error_query(struct rte_cryptodev *dev, uint16_t qp_id);
 
 static __rte_always_inline void
 pending_queue_advance(uint64_t *index, const uint64_t mask)
Signature · 1 line
2.25.1
#5 lore raw

RE: [PATCH 4/4] crypto/cnxk: add error interrupt event query handler

Quoted 8 lines

Subject: [PATCH 4/4] crypto/cnxk: add error interrupt event query handler

Adds RTE_CRYPTODEV_EVENT_ERROR query handler for cn9k/cn10k PMD. The query handler finds the next queue pair ID with pending error interrupt event if any, starting from the given queue pair index, for the device.

The patch description do not match with the API added. Can you please update it?

Thanks.

#6 lore raw

RE: [PATCH 4/4] crypto/cnxk: add error interrupt event query handler

Hi Akhil,

Please find the correct description inline,

Thanks,
Srujana.

Quoted 12 lines
Quoted 9 lines

Subject: [PATCH 4/4] crypto/cnxk: add error interrupt event query handler

Adds RTE_CRYPTODEV_EVENT_ERROR query handler for cn9k/cn10k PMD. The query handler finds the next queue pair ID with pending error interrupt event if any, starting from the given queue pair index, for the device.

The patch description do not match with the API added. Can you please update it?

Adds RTE_CRYPTODEV_EVENT_ERROR query handler for cn9k/cn10k PMD. The query handler returns pending error interrupt event status for the given queue pair ID.

Quoted 1 line

Thanks.

Applied
#7 lore raw

RE: [PATCH 4/4] crypto/cnxk: add error interrupt event query handler

Quoted 17 lines

Subject: RE: [PATCH 4/4] crypto/cnxk: add error interrupt event query handler

Hi Akhil,

Please find the correct description inline,

Thanks,
Srujana.

Quoted 8 lines
Quoted 8 lines

Subject: [PATCH 4/4] crypto/cnxk: add error interrupt event query handler

Adds RTE_CRYPTODEV_EVENT_ERROR query handler for cn9k/cn10k PMD. The query handler finds the next queue pair ID with pending error interrupt event if any, starting from the given queue pair index, for the device.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

The patch description do not match with the API added. Can you please update it?

Adds RTE_CRYPTODEV_EVENT_ERROR query handler for cn9k/cn10k PMD. The query handler returns pending error interrupt event status for the given queue pair ID.

Series Acked-by: Akhil Goyal <[email protected]>

Applied to dpdk-next-crypto
Updated the description of this patch.

Thanks.