DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jananee Parthasarathy <jananeex.m.parthasarathy@intel.com>
To: dev@dpdk.org
Cc: pablo.de.lara.guarch@intel.com, reshma.pattan@intel.com,
	Agalya Babu Radha Krishnan <agalyax.babu.radhakrishnan@intel.com>
Subject: [dpdk-dev] [PATCH] crypto/zuc: add dynamic logging to zuc
Date: Mon, 25 Jun 2018 06:21:30 +0100	[thread overview]
Message-ID: <1529904090-8661-1-git-send-email-jananeex.m.parthasarathy@intel.com> (raw)

From: Agalya Babu Radha Krishnan <agalyax.babu.radhakrishnan@intel.com>

    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 <agalyax.babu.radhakrishnan@intel.com>
Reviewed-by: Reshma Pattan <reshma.pattan@intel.com>
---
 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 <rte_common.h>
@@ -11,7 +11,6 @@
 #include <rte_cpuflags.h>
 
 #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=<int>");
 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 <string.h>
@@ -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
-- 
2.13.6

             reply	other threads:[~2018-06-25  5:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-25  5:21 Jananee Parthasarathy [this message]
2018-06-28 14:59 ` [dpdk-dev] [PATCH v2] crypto/zuc: add dynamic logging Jananee Parthasarathy
2018-07-03  8:36   ` De Lara Guarch, Pablo
2018-07-03  8:38   ` De Lara Guarch, Pablo
     [not found] <1529659681-28346-1-git-send-email-agalyax.babu.radhakrishnan@intel.com>
2018-06-27 16:19 ` [dpdk-dev] [PATCH] crypto/zuc: add dynamic logging to zuc 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=1529904090-8661-1-git-send-email-jananeex.m.parthasarathy@intel.com \
    --to=jananeex.m.parthasarathy@intel.com \
    --cc=agalyax.babu.radhakrishnan@intel.com \
    --cc=dev@dpdk.org \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=reshma.pattan@intel.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).