From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 6396ACED1 for ; Fri, 17 Jun 2016 13:18:40 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 17 Jun 2016 04:18:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,483,1459839600"; d="scan'208";a="123835067" Received: from sie-lab-212-116.ir.intel.com (HELO silpixa00378492.ir.intel.com) ([10.237.212.116]) by fmsmga004.fm.intel.com with ESMTP; 17 Jun 2016 04:18:38 -0700 From: Pablo de Lara To: dev@dpdk.org Cc: declan.doherty@intel.com, Pablo de Lara Date: Fri, 17 Jun 2016 12:24:44 +0100 Message-Id: <1466162692-24654-4-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1466162692-24654-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1462543429-26741-1-git-send-email-pablo.de.lara.guarch@intel.com> <1466162692-24654-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v2 03/11] snow3g: define IV/digest length macros X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 11:18:40 -0000 In order to avoid using magic numbers, macros for the IV and digest lengths for Snow3G have been added. Signed-off-by: Pablo de Lara --- drivers/crypto/snow3g/rte_snow3g_pmd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c index f3e0e66..8bbee8a 100644 --- a/drivers/crypto/snow3g/rte_snow3g_pmd.c +++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c @@ -42,6 +42,8 @@ #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 @@ -198,7 +200,7 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops, for (i = 0; i < num_ops; i++) { /* Sanity checks. */ - if (ops[i]->sym->cipher.iv.length != 16) { + if (unlikely(ops[i]->sym->cipher.iv.length != SNOW3G_IV_LENGTH)) { ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; SNOW3G_LOG_ERR("iv"); break; @@ -243,13 +245,13 @@ process_snow3g_hash_op(struct rte_crypto_op **ops, uint32_t length_in_bits; for (i = 0; i < num_ops; i++) { - if (ops[i]->sym->auth.aad.length != 16) { + if (unlikely(ops[i]->sym->auth.aad.length != SNOW3G_IV_LENGTH)) { ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; SNOW3G_LOG_ERR("aad"); break; } - if (ops[i]->sym->auth.digest.length != 4) { + if (unlikely(ops[i]->sym->auth.digest.length != SNOW3G_DIGEST_LENGTH)) { ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; SNOW3G_LOG_ERR("digest"); break; -- 2.5.0