crypto/zuc: add dynamic logging
authorAgalya Babu RadhaKrishnan <agalyax.babu.radhakrishnan@intel.com>
Thu, 28 Jun 2018 14:59:43 +0000 (15:59 +0100)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Tue, 10 Jul 2018 22:57:51 +0000 (00:57 +0200)
Registered new dynamic logtype for driver and
replaced ZUC_LOG_ERR and CDEV_LOG_ERR
with the new ZUC_LOG macro, which uses the new logtype.

Signed-off-by: Agalya Babu RadhaKrishnan <agalyax.babu.radhakrishnan@intel.com>
Reviewed-by: Reshma Pattan <reshma.pattan@intel.com>
Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
config/common_base
drivers/crypto/zuc/rte_zuc_pmd.c
drivers/crypto/zuc/rte_zuc_pmd_ops.c
drivers/crypto/zuc/rte_zuc_pmd_private.h

index 6785389..fc9fe96 100644 (file)
@@ -533,9 +533,7 @@ CONFIG_RTE_LIBRTE_PMD_KASUMI=n
 # Compile PMD for ZUC device
 #
 CONFIG_RTE_LIBRTE_PMD_ZUC=n
-CONFIG_RTE_LIBRTE_PMD_ZUC_DEBUG=n
 
-#
 # Compile PMD for Crypto Scheduler device
 #
 CONFIG_RTE_LIBRTE_PMD_CRYPTO_SCHEDULER=y
index a805b22..119d393 100644 (file)
@@ -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_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_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_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_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_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_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_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_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_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");
+}
index 8abac89..87c44ce 100644 (file)
@@ -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_LOG(INFO, "Reusing existing ring %s"
                                        " for processed packets",
                                         qp->name);
                        return r;
                }
 
-               ZUC_LOG_ERR("Unable to reuse existing ring %s"
+               ZUC_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_LOG(ERR, "invalid session struct");
                return -EINVAL;
        }
 
        if (rte_mempool_get(mempool, &sess_private_data)) {
-               CDEV_LOG_ERR(
+               ZUC_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_LOG(ERR, "failed configure session parameters");
 
                /* Return session to mempool */
                rte_mempool_put(mempool, sess_private_data);
index b83c4a0..69cc32e 100644 (file)
@@ -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_
 #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_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