From: Tomasz Jozwiak Date: Thu, 14 Jun 2018 11:03:05 +0000 (+0200) Subject: crypto/qat: move to dynamic logging for data-path trace X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ab8a58fec59df465e882d00fd73993f11df5d111;p=dpdk.git crypto/qat: move to dynamic logging for data-path trace For all trace on the data-path move to dynamic logging. Add new QAT_DP_LOG macro to separate from non-dp trace. Use the overall RTE_LOG_DP_LEVEL to override and compile out debug data-path trace. Add "unlikely" in two appropriate error checks. Signed-off-by: Tomasz Jozwiak Signed-off-by: Fiona Trahe --- diff --git a/config/common_base b/config/common_base index b900767894..721e59bbe0 100644 --- a/config/common_base +++ b/config/common_base @@ -486,8 +486,6 @@ CONFIG_RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS=2048 # Compile PMD for QuickAssist based devices # CONFIG_RTE_LIBRTE_PMD_QAT=n -CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_TX=n -CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_RX=n # # Max. number of QuickAssist devices, which can be detected and attached # diff --git a/drivers/crypto/qat/qat_logs.c b/drivers/crypto/qat/qat_logs.c index fc8d9a7f0e..fa3df85f0f 100644 --- a/drivers/crypto/qat/qat_logs.c +++ b/drivers/crypto/qat/qat_logs.c @@ -3,8 +3,26 @@ */ #include +#include + +#include "qat_logs.h" int qat_gen_logtype; +int qat_dp_logtype; + +int +qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title, + const void *buf, unsigned int len) +{ + if (level > rte_log_get_global_level()) + return 0; + if (level > (uint32_t)(rte_log_get_level(logtype))) + return 0; + + rte_hexdump(rte_logs.file == NULL ? stderr : rte_logs.file, + title, buf, len); + return 0; +} RTE_INIT(qat_pci_init_log); static void @@ -14,4 +32,9 @@ qat_pci_init_log(void) qat_gen_logtype = rte_log_register("pmd.qat_general"); if (qat_gen_logtype >= 0) rte_log_set_level(qat_gen_logtype, RTE_LOG_NOTICE); + + /* data-path logging for all services */ + qat_dp_logtype = rte_log_register("pmd.qat_dp"); + if (qat_dp_logtype >= 0) + rte_log_set_level(qat_dp_logtype, RTE_LOG_NOTICE); } diff --git a/drivers/crypto/qat/qat_logs.h b/drivers/crypto/qat/qat_logs.h index b12f7543e2..4baea12c3b 100644 --- a/drivers/crypto/qat/qat_logs.h +++ b/drivers/crypto/qat/qat_logs.h @@ -6,9 +6,29 @@ #define _QAT_LOGS_H_ extern int qat_gen_logtype; +extern int qat_dp_logtype; #define QAT_LOG(level, fmt, args...) \ rte_log(RTE_LOG_ ## level, qat_gen_logtype, \ "%s(): " fmt "\n", __func__, ## args) +#define QAT_DP_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, qat_dp_logtype, \ + "%s(): " fmt "\n", __func__, ## args) + +#define QAT_DP_HEXDUMP_LOG(level, title, buf, len) \ + qat_hexdump_log(RTE_LOG_ ## level, qat_dp_logtype, title, buf, len) + +/** + * qat_hexdump_log - Dump out memory in a special hex dump format. + * + * Dump out the message buffer in a special hex dump output format with + * characters printed for each line of 16 hex values. The message will be sent + * to the stream defined by rte_logs.file or to stderr in case of rte_logs.file + * is undefined. + */ +int +qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title, + const void *buf, unsigned int len); + #endif /* _QAT_LOGS_H_ */ diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c index 7bedad315d..17d63eb1ee 100644 --- a/drivers/crypto/qat/qat_sym.c +++ b/drivers/crypto/qat/qat_sym.c @@ -6,12 +6,10 @@ #include #include -#include #include #include #include -#include "qat_logs.h" #include "qat_sym.h" /** Decrypt a single partial block @@ -39,7 +37,7 @@ bpi_cipher_decrypt(uint8_t *src, uint8_t *dst, return 0; cipher_decrypt_err: - QAT_LOG(ERR, "libcrypto ECB cipher decrypt for BPI IV failed"); + QAT_DP_LOG(ERR, "libcrypto ECB cipher decrypt for BPI IV failed"); return -EINVAL; } @@ -78,21 +76,21 @@ qat_bpicipher_preprocess(struct qat_sym_session *ctx, iv = rte_crypto_op_ctod_offset(op, uint8_t *, ctx->cipher_iv.offset); -#ifdef RTE_LIBRTE_PMD_QAT_DEBUG_TX - rte_hexdump(stdout, "BPI: src before pre-process:", last_block, - last_block_len); +#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG + QAT_DP_HEXDUMP_LOG(DEBUG, "BPI: src before pre-process:", + last_block, last_block_len); if (sym_op->m_dst != NULL) - rte_hexdump(stdout, "BPI: dst before pre-process:", dst, - last_block_len); + QAT_DP_HEXDUMP_LOG(DEBUG, "BPI:dst before pre-process:", + dst, last_block_len); #endif bpi_cipher_decrypt(last_block, dst, iv, block_len, last_block_len, ctx->bpi_ctx); -#ifdef RTE_LIBRTE_PMD_QAT_DEBUG_TX - rte_hexdump(stdout, "BPI: src after pre-process:", last_block, - last_block_len); +#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG + QAT_DP_HEXDUMP_LOG(DEBUG, "BPI: src after pre-process:", + last_block, last_block_len); if (sym_op->m_dst != NULL) - rte_hexdump(stdout, "BPI: dst after pre-process:", dst, - last_block_len); + QAT_DP_HEXDUMP_LOG(DEBUG, "BPI: dst after pre-process:", + dst, last_block_len); #endif } @@ -163,16 +161,15 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, struct qat_sym_op_cookie *cookie = (struct qat_sym_op_cookie *)op_cookie; -#ifdef RTE_LIBRTE_PMD_QAT_DEBUG_TX if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) { - QAT_LOG(ERR, "QAT PMD only supports symmetric crypto " + QAT_DP_LOG(ERR, "QAT PMD only supports symmetric crypto " "operation requests, op (%p) is not a " "symmetric operation.", op); return -EINVAL; } -#endif + if (unlikely(op->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) { - QAT_LOG(ERR, "QAT PMD only supports session oriented" + QAT_DP_LOG(ERR, "QAT PMD only supports session oriented" " requests, op (%p) is sessionless.", op); return -EINVAL; } @@ -181,12 +178,12 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, op->sym->session, cryptodev_qat_driver_id); if (unlikely(ctx == NULL)) { - QAT_LOG(ERR, "Session was not created for this device"); + QAT_DP_LOG(ERR, "Session was not created for this device"); return -EINVAL; } if (unlikely(ctx->min_qat_dev_gen > qat_dev_gen)) { - QAT_LOG(ERR, "Session alg not supported on this device gen"); + QAT_DP_LOG(ERR, "Session alg not supported on this device gen"); op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION; return -EINVAL; } @@ -231,7 +228,7 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, (cipher_param->cipher_length % BYTE_LENGTH != 0) || (cipher_param->cipher_offset % BYTE_LENGTH != 0))) { - QAT_LOG(ERR, + QAT_DP_LOG(ERR, "SNOW3G/KASUMI/ZUC in QAT PMD only supports byte aligned values"); op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; return -EINVAL; @@ -265,7 +262,7 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, ICP_QAT_HW_AUTH_ALGO_ZUC_3G_128_EIA3) { if (unlikely((auth_param->auth_off % BYTE_LENGTH != 0) || (auth_param->auth_len % BYTE_LENGTH != 0))) { - QAT_LOG(ERR, + QAT_DP_LOG(ERR, "For SNOW3G/KASUMI/ZUC, QAT PMD only supports byte aligned values"); op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; return -EINVAL; @@ -500,8 +497,9 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, ret = qat_sgl_fill_array(op->sym->m_src, src_buf_start, &cookie->qat_sgl_src, qat_req->comn_mid.src_length); - if (ret) { - QAT_LOG(ERR, "QAT PMD Cannot fill sgl array"); + + if (unlikely(ret)) { + QAT_DP_LOG(ERR, "QAT PMD Cannot fill sgl array"); return ret; } @@ -515,9 +513,8 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, &cookie->qat_sgl_dst, qat_req->comn_mid.dst_length); - if (ret) { - QAT_LOG(ERR, "QAT PMD Cannot " - "fill sgl array"); + if (unlikely(ret)) { + QAT_DP_LOG(ERR, "QAT PMD can't fill sgl array"); return ret; } @@ -531,17 +528,17 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, qat_req->comn_mid.dest_data_addr = dst_buf_start; } -#ifdef RTE_LIBRTE_PMD_QAT_DEBUG_TX - rte_hexdump(stdout, "qat_req:", qat_req, +#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG + QAT_DP_HEXDUMP_LOG(DEBUG, "qat_req:", qat_req, sizeof(struct icp_qat_fw_la_bulk_req)); - rte_hexdump(stdout, "src_data:", + QAT_DP_HEXDUMP_LOG(DEBUG, "src_data:", rte_pktmbuf_mtod(op->sym->m_src, uint8_t*), rte_pktmbuf_data_len(op->sym->m_src)); if (do_cipher) { uint8_t *cipher_iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, ctx->cipher_iv.offset); - rte_hexdump(stdout, "cipher iv:", cipher_iv_ptr, + QAT_DP_HEXDUMP_LOG(DEBUG, "cipher iv:", cipher_iv_ptr, ctx->cipher_iv.length); } @@ -550,17 +547,17 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, uint8_t *auth_iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, ctx->auth_iv.offset); - rte_hexdump(stdout, "auth iv:", auth_iv_ptr, + QAT_DP_HEXDUMP_LOG(DEBUG, "auth iv:", auth_iv_ptr, ctx->auth_iv.length); } - rte_hexdump(stdout, "digest:", op->sym->auth.digest.data, + QAT_DP_HEXDUMP_LOG(DEBUG, "digest:", op->sym->auth.digest.data, ctx->digest_length); } if (do_aead) { - rte_hexdump(stdout, "digest:", op->sym->aead.digest.data, + QAT_DP_HEXDUMP_LOG(DEBUG, "digest:", op->sym->aead.digest.data, ctx->digest_length); - rte_hexdump(stdout, "aad:", op->sym->aead.aad.data, + QAT_DP_HEXDUMP_LOG(DEBUG, "aad:", op->sym->aead.aad.data, ctx->aad_len); } #endif diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h index b693a4d9a1..f9e72a6e57 100644 --- a/drivers/crypto/qat/qat_sym.h +++ b/drivers/crypto/qat/qat_sym.h @@ -6,13 +6,13 @@ #define _QAT_SYM_H_ #include -#include #include #include "qat_common.h" #include "qat_sym_session.h" #include "qat_sym_pmd.h" +#include "qat_logs.h" #define BYTE_LENGTH 8 /* bpi is only used for partial blocks of DES and AES @@ -59,7 +59,7 @@ bpi_cipher_encrypt(uint8_t *src, uint8_t *dst, return 0; cipher_encrypt_err: - QAT_LOG(ERR, "libcrypto ECB cipher encrypt failed"); + QAT_DP_LOG(ERR, "libcrypto ECB cipher encrypt failed"); return -EINVAL; } @@ -99,21 +99,23 @@ qat_bpicipher_postprocess(struct qat_sym_session *ctx, iv = rte_crypto_op_ctod_offset(op, uint8_t *, ctx->cipher_iv.offset); -#ifdef RTE_LIBRTE_PMD_QAT_DEBUG_RX - rte_hexdump(stdout, "BPI: src before post-process:", last_block, - last_block_len); +#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG + QAT_DP_HEXDUMP_LOG(DEBUG, "BPI: src before post-process:", + last_block, last_block_len); if (sym_op->m_dst != NULL) - rte_hexdump(stdout, "BPI: dst before post-process:", - dst, last_block_len); + QAT_DP_HEXDUMP_LOG(DEBUG, + "BPI: dst before post-process:", + dst, last_block_len); #endif bpi_cipher_encrypt(last_block, dst, iv, block_len, last_block_len, ctx->bpi_ctx); -#ifdef RTE_LIBRTE_PMD_QAT_DEBUG_RX - rte_hexdump(stdout, "BPI: src after post-process:", last_block, - last_block_len); +#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG + QAT_DP_HEXDUMP_LOG(DEBUG, "BPI: src after post-process:", + last_block, last_block_len); if (sym_op->m_dst != NULL) - rte_hexdump(stdout, "BPI: dst after post-process:", dst, - last_block_len); + QAT_DP_HEXDUMP_LOG(DEBUG, + "BPI: dst after post-process:", + dst, last_block_len); #endif } return sym_op->cipher.data.length - last_block_len; @@ -128,8 +130,8 @@ qat_sym_process_response(void **op, uint8_t *resp) struct rte_crypto_op *rx_op = (struct rte_crypto_op *)(uintptr_t) (resp_msg->opaque_data); -#ifdef RTE_LIBRTE_PMD_QAT_DEBUG_RX - rte_hexdump(stdout, "qat_response:", (uint8_t *)resp_msg, +#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG + QAT_DP_HEXDUMP_LOG(DEBUG, "qat_response:", (uint8_t *)resp_msg, sizeof(struct icp_qat_fw_comn_resp)); #endif