From patchwork Mon Jun 25 05:21:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jananee Parthasarathy X-Patchwork-Id: 41441 X-Patchwork-Delegate: pablo.de.lara.guarch@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B3A9358C4; Mon, 25 Jun 2018 07:21:49 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id EF5A62BEA for ; Mon, 25 Jun 2018 07:21:47 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jun 2018 22:21:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,269,1526367600"; d="scan'208";a="210846273" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga004.jf.intel.com with ESMTP; 24 Jun 2018 22:21:45 -0700 Received: from wgcvswdev001.ir.intel.com (wgcvswdev001.ir.intel.com [10.102.246.100]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id w5P5LiJP020634; Mon, 25 Jun 2018 06:21:44 +0100 Received: from wgcvswdev001.ir.intel.com (localhost [127.0.0.1]) by wgcvswdev001.ir.intel.com with ESMTP id w5P5LiGq008746; Mon, 25 Jun 2018 06:21:44 +0100 Received: (from jmparthx@localhost) by wgcvswdev001.ir.intel.com with ? id w5P5LiRw008742; Mon, 25 Jun 2018 06:21:44 +0100 From: Jananee Parthasarathy To: dev@dpdk.org Cc: pablo.de.lara.guarch@intel.com, reshma.pattan@intel.com, Agalya Babu Radha Krishnan Date: Mon, 25 Jun 2018 06:21:30 +0100 Message-Id: <1529904090-8661-1-git-send-email-jananeex.m.parthasarathy@intel.com> X-Mailer: git-send-email 1.7.12.2 Subject: [dpdk-dev] [PATCH] crypto/zuc: add dynamic logging to zuc 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Agalya Babu Radha Krishnan 1.added new logtype for zuc driver. 2.registered new logtype. 3.ZUC_LOG_ERR and CDEV_LOG_ERR are replaced with new logtype name ZUC_PMD_LOG Signed-off-by: Agalya Babu RadhaKrishnan Reviewed-by: Reshma Pattan --- drivers/crypto/zuc/rte_zuc_pmd.c | 28 +++++++++++++++++----------- drivers/crypto/zuc/rte_zuc_pmd_ops.c | 13 +++++++------ drivers/crypto/zuc/rte_zuc_pmd_private.h | 27 +++++++-------------------- 3 files changed, 31 insertions(+), 37 deletions(-) diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c index a805b2278..2a6c2caf7 100644 --- a/drivers/crypto/zuc/rte_zuc_pmd.c +++ b/drivers/crypto/zuc/rte_zuc_pmd.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2016-2017 Intel Corporation + * Copyright(c) 2016-2018 Intel Corporation */ #include @@ -11,7 +11,6 @@ #include #include "rte_zuc_pmd_private.h" - #define ZUC_MAX_BURST 4 #define BYTE_LEN 8 @@ -78,7 +77,7 @@ zuc_set_session_parameters(struct zuc_session *sess, break; case ZUC_OP_NOT_SUPPORTED: default: - ZUC_LOG_ERR("Unsupported operation chain order parameter"); + ZUC_PMD_LOG(ERR, "Unsupported operation chain order parameter"); return -ENOTSUP; } @@ -88,7 +87,7 @@ zuc_set_session_parameters(struct zuc_session *sess, return -ENOTSUP; if (cipher_xform->cipher.iv.length != ZUC_IV_KEY_LENGTH) { - ZUC_LOG_ERR("Wrong IV length"); + ZUC_PMD_LOG(ERR, "Wrong IV length"); return -EINVAL; } sess->cipher_iv_offset = cipher_xform->cipher.iv.offset; @@ -104,14 +103,14 @@ zuc_set_session_parameters(struct zuc_session *sess, return -ENOTSUP; if (auth_xform->auth.digest_length != ZUC_DIGEST_LENGTH) { - ZUC_LOG_ERR("Wrong digest length"); + ZUC_PMD_LOG(ERR, "Wrong digest length"); return -EINVAL; } sess->auth_op = auth_xform->auth.op; if (auth_xform->auth.iv.length != ZUC_IV_KEY_LENGTH) { - ZUC_LOG_ERR("Wrong IV length"); + ZUC_PMD_LOG(ERR, "Wrong IV length"); return -EINVAL; } sess->auth_iv_offset = auth_xform->auth.iv.offset; @@ -187,7 +186,7 @@ process_zuc_cipher_op(struct rte_crypto_op **ops, || ((ops[i]->sym->cipher.data.offset % BYTE_LEN) != 0)) { ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; - ZUC_LOG_ERR("Data Length or offset"); + ZUC_PMD_LOG(ERR, "Data Length or offset"); break; } @@ -198,7 +197,7 @@ process_zuc_cipher_op(struct rte_crypto_op **ops, (ops[i]->sym->m_dst != NULL && !rte_pktmbuf_is_contiguous( ops[i]->sym->m_dst))) { - ZUC_LOG_ERR("PMD supports only contiguous mbufs, " + ZUC_PMD_LOG(ERR, "PMD supports only contiguous mbufs, " "op (%p) provides noncontiguous mbuf as " "source/destination buffer.\n", ops[i]); ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; @@ -246,7 +245,7 @@ process_zuc_hash_op(struct zuc_qp *qp, struct rte_crypto_op **ops, /* Data must be byte aligned */ if ((ops[i]->sym->auth.data.offset % BYTE_LEN) != 0) { ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; - ZUC_LOG_ERR("Offset"); + ZUC_PMD_LOG(ERR, "Offset"); break; } @@ -461,7 +460,7 @@ cryptodev_zuc_create(const char *name, dev = rte_cryptodev_pmd_create(name, &vdev->device, init_params); if (dev == NULL) { - ZUC_LOG_ERR("failed to create cryptodev vdev"); + ZUC_PMD_LOG(ERR, "failed to create cryptodev vdev"); goto init_error; } @@ -483,7 +482,7 @@ cryptodev_zuc_create(const char *name, return 0; init_error: - ZUC_LOG_ERR("driver %s: cryptodev_zuc_create failed", + ZUC_PMD_LOG(ERR, "driver %s: failed", init_params->name); cryptodev_zuc_remove(vdev); @@ -545,3 +544,10 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_ZUC_PMD, "socket_id="); RTE_PMD_REGISTER_CRYPTO_DRIVER(zuc_crypto_drv, cryptodev_zuc_pmd_drv.driver, cryptodev_driver_id); + +RTE_INIT(zuc_init_log); +static void +zuc_init_log(void) +{ + zuc_logtype_driver = rte_log_register("pmd.crypto.zuc"); +} diff --git a/drivers/crypto/zuc/rte_zuc_pmd_ops.c b/drivers/crypto/zuc/rte_zuc_pmd_ops.c index 8abac8989..6f3345421 100644 --- a/drivers/crypto/zuc/rte_zuc_pmd_ops.c +++ b/drivers/crypto/zuc/rte_zuc_pmd_ops.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2016-2017 Intel Corporation + * Copyright(c) 2016-2018 Intel Corporation */ #include @@ -172,13 +172,13 @@ zuc_pmd_qp_create_processed_ops_ring(struct zuc_qp *qp, r = rte_ring_lookup(qp->name); if (r) { if (rte_ring_get_size(r) >= ring_size) { - ZUC_LOG_INFO("Reusing existing ring %s" + ZUC_PMD_LOG(INFO, "Reusing existing ring %s" " for processed packets", qp->name); return r; } - ZUC_LOG_ERR("Unable to reuse existing ring %s" + ZUC_PMD_LOG(ERR, "Unable to reuse existing ring %s" " for processed packets", qp->name); return NULL; @@ -271,19 +271,20 @@ zuc_pmd_session_configure(struct rte_cryptodev *dev __rte_unused, int ret; if (unlikely(sess == NULL)) { - ZUC_LOG_ERR("invalid session struct"); + ZUC_PMD_LOG(ERR, "invalid session struct"); return -EINVAL; } if (rte_mempool_get(mempool, &sess_private_data)) { - CDEV_LOG_ERR( + ZUC_PMD_LOG(ERR, "Couldn't get object from session mempool"); + return -ENOMEM; } ret = zuc_set_session_parameters(sess_private_data, xform); if (ret != 0) { - ZUC_LOG_ERR("failed configure session parameters"); + ZUC_PMD_LOG(ERR, "failed configure session parameters"); /* Return session to mempool */ rte_mempool_put(mempool, sess_private_data); diff --git a/drivers/crypto/zuc/rte_zuc_pmd_private.h b/drivers/crypto/zuc/rte_zuc_pmd_private.h index b83c4a047..36923b5de 100644 --- a/drivers/crypto/zuc/rte_zuc_pmd_private.h +++ b/drivers/crypto/zuc/rte_zuc_pmd_private.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2016-2017 Intel Corporation + * Copyright(c) 2016-2018 Intel Corporation */ #ifndef _RTE_ZUC_PMD_PRIVATE_H_ @@ -10,25 +10,12 @@ #define CRYPTODEV_NAME_ZUC_PMD crypto_zuc /**< KASUMI PMD device name */ -#define ZUC_LOG_ERR(fmt, args...) \ - RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \ - RTE_STR(CRYPTODEV_NAME_ZUC_PMD), \ - __func__, __LINE__, ## args) - -#ifdef RTE_LIBRTE_ZUC_DEBUG -#define ZUC_LOG_INFO(fmt, args...) \ - RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \ - RTE_STR(CRYPTODEV_NAME_ZUC_PMD), \ - __func__, __LINE__, ## args) - -#define ZUC_LOG_DBG(fmt, args...) \ - RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \ - RTE_STR(CRYPTODEV_NAME_ZUC_PMD), \ - __func__, __LINE__, ## args) -#else -#define ZUC_LOG_INFO(fmt, args...) -#define ZUC_LOG_DBG(fmt, args...) -#endif +/** ZUC PMD LOGTYPE DRIVER */ +int zuc_logtype_driver; +#define ZUC_PMD_LOG(level, fmt, ...) \ + rte_log(RTE_LOG_ ## level, zuc_logtype_driver, \ + "%s()... line %u: " fmt "\n", __func__, __LINE__, \ + ## __VA_ARGS__) #define ZUC_IV_KEY_LENGTH 16 #define ZUC_DIGEST_LENGTH 4