From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by dpdk.org (Postfix) with ESMTP id 28D4F4CC3 for ; Fri, 21 Sep 2018 15:25:01 +0200 (CEST) Received: by mail-lf1-f46.google.com with SMTP id g24-v6so11428728lfb.11 for ; Fri, 21 Sep 2018 06:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6FCrI51fp2KRdC+ZHqf1JIjssn0cwJRZlYySkUQ785s=; b=ulkUO3QwxuBLUVxNbq8CIaoMj2+J+Vckn4J8j6Vdxv2i9+QNa8LmCQxcifhjTVUIV3 ec9H51T5xvlTC5sDuN+tOnob87rY0Aj17DZJ6PCyVic2CMOr+EH14ZKU4Fs65fQ1zczN IBnvlN+fI2VcEx3spNsUXH3iXR94ipRk4/2FjghFB9fdirFS0Od4j8tZQGa9OBFV5uE7 TrPZZa3+m7AWqiwm9ASyYWGfJO+4dkNMyq8jifYJrm/sHv4vi9TTRVAnMWkdSnZnNuUR oU37NUI9xSG1IFl3x2hJRA5A+vG2lh+Qbew+TvsX8K5OrCpoUFN0k0SQCqGgGc1bEHTN hGFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6FCrI51fp2KRdC+ZHqf1JIjssn0cwJRZlYySkUQ785s=; b=bx+9jAh9K9B0x9DqfNoegUCSe2uK1cyy0cp9aDOZHVVYvEqYbQfs9aST1FpqR9evXS Vb0bGr+sYTJRnd+v2E5aNwW1yvW4/eX6NpylnvgGpoaKurItxnzsiq9qIF9+IHzejOuL iQjbA81eJmhJ9LngH33g2YuY1KhLlt8kgMLwgUaiEVWLON3WKuErK4I1Mn35OE7uvaiF cuaP3lsTqBp7LSP/VCNlBzsYVP1bALPpFuT51HsxzlKaaVqVHkcaQ0cdzOBsFi3lD3T+ o/ovsv+oGTuQaC7r2eFdFYnXBgAZ17kidvSduwUsoDmTjrbL07OrornmSWjCvMPAmdhj oH9A== X-Gm-Message-State: APzg51C59hXQneHTYSLRibKQtlkuitDoVTH7GXcYJzmceYzm5N1CyM7z Sdsngre2vcPZIlICdshXQpYsAMU0534= X-Google-Smtp-Source: ANB0VdaMB6i3NB0G3LeF3ccQBGEZcxL7vcbMUDVG5MRhb8iHl1qhcFs4s7OTlV//WNZBoewa4wQWKw== X-Received: by 2002:a19:1853:: with SMTP id o80-v6mr17337808lfi.10.1537536300368; Fri, 21 Sep 2018 06:25:00 -0700 (PDT) Received: from amok.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.googlemail.com with ESMTPSA id v14-v6sm4868767lji.80.2018.09.21.06.24.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Sep 2018 06:24:59 -0700 (PDT) From: Andrzej Ostruszka To: dev@dpdk.org Cc: mw@semihalf.com, nadavh@marvell.com, Tomasz Duszynski Date: Fri, 21 Sep 2018 15:24:54 +0200 Message-Id: <1537536294-16703-4-git-send-email-amo@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537536294-16703-1-git-send-email-amo@semihalf.com> References: <1535372574-18950-1-git-send-email-tdu@semihalf.com> <1537536294-16703-1-git-send-email-amo@semihalf.com> Subject: [dpdk-dev] [PATCH v2 3/3] crypto/mvsam: add dynamic logging support 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: Fri, 21 Sep 2018 13:25:01 -0000 From: Tomasz Duszynski Add dynamic logging support to mvsam crypto PMD. Signed-off-by: Tomasz Duszynski --- config/common_base | 1 - drivers/crypto/mvsam/rte_mrvl_pmd.c | 74 ++++++++++++++--------------- drivers/crypto/mvsam/rte_mrvl_pmd_ops.c | 10 ++-- drivers/crypto/mvsam/rte_mrvl_pmd_private.h | 27 +++-------- 4 files changed, 49 insertions(+), 63 deletions(-) diff --git a/config/common_base b/config/common_base index 155c7d4..61c7f6d 100644 --- a/config/common_base +++ b/config/common_base @@ -559,7 +559,6 @@ CONFIG_RTE_LIBRTE_PMD_CCP=n # Compile PMD for Marvell Crypto device # CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO=n -CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO_DEBUG=n # # Compile generic security library diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c index 35dd659..2afdd3b 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c @@ -210,7 +210,7 @@ mrvl_crypto_set_cipher_session_parameters(struct mrvl_crypto_session *sess, { /* Make sure we've got proper struct */ if (cipher_xform->type != RTE_CRYPTO_SYM_XFORM_CIPHER) { - MRVL_CRYPTO_LOG_ERR("Wrong xform struct provided!"); + MRVL_LOG(ERR, "Wrong xform struct provided!"); return -EINVAL; } @@ -218,7 +218,7 @@ mrvl_crypto_set_cipher_session_parameters(struct mrvl_crypto_session *sess, if ((cipher_xform->cipher.algo > RTE_DIM(cipher_map)) || (cipher_map[cipher_xform->cipher.algo].supported != ALGO_SUPPORTED)) { - MRVL_CRYPTO_LOG_ERR("Cipher algorithm not supported!"); + MRVL_LOG(ERR, "Cipher algorithm not supported!"); return -EINVAL; } @@ -238,7 +238,7 @@ mrvl_crypto_set_cipher_session_parameters(struct mrvl_crypto_session *sess, /* Get max key length. */ if (cipher_xform->cipher.key.length > cipher_map[cipher_xform->cipher.algo].max_key_len) { - MRVL_CRYPTO_LOG_ERR("Wrong key length!"); + MRVL_LOG(ERR, "Wrong key length!"); return -EINVAL; } @@ -261,14 +261,14 @@ mrvl_crypto_set_auth_session_parameters(struct mrvl_crypto_session *sess, { /* Make sure we've got proper struct */ if (auth_xform->type != RTE_CRYPTO_SYM_XFORM_AUTH) { - MRVL_CRYPTO_LOG_ERR("Wrong xform struct provided!"); + MRVL_LOG(ERR, "Wrong xform struct provided!"); return -EINVAL; } /* See if map data is present and valid */ if ((auth_xform->auth.algo > RTE_DIM(auth_map)) || (auth_map[auth_xform->auth.algo].supported != ALGO_SUPPORTED)) { - MRVL_CRYPTO_LOG_ERR("Auth algorithm not supported!"); + MRVL_LOG(ERR, "Auth algorithm not supported!"); return -EINVAL; } @@ -300,7 +300,7 @@ mrvl_crypto_set_aead_session_parameters(struct mrvl_crypto_session *sess, { /* Make sure we've got proper struct */ if (aead_xform->type != RTE_CRYPTO_SYM_XFORM_AEAD) { - MRVL_CRYPTO_LOG_ERR("Wrong xform struct provided!"); + MRVL_LOG(ERR, "Wrong xform struct provided!"); return -EINVAL; } @@ -308,7 +308,7 @@ mrvl_crypto_set_aead_session_parameters(struct mrvl_crypto_session *sess, if ((aead_xform->aead.algo > RTE_DIM(aead_map)) || (aead_map[aead_xform->aead.algo].supported != ALGO_SUPPORTED)) { - MRVL_CRYPTO_LOG_ERR("AEAD algorithm not supported!"); + MRVL_LOG(ERR, "AEAD algorithm not supported!"); return -EINVAL; } @@ -326,7 +326,7 @@ mrvl_crypto_set_aead_session_parameters(struct mrvl_crypto_session *sess, /* Get max key length. */ if (aead_xform->aead.key.length > aead_map[aead_xform->aead.algo].max_key_len) { - MRVL_CRYPTO_LOG_ERR("Wrong key length!"); + MRVL_LOG(ERR, "Wrong key length!"); return -EINVAL; } @@ -391,21 +391,21 @@ mrvl_crypto_set_session_parameters(struct mrvl_crypto_session *sess, if ((cipher_xform != NULL) && (mrvl_crypto_set_cipher_session_parameters( sess, cipher_xform) < 0)) { - MRVL_CRYPTO_LOG_ERR("Invalid/unsupported cipher parameters"); + MRVL_LOG(ERR, "Invalid/unsupported cipher parameters!"); return -EINVAL; } if ((auth_xform != NULL) && (mrvl_crypto_set_auth_session_parameters( sess, auth_xform) < 0)) { - MRVL_CRYPTO_LOG_ERR("Invalid/unsupported auth parameters"); + MRVL_LOG(ERR, "Invalid/unsupported auth parameters!"); return -EINVAL; } if ((aead_xform != NULL) && (mrvl_crypto_set_aead_session_parameters( sess, aead_xform) < 0)) { - MRVL_CRYPTO_LOG_ERR("Invalid/unsupported aead parameters"); + MRVL_LOG(ERR, "Invalid/unsupported aead parameters!"); return -EINVAL; } @@ -443,8 +443,8 @@ mrvl_request_prepare(struct sam_cio_op_params *request, int i; if (unlikely(op->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) { - MRVL_CRYPTO_LOG_ERR("MRVL CRYPTO PMD only supports session " - "oriented requests, op (%p) is sessionless.", + MRVL_LOG(ERR, "MRVL CRYPTO PMD only supports session " + "oriented requests, op (%p) is sessionless!", op); return -EINVAL; } @@ -452,7 +452,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, sess = (struct mrvl_crypto_session *)get_sym_session_private_data( op->sym->session, cryptodev_driver_id); if (unlikely(sess == NULL)) { - MRVL_CRYPTO_LOG_ERR("Session was not created for this device"); + MRVL_LOG(ERR, "Session was not created for this device!"); return -EINVAL; } @@ -466,7 +466,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, * - Segmented destination buffer is not supported */ if ((segments_nb > 1) && (!op->sym->m_dst)) { - MRVL_CRYPTO_LOG_ERR("op->sym->m_dst = NULL!\n"); + MRVL_LOG(ERR, "op->sym->m_dst = NULL!"); return -1; } /* For non SG case: @@ -476,8 +476,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, dst_mbuf = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src; if (!rte_pktmbuf_is_contiguous(dst_mbuf)) { - MRVL_CRYPTO_LOG_ERR("Segmented destination buffer " - "not supported.\n"); + MRVL_LOG(ERR, "Segmented destination buffer not supported!"); return -1; } @@ -486,7 +485,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, /* Empty source. */ if (rte_pktmbuf_data_len(src_mbuf) == 0) { /* EIP does not support 0 length buffers. */ - MRVL_CRYPTO_LOG_ERR("Buffer length == 0 not supported!"); + MRVL_LOG(ERR, "Buffer length == 0 not supported!"); return -1; } src_bd[i].vaddr = rte_pktmbuf_mtod(src_mbuf, void *); @@ -502,7 +501,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, /* Make dst buffer fit at least source data. */ if (rte_pktmbuf_append(dst_mbuf, rte_pktmbuf_data_len(op->sym->m_src)) == NULL) { - MRVL_CRYPTO_LOG_ERR("Unable to set big enough dst buffer!"); + MRVL_LOG(ERR, "Unable to set big enough dst buffer!"); return -1; } } @@ -642,8 +641,7 @@ mrvl_crypto_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, src_bd[iter_ops].src_bd, &dst_bd[iter_ops], ops[iter_ops]) < 0) { - MRVL_CRYPTO_LOG_ERR( - "Error while parameters preparation!"); + MRVL_LOG(ERR, "Error while preparing parameters!"); qp->stats.enqueue_err_count++; ops[iter_ops]->status = RTE_CRYPTO_OP_STATUS_ERROR; @@ -721,12 +719,12 @@ mrvl_crypto_pmd_dequeue_burst(void *queue_pair, ops[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS; break; case SAM_CIO_ERR_ICV: - MRVL_CRYPTO_LOG_DBG("CIO returned SAM_CIO_ERR_ICV."); + MRVL_LOG(DEBUG, "CIO returned SAM_CIO_ERR_ICV."); ops[i]->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED; break; default: - MRVL_CRYPTO_LOG_DBG( - "CIO returned Error: %d", results[i].status); + MRVL_LOG(DEBUG, + "CIO returned Error: %d.", results[i].status); ops[i]->status = RTE_CRYPTO_OP_STATUS_ERROR; break; } @@ -757,7 +755,7 @@ cryptodev_mrvl_crypto_create(const char *name, dev = rte_cryptodev_pmd_create(name, &vdev->device, &init_params->common); if (dev == NULL) { - MRVL_CRYPTO_LOG_ERR("failed to create cryptodev vdev"); + MRVL_LOG(ERR, "Failed to create cryptodev vdev!"); goto init_error; } @@ -793,8 +791,8 @@ cryptodev_mrvl_crypto_create(const char *name, return 0; init_error: - MRVL_CRYPTO_LOG_ERR( - "driver %s: %s failed", init_params->common.name, __func__); + MRVL_LOG(ERR, + "Driver %s: %s failed!", init_params->common.name, __func__); cryptodev_mrvl_crypto_uninit(vdev); return ret; @@ -809,7 +807,7 @@ parse_integer_arg(const char *key __rte_unused, *i = atoi(value); if (*i < 0) { - MRVL_CRYPTO_LOG_ERR("Argument has to be positive.\n"); + MRVL_LOG(ERR, "Argument has to be positive!"); return -EINVAL; } @@ -824,9 +822,8 @@ parse_name_arg(const char *key __rte_unused, struct rte_cryptodev_pmd_init_params *params = extra_args; if (strlen(value) >= RTE_CRYPTODEV_NAME_MAX_LEN - 1) { - MRVL_CRYPTO_LOG_ERR("Invalid name %s, should be less than " - "%u bytes.\n", value, - RTE_CRYPTODEV_NAME_MAX_LEN - 1); + MRVL_LOG(ERR, "Invalid name %s, should be less than %u bytes!", + value, RTE_CRYPTODEV_NAME_MAX_LEN - 1); return -EINVAL; } @@ -918,9 +915,8 @@ cryptodev_mrvl_crypto_init(struct rte_vdev_device *vdev) ret = mrvl_pmd_parse_input_args(&init_params, args); if (ret) { - RTE_LOG(ERR, PMD, - "Failed to parse initialisation arguments[%s]\n", - args); + MRVL_LOG(ERR, "Failed to parse initialisation arguments[%s]!", + args); return -EINVAL; } @@ -942,9 +938,8 @@ cryptodev_mrvl_crypto_uninit(struct rte_vdev_device *vdev) if (name == NULL) return -EINVAL; - RTE_LOG(INFO, PMD, - "Closing Marvell crypto device %s on numa socket %u\n", - name, rte_socket_id()); + MRVL_LOG(INFO, "Closing Marvell crypto device %s on numa socket %u.", + name, rte_socket_id()); sam_deinit(); rte_mvep_deinit(MVEP_MOD_T_SAM); @@ -974,3 +969,8 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_MRVL_PMD, "socket_id="); RTE_PMD_REGISTER_CRYPTO_DRIVER(mrvl_crypto_drv, cryptodev_mrvl_pmd_drv.driver, cryptodev_driver_id); + +RTE_INIT(crypto_mrvl_init_log) +{ + mrvl_logtype_driver = rte_log_register("pmd.crypto.mvsam"); +} diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c index c045562..ba6eef3 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c @@ -551,7 +551,7 @@ mrvl_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, */ int num = sam_get_num_inst(); if (num == 0) { - MRVL_CRYPTO_LOG_ERR("No crypto engines detected.\n"); + MRVL_LOG(ERR, "No crypto engines detected!"); return -1; } @@ -635,7 +635,7 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev, int ret; if (sess == NULL) { - MRVL_CRYPTO_LOG_ERR("Invalid session struct."); + MRVL_LOG(ERR, "Invalid session struct!"); return -EINVAL; } @@ -646,7 +646,7 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev, ret = mrvl_crypto_set_session_parameters(sess_private_data, xform); if (ret != 0) { - MRVL_CRYPTO_LOG_ERR("Failed to configure session parameters."); + MRVL_LOG(ERR, "Failed to configure session parameters!"); /* Return session to mempool */ rte_mempool_put(mp, sess_private_data); @@ -658,7 +658,7 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev, mrvl_sess = (struct mrvl_crypto_session *)sess_private_data; if (sam_session_create(&mrvl_sess->sam_sess_params, &mrvl_sess->sam_sess) < 0) { - MRVL_CRYPTO_LOG_DBG("Failed to create session!"); + MRVL_LOG(DEBUG, "Failed to create session!"); return -EIO; } @@ -686,7 +686,7 @@ mrvl_crypto_pmd_sym_session_clear(struct rte_cryptodev *dev, if (mrvl_sess->sam_sess && sam_session_destroy(mrvl_sess->sam_sess) < 0) { - MRVL_CRYPTO_LOG_INFO("Error while destroying session!"); + MRVL_LOG(ERR, "Error while destroying session!"); } memset(sess, 0, sizeof(struct mrvl_crypto_session)); diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h index 0689fc3..6f8cf56 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h +++ b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h @@ -12,26 +12,13 @@ #define CRYPTODEV_NAME_MRVL_PMD crypto_mvsam /**< Marvell PMD device name */ -#define MRVL_CRYPTO_LOG_ERR(fmt, args...) \ - RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \ - RTE_STR(CRYPTODEV_NAME_MRVL_PMD), \ - __func__, __LINE__, ## args) - -#ifdef RTE_LIBRTE_PMD_MRVL_CRYPTO_DEBUG -#define MRVL_CRYPTO_LOG_INFO(fmt, args...) \ - RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \ - RTE_STR(CRYPTODEV_NAME_MRVL_PMD), \ - __func__, __LINE__, ## args) - -#define MRVL_CRYPTO_LOG_DBG(fmt, args...) \ - RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \ - RTE_STR(CRYPTODEV_NAME_MRVL_PMD), \ - __func__, __LINE__, ## args) - -#else -#define MRVL_CRYPTO_LOG_INFO(fmt, args...) -#define MRVL_CRYPTO_LOG_DBG(fmt, args...) -#endif +/** MRVL PMD LOGTYPE DRIVER */ +int mrvl_logtype_driver; + +#define MRVL_LOG(level, fmt, ...) \ + rte_log(RTE_LOG_ ## level, mrvl_logtype_driver, \ + "%s() line %u: " fmt "\n", __func__, __LINE__, \ + ## __VA_ARGS__) /** * Handy bits->bytes conversion macro. -- 2.7.4