All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fiona Trahe <fiona.trahe@intel.com>
To: dev@dpdk.org, pablo.de.lara.guarch@intel.com
Cc: fiona.trahe@intel.com, tomaszx.jozwiak@intel.com
Subject: [PATCH 09/30] crypto/qat: make enqueue function generic
Date: Fri,  6 Apr 2018 19:51:51 +0100	[thread overview]
Message-ID: <1523040732-3290-10-git-send-email-fiona.trahe@intel.com> (raw)
In-Reply-To: <1523040732-3290-1-git-send-email-fiona.trahe@intel.com>

Queue-handling code in enqueue is made generic, so it can
be used by other services in future. This is done by
 - Removing all sym-specific refs in input params - replace with void ptrs.
 - Wrapping this generic enqueue with the sym-specific enqueue
   called through the API.
 - Setting a fn ptr for build_request in qp on qp creation
 - Passing void * params to this, in the service-specific implementation
   qat_sym_build_request cast back to sym structs.


Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
---
 drivers/crypto/qat/qat_qp.c  |  1 +
 drivers/crypto/qat/qat_sym.c | 46 +++++++++++++++++++++++++-------------------
 drivers/crypto/qat/qat_sym.h | 11 +++++++++++
 3 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/drivers/crypto/qat/qat_qp.c b/drivers/crypto/qat/qat_qp.c
index 990cde242..74db1069c 100644
--- a/drivers/crypto/qat/qat_qp.c
+++ b/drivers/crypto/qat/qat_qp.c
@@ -216,6 +216,7 @@ int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
 	struct qat_pmd_private *internals
 		= dev->data->dev_private;
 	qp->qat_dev_gen = internals->qat_dev_gen;
+	qp->build_request = qat_sym_build_request;
 
 	dev->data->queue_pairs[queue_pair_id] = qp;
 	return 0;
diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c
index 2dfdc9cce..4e404749a 100644
--- a/drivers/crypto/qat/qat_sym.c
+++ b/drivers/crypto/qat/qat_sym.c
@@ -86,10 +86,6 @@ bpi_cipher_decrypt(uint8_t *src, uint8_t *dst,
 static inline uint32_t
 adf_modulo(uint32_t data, uint32_t shift);
 
-static inline int
-qat_sym_build_request(struct rte_crypto_op *op, uint8_t *out_msg,
-		struct qat_sym_op_cookie *qat_op_cookie, struct qat_qp *qp);
-
 static inline uint32_t
 qat_bpicipher_preprocess(struct qat_sym_session *ctx,
 				struct rte_crypto_op *op)
@@ -209,14 +205,12 @@ txq_write_tail(struct qat_qp *qp, struct qat_queue *q) {
 	q->csr_tail = q->tail;
 }
 
-uint16_t
-qat_sym_pmd_enqueue_op_burst(void *qp, struct rte_crypto_op **ops,
-		uint16_t nb_ops)
+static uint16_t
+qat_enqueue_op_burst(void *qp, void **ops, uint16_t nb_ops)
 {
 	register struct qat_queue *queue;
 	struct qat_qp *tmp_qp = (struct qat_qp *)qp;
 	register uint32_t nb_ops_sent = 0;
-	register struct rte_crypto_op **cur_op = ops;
 	register int ret;
 	uint16_t nb_ops_possible = nb_ops;
 	register uint8_t *base_addr;
@@ -242,8 +236,9 @@ qat_sym_pmd_enqueue_op_burst(void *qp, struct rte_crypto_op **ops,
 	}
 
 	while (nb_ops_sent != nb_ops_possible) {
-		ret = qat_sym_build_request(*cur_op, base_addr + tail,
-			tmp_qp->op_cookies[tail / queue->msg_size], tmp_qp);
+		ret = tmp_qp->build_request(*ops, base_addr + tail,
+				tmp_qp->op_cookies[tail / queue->msg_size],
+				tmp_qp->qat_dev_gen);
 		if (ret != 0) {
 			tmp_qp->stats.enqueue_err_count++;
 			/*
@@ -257,8 +252,8 @@ qat_sym_pmd_enqueue_op_burst(void *qp, struct rte_crypto_op **ops,
 		}
 
 		tail = adf_modulo(tail + queue->msg_size, queue->modulo);
+		ops++;
 		nb_ops_sent++;
-		cur_op++;
 	}
 kick_tail:
 	queue->tail = tail;
@@ -299,6 +294,13 @@ void rxq_free_desc(struct qat_qp *qp, struct qat_queue *q)
 }
 
 uint16_t
+qat_sym_pmd_enqueue_op_burst(void *qp, struct rte_crypto_op **ops,
+		uint16_t nb_ops)
+{
+	return qat_enqueue_op_burst(qp, (void **)ops, nb_ops);
+}
+
+uint16_t
 qat_sym_pmd_dequeue_op_burst(void *qp, struct rte_crypto_op **ops,
 		uint16_t nb_ops)
 {
@@ -456,9 +458,10 @@ set_cipher_iv_ccm(uint16_t iv_length, uint16_t iv_offset,
 			iv_length);
 }
 
-static inline int
-qat_sym_build_request(struct rte_crypto_op *op, uint8_t *out_msg,
-		struct qat_sym_op_cookie *qat_op_cookie, struct qat_qp *qp)
+
+int
+qat_sym_build_request(void *in_op, uint8_t *out_msg,
+		void *op_cookie, enum qat_device_gen qat_dev_gen)
 {
 	int ret = 0;
 	struct qat_sym_session *ctx;
@@ -471,6 +474,9 @@ qat_sym_build_request(struct rte_crypto_op *op, uint8_t *out_msg,
 	uint32_t min_ofs = 0;
 	uint64_t src_buf_start = 0, dst_buf_start = 0;
 	uint8_t do_sgl = 0;
+	struct rte_crypto_op *op = (struct rte_crypto_op *)in_op;
+	struct qat_sym_op_cookie *cookie =
+				(struct qat_sym_op_cookie *)op_cookie;
 
 #ifdef RTE_LIBRTE_PMD_QAT_DEBUG_TX
 	if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) {
@@ -494,7 +500,7 @@ qat_sym_build_request(struct rte_crypto_op *op, uint8_t *out_msg,
 		return -EINVAL;
 	}
 
-	if (unlikely(ctx->min_qat_dev_gen > qp->qat_dev_gen)) {
+	if (unlikely(ctx->min_qat_dev_gen > qat_dev_gen)) {
 		PMD_DRV_LOG(ERR, "Session alg not supported on this device gen");
 		op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
 		return -EINVAL;
@@ -807,7 +813,7 @@ qat_sym_build_request(struct rte_crypto_op *op, uint8_t *out_msg,
 		ICP_QAT_FW_COMN_PTR_TYPE_SET(qat_req->comn_hdr.comn_req_flags,
 				QAT_COMN_PTR_TYPE_SGL);
 		ret = qat_sgl_fill_array(op->sym->m_src, src_buf_start,
-				&qat_op_cookie->qat_sgl_list_src,
+				&cookie->qat_sgl_list_src,
 				qat_req->comn_mid.src_length);
 		if (ret) {
 			PMD_DRV_LOG(ERR, "QAT PMD Cannot fill sgl array");
@@ -817,11 +823,11 @@ qat_sym_build_request(struct rte_crypto_op *op, uint8_t *out_msg,
 		if (likely(op->sym->m_dst == NULL))
 			qat_req->comn_mid.dest_data_addr =
 				qat_req->comn_mid.src_data_addr =
-				qat_op_cookie->qat_sgl_src_phys_addr;
+				cookie->qat_sgl_src_phys_addr;
 		else {
 			ret = qat_sgl_fill_array(op->sym->m_dst,
 					dst_buf_start,
-					&qat_op_cookie->qat_sgl_list_dst,
+					&cookie->qat_sgl_list_dst,
 						qat_req->comn_mid.dst_length);
 
 			if (ret) {
@@ -831,9 +837,9 @@ qat_sym_build_request(struct rte_crypto_op *op, uint8_t *out_msg,
 			}
 
 			qat_req->comn_mid.src_data_addr =
-				qat_op_cookie->qat_sgl_src_phys_addr;
+				cookie->qat_sgl_src_phys_addr;
 			qat_req->comn_mid.dest_data_addr =
-					qat_op_cookie->qat_sgl_dst_phys_addr;
+					cookie->qat_sgl_dst_phys_addr;
 		}
 	} else {
 		qat_req->comn_mid.src_data_addr = src_buf_start;
diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h
index 18c77ea11..b1ddb6e93 100644
--- a/drivers/crypto/qat/qat_sym.h
+++ b/drivers/crypto/qat/qat_sym.h
@@ -27,6 +27,11 @@
 #define QAT_CSR_TAIL_FORCE_WRITE_THRESH 256U
 /* number of inflights below which no tail write coalescing should occur */
 
+typedef int (*build_request_t)(void *op,
+		uint8_t *req, void *op_cookie,
+		enum qat_device_gen qat_dev_gen);
+/**< Build a request from an op. */
+
 struct qat_sym_session;
 
 /**
@@ -63,8 +68,14 @@ struct qat_qp {
 	void **op_cookies;
 	uint32_t nb_descriptors;
 	enum qat_device_gen qat_dev_gen;
+	build_request_t build_request;
 } __rte_cache_aligned;
 
+
+int
+qat_sym_build_request(void *in_op, uint8_t *out_msg,
+		void *op_cookie, enum qat_device_gen qat_dev_gen);
+
 void qat_sym_stats_get(struct rte_cryptodev *dev,
 	struct rte_cryptodev_stats *stats);
 void qat_sym_stats_reset(struct rte_cryptodev *dev);
-- 
2.13.6

  parent reply	other threads:[~2018-04-06 18:52 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06 18:51 [PATCH 00/30] crypto/qat: refactor to support multiple service Fiona Trahe
2018-04-06 18:51 ` [PATCH 01/30] crypto/qat: use SPDX license Fiona Trahe
2018-04-18  8:03   ` De Lara Guarch, Pablo
2018-04-06 18:51 ` [PATCH 02/30] crypto/qat: add qat common header Fiona Trahe
2018-04-06 18:51 ` [PATCH 03/30] crypto/qat: add qat device files Fiona Trahe
2018-04-06 18:51 ` [PATCH 04/30] crypto/qat: remove unused includes Fiona Trahe
2018-04-06 18:51 ` [PATCH 05/30] crypto/qat: add symmetric session file Fiona Trahe
2018-04-06 18:51 ` [PATCH 06/30] crypto/qat: change filename crypto to sym Fiona Trahe
2018-04-06 18:51 ` [PATCH 07/30] crypto/qat: rename fns for consistency Fiona Trahe
2018-04-06 18:51 ` [PATCH 08/30] crypto/qat: renamed sym-specific structs Fiona Trahe
2018-04-06 18:51 ` Fiona Trahe [this message]
2018-04-06 18:51 ` [PATCH 10/30] crypto/qat: make dequeue function generic Fiona Trahe
2018-04-06 18:51 ` [PATCH 11/30] crypto/qat: move generic qp fn to qp file Fiona Trahe
2018-04-06 18:51 ` [PATCH 12/30] crypto/qat: separate sym-specific from generic qp setup Fiona Trahe
2018-04-06 18:51 ` [PATCH 13/30] crypto/qat: move sym-specific qp code to sym file Fiona Trahe
2018-04-06 18:51 ` [PATCH 14/30] crypto/qat: remove dependencies on cryptodev from common Fiona Trahe
2018-04-06 18:51 ` [PATCH 15/30] crypto/qat: move defines from sym to qp header file Fiona Trahe
2018-04-06 18:51 ` [PATCH 16/30] crypto/qat: create data structures to support different generations Fiona Trahe
2018-04-06 18:51 ` [PATCH 17/30] crypto/qat: rename sgl related objects Fiona Trahe
2018-04-06 18:52 ` [PATCH 18/30] crypto/qat: move sgl related element to appropriate files Fiona Trahe
2018-04-06 18:52 ` [PATCH 19/30] crypto/qat: add QAT PCI device struct Fiona Trahe
2018-04-06 18:52 ` [PATCH 20/30] crypto/qat: separate the name used for PCI reg from crypto name Fiona Trahe
2018-04-06 18:52 ` [PATCH 21/30] crypto/qat: move to using new device structure Fiona Trahe
2018-04-06 18:52 ` [PATCH 22/30] crypto/qat: use common stats structures Fiona Trahe
2018-04-06 18:52 ` [PATCH 23/30] crypto/qat: rename functions which depend on cryptodev Fiona Trahe
2018-04-06 18:52 ` [PATCH 24/30] crypto/qat: move code into appropriate files Fiona Trahe
2018-04-06 18:52 ` [PATCH 25/30] crypto/qat: add lock around csr access and change logic Fiona Trahe
2018-04-06 18:52 ` [PATCH 26/30] crypto/qat: remove incorrect usage of bundle number Fiona Trahe
2018-04-06 18:52 ` [PATCH 27/30] crypto/qat: cleanups Fiona Trahe
2018-04-06 18:52 ` [PATCH 28/30] crypto/qat: create appropriately named device for registration Fiona Trahe
2018-04-06 18:52 ` [PATCH 29/30] crypto/qat: add MAX PCI DEVICES flag to config file Fiona Trahe
2018-04-06 18:52 ` [PATCH 30/30] crypto/qat: add performance improvement into qat crypto dev Fiona Trahe
2018-04-11 12:41 ` [PATCH 00/30] crypto/qat: refactor to support multiple service De Lara Guarch, Pablo
2018-05-11 11:13 ` [PATCH v2 00/31] crypto/qat: refactor to support multiple Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 01/31] crypto/qat: add qat common header Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 02/31] crypto/qat: add qat device files Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 03/31] crypto/qat: remove unused includes Fiona Trahe
2018-06-11 22:20   ` De Lara Guarch, Pablo
2018-05-11 11:13 ` [PATCH v2 04/31] crypto/qat: add symmetric session file Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 05/31] crypto/qat: change filename crypto to sym Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 06/31] crypto/qat: rename fns for consistency Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 07/31] crypto/qat: renamed sym-specific structs Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 08/31] crypto/qat: make enqueue function generic Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 09/31] crypto/qat: make dequeue " Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 10/31] crypto/qat: move generic qp fn to qp file Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 11/31] crypto/qat: separate sym-specific from generic qp setup Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 12/31] crypto/qat: move sym-specific qp code to sym file Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 13/31] crypto/qat: remove dependencies on cryptodev from common Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 14/31] crypto/qat: move defines from sym to qp header file Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 15/31] crypto/qat: create data structures to support different generations Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 16/31] crypto/qat: rename sgl related objects Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 17/31] crypto/qat: move sgl related element to appropriate files Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 18/31] crypto/qat: add QAT PCI device struct Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 19/31] crypto/qat: separate the name used for PCI reg from crypto name Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 20/31] crypto/qat: move to using new device structure Fiona Trahe
2018-05-11 11:13 ` [PATCH v2 21/31] crypto/qat: use common stats structures Fiona Trahe
2018-05-11 11:14 ` [PATCH v2 22/31] crypto/qat: rename functions which depend on cryptodev Fiona Trahe
2018-05-11 11:14 ` [PATCH v2 23/31] crypto/qat: move code into appropriate files Fiona Trahe
2018-05-11 11:14 ` [PATCH v2 24/31] crypto/qat: add lock around csr access and change logic Fiona Trahe
2018-05-11 11:14 ` [PATCH v2 25/31] crypto/qat: remove incorrect usage of bundle number Fiona Trahe
2018-05-11 11:14 ` [PATCH v2 26/31] crypto/qat: cleanups Fiona Trahe
2018-06-11 22:21   ` De Lara Guarch, Pablo
2018-05-11 11:14 ` [PATCH v2 27/31] crypto/qat: create appropriately named device for registration Fiona Trahe
2018-05-11 11:14 ` [PATCH v2 28/31] crypto/qat: add MAX PCI DEVICES flag to config file Fiona Trahe
2018-05-11 11:14 ` [PATCH v2 29/31] crypto/qat: add performance improvement into qat crypto dev Fiona Trahe
2018-06-11 22:23   ` De Lara Guarch, Pablo
2018-05-11 11:14 ` [PATCH v2 30/31] doc/qat: specify QAT driver and device name formats Fiona Trahe
2018-05-14 15:38   ` Kovacevic, Marko
2018-05-11 11:14 ` [PATCH v2 31/31] crypto/qat: remove CONFIG_RTE_QAT_PMD_MAX_NB_SESSIONS Fiona Trahe
2018-06-13 12:13 ` [PATCH v3 00/38] crypto/qat: refactor to support multiple services Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 01/38] crypto/qat: add qat common header Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 02/38] crypto/qat: add qat device files Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 03/38] crypto/qat: remove unused includes Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 04/38] crypto/qat: add symmetric session file Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 05/38] crypto/qat: change filename crypto to sym Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 06/38] crypto/qat: rename fns for consistency Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 07/38] crypto/qat: renamed sym-specific structs Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 08/38] crypto/qat: make enqueue function generic Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 09/38] crypto/qat: make dequeue " Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 10/38] crypto/qat: move generic qp fn to qp file Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 11/38] crypto/qat: separate sym-specific from generic qp setup Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 12/38] crypto/qat: move sym-specific qp code to sym file Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 13/38] crypto/qat: remove dependencies on cryptodev from common Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 14/38] crypto/qat: move defines from sym to qp header file Tomasz Jozwiak
2018-06-13 12:13   ` [PATCH v3 15/38] crypto/qat: create structures to support various generations Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 16/38] crypto/qat: rename sgl related objects Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 17/38] crypto/qat: move sgl related element to appropriate files Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 18/38] crypto/qat: add QAT PCI device struct Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 19/38] crypto/qat: use generic driver name for PCI registration Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 20/38] crypto/qat: move to using new device structure Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 21/38] crypto/qat: use common stats structures Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 22/38] crypto/qat: rename functions which depend on cryptodev Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 23/38] crypto/qat: move code into appropriate files Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 24/38] crypto/qat: add lock around csr access and change logic Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 25/38] crypto/qat: remove incorrect usage of bundle number Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 26/38] crypto/qat: rename variables Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 27/38] crypto/qat: modify debug message Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 28/38] crypto/qat: free cookie pool on queue creation error Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 29/38] crypto/qat: remove unused macro Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 30/38] crypto/qat: move macro to common file Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 31/38] crypto/qat: register appropriately named device Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 32/38] crypto/qat: add max PCI devices to config file Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 33/38] crypto/qat: optimize adf modulo function Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 34/38] crypto/qat: remove unused arguments Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 35/38] crypto/qat: make response process function inline Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 36/38] crypto/qat: check for service type Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 37/38] doc/qat: specify QAT driver and device name formats Tomasz Jozwiak
2018-06-13 12:14   ` [PATCH v3 38/38] crypto/qat: remove configurable max number of sessions Tomasz Jozwiak
2018-06-14 10:59   ` [PATCH v3 00/38] crypto/qat: refactor to support multiple services De Lara Guarch, Pablo

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=1523040732-3290-10-git-send-email-fiona.trahe@intel.com \
    --to=fiona.trahe@intel.com \
    --cc=dev@dpdk.org \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=tomaszx.jozwiak@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.