From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 4123E7CEC for ; Fri, 18 Aug 2017 17:21:01 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Aug 2017 08:20:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,393,1498546800"; d="scan'208";a="301831022" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by fmsmga004.fm.intel.com with ESMTP; 18 Aug 2017 08:20:47 -0700 From: Pablo de Lara To: declan.doherty@intel.com, jerin.jacob@caviumnetworks.com Cc: dev@dpdk.org, Pablo de Lara Date: Fri, 18 Aug 2017 08:20:57 +0100 Message-Id: <20170818072103.1416-3-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170818072103.1416-1-pablo.de.lara.guarch@intel.com> References: <20170818072103.1416-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH 2/8] crypto/armv8: do not append digest X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Aug 2017 15:21:02 -0000 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 --- 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