From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 1F89E7CAA for ; Tue, 5 Sep 2017 12:19:59 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Sep 2017 03:19:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,479,1498546800"; d="scan'208";a="125667057" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by orsmga004.jf.intel.com with ESMTP; 05 Sep 2017 03:19:58 -0700 From: Pablo de Lara To: declan.doherty@intel.com, roy.fan.zhang@intel.com, jerin.jacob@caviumnetworks.com Cc: dev@dpdk.org, Pablo de Lara Date: Tue, 5 Sep 2017 03:20:04 +0100 Message-Id: <20170905022007.55749-6-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170905022007.55749-1-pablo.de.lara.guarch@intel.com> References: <20170818072103.1416-1-pablo.de.lara.guarch@intel.com> <20170905022007.55749-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v2 5/8] crypto/snow3g: 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: Tue, 05 Sep 2017 10:20:00 -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/snow3g/rte_snow3g_pmd.c | 22 ++++++++-------------- drivers/crypto/snow3g/rte_snow3g_pmd_private.h | 7 +++++++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c index dad4506..15f9381 100644 --- a/drivers/crypto/snow3g/rte_snow3g_pmd.c +++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c @@ -43,7 +43,6 @@ #include "rte_snow3g_pmd_private.h" #define SNOW3G_IV_LENGTH 16 -#define SNOW3G_DIGEST_LENGTH 4 #define SNOW3G_MAX_BURST 8 #define BYTE_LEN 8 @@ -263,7 +262,7 @@ process_snow3g_cipher_op_bit(struct rte_crypto_op *op, /** Generate/verify hash from mbufs with same hash key. */ static int -process_snow3g_hash_op(struct rte_crypto_op **ops, +process_snow3g_hash_op(struct snow3g_qp *qp, struct rte_crypto_op **ops, struct snow3g_session *session, uint8_t num_ops) { @@ -289,8 +288,7 @@ process_snow3g_hash_op(struct rte_crypto_op **ops, session->auth_iv_offset); if (session->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY) { - dst = (uint8_t *)rte_pktmbuf_append(ops[i]->sym->m_src, - SNOW3G_DIGEST_LENGTH); + dst = qp->temp_digest; sso_snow3g_f9_1_buffer(&session->pKeySched_hash, iv, src, @@ -299,10 +297,6 @@ process_snow3g_hash_op(struct rte_crypto_op **ops, if (memcmp(dst, ops[i]->sym->auth.digest.data, SNOW3G_DIGEST_LENGTH) != 0) ops[i]->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED; - - /* Trim area used for digest from mbuf. */ - rte_pktmbuf_trim(ops[i]->sym->m_src, - SNOW3G_DIGEST_LENGTH); } else { dst = ops[i]->sym->auth.digest.data; @@ -346,16 +340,16 @@ process_ops(struct rte_crypto_op **ops, struct snow3g_session *session, session, num_ops); break; case SNOW3G_OP_ONLY_AUTH: - processed_ops = process_snow3g_hash_op(ops, session, + processed_ops = process_snow3g_hash_op(qp, ops, session, num_ops); break; case SNOW3G_OP_CIPHER_AUTH: processed_ops = process_snow3g_cipher_op(ops, session, num_ops); - process_snow3g_hash_op(ops, session, processed_ops); + process_snow3g_hash_op(qp, ops, session, processed_ops); break; case SNOW3G_OP_AUTH_CIPHER: - processed_ops = process_snow3g_hash_op(ops, session, + processed_ops = process_snow3g_hash_op(qp, ops, session, num_ops); process_snow3g_cipher_op(ops, session, processed_ops); break; @@ -403,15 +397,15 @@ process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session, session); break; case SNOW3G_OP_ONLY_AUTH: - processed_op = process_snow3g_hash_op(&op, session, 1); + processed_op = process_snow3g_hash_op(qp, &op, session, 1); break; case SNOW3G_OP_CIPHER_AUTH: processed_op = process_snow3g_cipher_op_bit(op, session); if (processed_op == 1) - process_snow3g_hash_op(&op, session, 1); + process_snow3g_hash_op(qp, &op, session, 1); break; case SNOW3G_OP_AUTH_CIPHER: - processed_op = process_snow3g_hash_op(&op, session, 1); + processed_op = process_snow3g_hash_op(qp, &op, session, 1); if (processed_op == 1) process_snow3g_cipher_op_bit(op, session); break; diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd_private.h b/drivers/crypto/snow3g/rte_snow3g_pmd_private.h index fba3cb8..7b9729f 100644 --- a/drivers/crypto/snow3g/rte_snow3g_pmd_private.h +++ b/drivers/crypto/snow3g/rte_snow3g_pmd_private.h @@ -58,6 +58,8 @@ #define SNOW3G_LOG_DBG(fmt, args...) #endif +#define SNOW3G_DIGEST_LENGTH 4 + /** private data structure for each virtual SNOW 3G device */ struct snow3g_private { unsigned max_nb_queue_pairs; @@ -78,6 +80,11 @@ struct snow3g_qp { /**< Session Mempool */ struct rte_cryptodev_stats qp_stats; /**< Queue pair statistics */ + uint8_t temp_digest[SNOW3G_DIGEST_LENGTH]; + /**< 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; enum snow3g_operation { -- 2.9.4