DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: declan.doherty@intel.com, jerin.jacob@caviumnetworks.com
Cc: dev@dpdk.org, Pablo de Lara <pablo.de.lara.guarch@intel.com>
Subject: [dpdk-dev] [PATCH 2/8] crypto/armv8: do not append digest
Date: Fri, 18 Aug 2017 08:20:57 +0100	[thread overview]
Message-ID: <20170818072103.1416-3-pablo.de.lara.guarch@intel.com> (raw)
In-Reply-To: <20170818072103.1416-1-pablo.de.lara.guarch@intel.com>

When performing an authentication verification,
the PMD was using memory at the end of the input buffer,
to store temporarily the digest.
This operation requires the buffer to have enough
tailroom unnecessarily.
Instead, memory is allocated for each queue pair, to store
temporarily the digest generated by the driver, so it can
be compared with the one provided in the crypto operation,
without needing to touch the input buffer.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/crypto/armv8/rte_armv8_pmd.c         | 14 +++++---------
 drivers/crypto/armv8/rte_armv8_pmd_private.h |  8 ++++++++
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c
index a5c39c9..6f6d053 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd.c
@@ -575,8 +575,8 @@ get_session(struct armv8_crypto_qp *qp, struct rte_crypto_op *op)
 
 /** Process cipher operation */
 static inline void
-process_armv8_chained_op
-		(struct rte_crypto_op *op, struct armv8_crypto_session *sess,
+process_armv8_chained_op(struct armv8_crypto_qp *qp, struct rte_crypto_op *op,
+		struct armv8_crypto_session *sess,
 		struct rte_mbuf *mbuf_src, struct rte_mbuf *mbuf_dst)
 {
 	crypto_func_t crypto_func;
@@ -633,8 +633,7 @@ process_armv8_chained_op
 					op->sym->auth.data.length);
 		}
 	} else {
-		adst = (uint8_t *)rte_pktmbuf_append(m_asrc,
-				sess->auth.digest_length);
+		adst = (uint8_t *)&qp->temp_digest;
 	}
 
 	arg.cipher.iv = rte_crypto_op_ctod_offset(op, uint8_t *,
@@ -655,15 +654,12 @@ process_armv8_chained_op
 				sess->auth.digest_length) != 0) {
 			op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
 		}
-		/* Trim area used for digest from mbuf. */
-		rte_pktmbuf_trim(m_asrc,
-				sess->auth.digest_length);
 	}
 }
 
 /** Process crypto operation for mbuf */
 static inline int
-process_op(const struct armv8_crypto_qp *qp, struct rte_crypto_op *op,
+process_op(struct armv8_crypto_qp *qp, struct rte_crypto_op *op,
 		struct armv8_crypto_session *sess)
 {
 	struct rte_mbuf *msrc, *mdst;
@@ -676,7 +672,7 @@ process_op(const struct armv8_crypto_qp *qp, struct rte_crypto_op *op,
 	switch (sess->chain_order) {
 	case ARMV8_CRYPTO_CHAIN_CIPHER_AUTH:
 	case ARMV8_CRYPTO_CHAIN_AUTH_CIPHER: /* Fall through */
-		process_armv8_chained_op(op, sess, msrc, mdst);
+		process_armv8_chained_op(qp, op, sess, msrc, mdst);
 		break;
 	default:
 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
diff --git a/drivers/crypto/armv8/rte_armv8_pmd_private.h b/drivers/crypto/armv8/rte_armv8_pmd_private.h
index d02992a..fa31f0a 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd_private.h
+++ b/drivers/crypto/armv8/rte_armv8_pmd_private.h
@@ -69,6 +69,9 @@ do {								\
 #define NBBY		8		/* Number of bits in a byte */
 #define BYTE_LENGTH(x)	((x) / NBBY)	/* Number of bytes in x (round down) */
 
+/* Maximum length for digest (SHA-256 needs 32 bytes) */
+#define DIGEST_LENGTH_MAX 32
+
 /** ARMv8 operation order mode enumerator */
 enum armv8_crypto_chain_order {
 	ARMV8_CRYPTO_CHAIN_CIPHER_AUTH,
@@ -147,6 +150,11 @@ struct armv8_crypto_qp {
 	/**< Queue pair statistics */
 	char name[RTE_CRYPTODEV_NAME_LEN];
 	/**< Unique Queue Pair Name */
+	uint8_t temp_digest[DIGEST_LENGTH_MAX];
+	/**< Buffer used to store the digest generated
+	 * by the driver when verifying a digest provided
+	 * by the user (using authentication verify operation)
+	 */
 } __rte_cache_aligned;
 
 /** ARMv8 crypto private session structure */
-- 
2.9.4

  parent reply	other threads:[~2017-08-18 15:21 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-18  7:20 [dpdk-dev] [PATCH 0/8] Remove temporary digest allocation Pablo de Lara
2017-08-18  7:20 ` [dpdk-dev] [PATCH 1/8] crypto/aesni_gcm: do not append digest Pablo de Lara
2017-09-04 10:07   ` Zhang, Roy Fan
2017-09-05  8:49     ` De Lara Guarch, Pablo
2017-08-18  7:20 ` Pablo de Lara [this message]
2017-09-11  5:22   ` [dpdk-dev] [PATCH 2/8] crypto/armv8: " Jerin Jacob
2017-08-18  7:20 ` [dpdk-dev] [PATCH 3/8] crypto/openssl: " Pablo de Lara
2017-08-18  7:20 ` [dpdk-dev] [PATCH 4/8] crypto/kasumi: " Pablo de Lara
2017-08-18  7:21 ` [dpdk-dev] [PATCH 5/8] crypto/snow3g: " Pablo de Lara
2017-08-18  7:21 ` [dpdk-dev] [PATCH 6/8] crypto/zuc: " Pablo de Lara
2017-08-18  7:21 ` [dpdk-dev] [PATCH 7/8] crypto/aesni_mb: " Pablo de Lara
2017-08-18  7:21 ` [dpdk-dev] [PATCH 8/8] test/crypto: do not allocate extra memory for digest Pablo de Lara
2017-09-05  2:19 ` [dpdk-dev] [PATCH v2 0/8] Remove temporary digest allocation Pablo de Lara
2017-09-05  2:20   ` [dpdk-dev] [PATCH v2 1/8] crypto/aesni_gcm: do not append digest Pablo de Lara
2017-09-05  2:20   ` [dpdk-dev] [PATCH v2 2/8] crypto/armv8: " Pablo de Lara
2017-09-06  9:02     ` De Lara Guarch, Pablo
2017-09-05  2:20   ` [dpdk-dev] [PATCH v2 3/8] crypto/openssl: " Pablo de Lara
2017-09-05  2:20   ` [dpdk-dev] [PATCH v2 4/8] crypto/kasumi: " Pablo de Lara
2017-09-05  2:20   ` [dpdk-dev] [PATCH v2 5/8] crypto/snow3g: " Pablo de Lara
2017-09-05  2:20   ` [dpdk-dev] [PATCH v2 6/8] crypto/zuc: " Pablo de Lara
2017-09-05  2:20   ` [dpdk-dev] [PATCH v2 7/8] crypto/aesni_mb: " Pablo de Lara
2017-09-05  2:20   ` [dpdk-dev] [PATCH v2 8/8] test/crypto: do not allocate extra memory for digest Pablo de Lara
2017-09-05 12:38   ` [dpdk-dev] [PATCH v2 0/8] Remove temporary digest allocation Zhang, Roy Fan
2017-09-11  9:39     ` 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=20170818072103.1416-3-pablo.de.lara.guarch@intel.com \
    --to=pablo.de.lara.guarch@intel.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=jerin.jacob@caviumnetworks.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).