From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0E61E41C33; Tue, 7 Feb 2023 21:45:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9893142D2F; Tue, 7 Feb 2023 21:44:44 +0100 (CET) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id 2FF3542BAC for ; Tue, 7 Feb 2023 21:44:41 +0100 (CET) Received: by mail-pj1-f50.google.com with SMTP id d2so12582035pjd.5 for ; Tue, 07 Feb 2023 12:44:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zbpl1VQaJw6KXJxK5XPQV2ImktM1Pubz0GIe8TZsd9A=; b=MKDi1SEkJfoZTKt3QIgTCd4tV0cQ22h/+cELmncAOzSJKFqiUU+VKuOb0Pq2jv967F 8lVpRnI5B81nXvWZR/5zNk+QzAafhtE+pBCdHZLCpqUjp1AR7wh8EZCKIiGpMzoTWVys d1Y/I41CLv6v49oqGtYeaeBxT7AxDgl+9iHJvaJZe8SQ/ZX2cm4EhMd/n5J5GFUu39Sk d+eq5b+f7s/V6MajS3EETxxGGmh/9odTQUZjYQBQEyztks7CG5fGum/4BvMI++ZBAXWi e4T5EkIxEJmorM5gXkgHXwVu76aRRSug/y0deYRLTBbCAEFgrct5R1nc7abUwF4Oe8zQ ipwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zbpl1VQaJw6KXJxK5XPQV2ImktM1Pubz0GIe8TZsd9A=; b=j4Oz3FYqcEJX8LpzoxzxpsFl7qzWiTjrpN/DhMuOBQJJ12z8l05yzwvnJ8IZREMsYm KS9fOod4jQPvi/kfpyv/BP1XGP72l3aDrXPiX9ve/gDhuHfod3n1yM+59aEXEDq29kUC FuJ5k0A3/wfqxdn4WT47M2h9h03SNK8mPP+LoE/wTmkzIqKS9EOnVl5PFLMf7Ox+OiL7 JG/BUb8MfApiq/fHWGbVL4xbslqkYGZa8FyV2N9HkJM/LaU3Za+gxtu+vCXFF/TL/pI7 w+8NDud0Yj3yYZgLmKRAgEtqt1BJ5b65ttHRJKZrJImDIGgOpYXR2fH7WI+kEDw2150w 84NA== X-Gm-Message-State: AO0yUKXOnU01XfTb3V+TDiLeftem/7NqRtbU3YwJivP0yzBGhYZWQRqg T1P/frTGoCvVxDI3QbMUS1yxPUlI5BnAATeQxdg= X-Google-Smtp-Source: AK7set/nXt+Bk7AIWHlODU4JoCkoxSk4ak+sPKXQgFMmCahWC+zcZ/YBPlef0fosUdVkNzG/MrqaBA== X-Received: by 2002:a17:902:e5c7:b0:199:1927:d088 with SMTP id u7-20020a170902e5c700b001991927d088mr5548838plf.3.1675802680072; Tue, 07 Feb 2023 12:44:40 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jk24-20020a170903331800b00194ab9a4febsm4725562plb.74.2023.02.07.12.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 12:44:39 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Konstantin Ananyev Subject: [RFC 06/13] acl: replace LOGTYPE_ACL with dynamic type Date: Tue, 7 Feb 2023 12:41:44 -0800 Message-Id: <20230207204151.1503491-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207204151.1503491-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC. For ACL library use a dynamic type. The one message using RTE_LOGTYPE_MALLOC should have been under the ACL logtype anyway. The test code should not have been using fixed log type so just change that to stderr. Signed-off-by: Stephen Hemminger --- app/test/test_acl.c | 3 ++- lib/acl/acl.h | 5 +++++ lib/acl/acl_bld.c | 34 ++++++++++++++++----------------- lib/acl/acl_gen.c | 19 +++++++++--------- lib/acl/rte_acl.c | 13 ++++++++----- lib/acl/tb_mem.c | 9 +++++++-- lib/eal/common/eal_common_log.c | 2 -- lib/eal/include/rte_log.h | 4 ++-- 8 files changed, 51 insertions(+), 38 deletions(-) diff --git a/app/test/test_acl.c b/app/test/test_acl.c index 623f34682e69..75588978a720 100644 --- a/app/test/test_acl.c +++ b/app/test/test_acl.c @@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx, for (i = 0; i != num; i++) { rc = acl_ipv4vlan_check_rule(rules + i); if (rc != 0) { - RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n", + fprintf(stderr, + "%s: rule #%u is invalid\n", __func__, i + 1); return rc; } diff --git a/lib/acl/acl.h b/lib/acl/acl.h index f5739a475cf0..1b64aa65edfe 100644 --- a/lib/acl/acl.h +++ b/lib/acl/acl.h @@ -9,6 +9,11 @@ extern"C" { #endif /* __cplusplus */ +extern int acl_logtype; +#define ACL_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, acl_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + #define RTE_ACL_QUAD_MAX 5 #define RTE_ACL_QUAD_SIZE 4 #define RTE_ACL_QUAD_SINGLE UINT64_C(0x7f7f7f7f00000000) diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c index 2816632803bd..0e29dc886c93 100644 --- a/lib/acl/acl_bld.c +++ b/lib/acl/acl_bld.c @@ -1014,8 +1014,8 @@ build_trie(struct acl_build_context *context, struct rte_acl_build_rule *head, break; default: - RTE_LOG(ERR, ACL, - "Error in rule[%u] type - %hhu\n", + ACL_LOG(ERR, + "Error in rule[%u] type - %hhu", rule->f->data.userdata, rule->config->defs[n].type); return NULL; @@ -1371,7 +1371,7 @@ acl_build_tries(struct acl_build_context *context, last = build_one_trie(context, rule_sets, n, context->node_max); if (context->bld_tries[n].trie == NULL) { - RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n); + ACL_LOG(ERR, "Build of %u-th trie failed", n); return -ENOMEM; } @@ -1380,8 +1380,7 @@ acl_build_tries(struct acl_build_context *context, break; if (num_tries == RTE_DIM(context->tries)) { - RTE_LOG(ERR, ACL, - "Exceeded max number of tries: %u\n", + ACL_LOG(ERR, "Exceeded max number of tries: %u", num_tries); return -ENOMEM; } @@ -1406,7 +1405,7 @@ acl_build_tries(struct acl_build_context *context, */ last = build_one_trie(context, rule_sets, n, INT32_MAX); if (context->bld_tries[n].trie == NULL || last != NULL) { - RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n); + ACL_LOG(ERR, "Build of %u-th trie failed", n); return -ENOMEM; } @@ -1421,10 +1420,11 @@ acl_build_log(const struct acl_build_context *ctx) { uint32_t n; - RTE_LOG(DEBUG, ACL, "Build phase for ACL \"%s\":\n" + ACL_LOG(DEBUG, + "Build phase for ACL \"%s\":\n" "node limit for tree split: %u\n" "nodes created: %u\n" - "memory consumed: %zu\n", + "memory consumed: %zu", ctx->acx->name, ctx->node_max, ctx->num_nodes, @@ -1432,7 +1432,7 @@ acl_build_log(const struct acl_build_context *ctx) for (n = 0; n < RTE_DIM(ctx->tries); n++) { if (ctx->tries[n].count != 0) - RTE_LOG(DEBUG, ACL, + ACL_LOG(DEBUG, "trie %u: number of rules: %u, indexes: %u\n", n, ctx->tries[n].count, ctx->tries[n].num_data_indexes); @@ -1523,8 +1523,8 @@ acl_bld(struct acl_build_context *bcx, struct rte_acl_ctx *ctx, /* build phase runs out of memory. */ if (rc != 0) { - RTE_LOG(ERR, ACL, - "ACL context: %s, %s() failed with error code: %d\n", + ACL_LOG(ERR, + "ACL context: %s, %s() failed with error code: %d", bcx->acx->name, __func__, rc); return rc; } @@ -1565,9 +1565,9 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg) for (i = 0; i != cfg->num_fields; i++) { if (cfg->defs[i].type > RTE_ACL_FIELD_TYPE_BITMASK) { - RTE_LOG(ERR, ACL, - "ACL context: %s, invalid type: %hhu for %u-th field\n", - ctx->name, cfg->defs[i].type, i); + ACL_LOG(ERR, + "ACL context: %s, invalid type: %hhu for %u-th field", + ctx->name, cfg->defs[i].type, i); return -EINVAL; } for (j = 0; @@ -1577,9 +1577,9 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg) ; if (j == RTE_DIM(field_sizes)) { - RTE_LOG(ERR, ACL, - "ACL context: %s, invalid size: %hhu for %u-th field\n", - ctx->name, cfg->defs[i].size, i); + ACL_LOG(ERR, + "ACL context: %s, invalid size: %hhu for %u-th field\n", + ctx->name, cfg->defs[i].size, i); return -EINVAL; } } diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c index e759a2ca1598..8d2a5451b0d5 100644 --- a/lib/acl/acl_gen.c +++ b/lib/acl/acl_gen.c @@ -32,18 +32,19 @@ struct rte_acl_indices { static void acl_gen_log_stats(const struct rte_acl_ctx *ctx, - const struct acl_node_counters *counts, - const struct rte_acl_indices *indices, - size_t max_size) + const struct acl_node_counters *counts, + const struct rte_acl_indices *indices, + size_t max_size) { - RTE_LOG(DEBUG, ACL, "Gen phase for ACL \"%s\":\n" + ACL_LOG(DEBUG, + "Gen phase for ACL \"%s\":\n" "runtime memory footprint on socket %d:\n" "single nodes/bytes used: %d/%zu\n" "quad nodes/vectors/bytes used: %d/%d/%zu\n" "DFA nodes/group64/bytes used: %d/%d/%zu\n" "match nodes/bytes used: %d/%zu\n" "total: %zu bytes\n" - "max limit: %zu bytes\n", + "max limit: %zu bytes", ctx->name, ctx->socket_id, counts->single, counts->single * sizeof(uint64_t), counts->quad, counts->quad_vectors, @@ -470,9 +471,9 @@ rte_acl_gen(struct rte_acl_ctx *ctx, struct rte_acl_trie *trie, XMM_SIZE; if (total_size > max_size) { - RTE_LOG(DEBUG, ACL, + ACL_LOG(DEBUG, "Gen phase for ACL ctx \"%s\" exceeds max_size limit, " - "bytes required: %zu, allowed: %zu\n", + "bytes required: %zu, allowed: %zu", ctx->name, total_size, max_size); return -ERANGE; } @@ -480,8 +481,8 @@ rte_acl_gen(struct rte_acl_ctx *ctx, struct rte_acl_trie *trie, mem = rte_zmalloc_socket(ctx->name, total_size, RTE_CACHE_LINE_SIZE, ctx->socket_id); if (mem == NULL) { - RTE_LOG(ERR, ACL, - "allocation of %zu bytes on socket %d for %s failed\n", + ACL_LOG(ERR, + "allocation of %zu bytes on socket %d for %s failed", total_size, ctx->socket_id, ctx->name); return -ENOMEM; } diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c index a61c3ba188da..9cc94b6f9633 100644 --- a/lib/acl/rte_acl.c +++ b/lib/acl/rte_acl.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "acl.h" @@ -400,15 +401,15 @@ rte_acl_create(const struct rte_acl_param *param) te = rte_zmalloc("ACL_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, ACL, "Cannot allocate tailq entry!\n"); + ACL_LOG(ERR, "Cannot allocate tailq entry!"); goto exit; } ctx = rte_zmalloc_socket(name, sz, RTE_CACHE_LINE_SIZE, param->socket_id); if (ctx == NULL) { - RTE_LOG(ERR, ACL, - "allocation of %zu bytes on socket %d for %s failed\n", + ACL_LOG(ERR, + "allocation of %zu bytes on socket %d for %s failed", sz, param->socket_id, name); rte_free(te); goto exit; @@ -474,8 +475,8 @@ rte_acl_add_rules(struct rte_acl_ctx *ctx, const struct rte_acl_rule *rules, ((uintptr_t)rules + i * ctx->rule_sz); rc = acl_check_rule(&rv->data); if (rc != 0) { - RTE_LOG(ERR, ACL, "%s(%s): rule #%u is invalid\n", - __func__, ctx->name, i + 1); + ACL_LOG(ERR, "%s: rule #%u is invalid", + ctx->name, i + 1); return rc; } } @@ -544,3 +545,5 @@ rte_acl_list_dump(void) } rte_mcfg_tailq_read_unlock(); } + +RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO); diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c index f14d7b4fa26e..a62e664e1224 100644 --- a/lib/acl/tb_mem.c +++ b/lib/acl/tb_mem.c @@ -4,6 +4,8 @@ #include "tb_mem.h" +#include + /* * Memory management routines for temporary memory. * That memory is used only during build phase and is released after @@ -15,6 +17,8 @@ * in the pool->fail before calling tb_alloc() for the given pool first time. */ +extern int acl_logtype; + static struct tb_mem_block * tb_pool(struct tb_mem_pool *pool, size_t sz) { @@ -25,8 +29,9 @@ tb_pool(struct tb_mem_pool *pool, size_t sz) size = sz + pool->alignment - 1; block = calloc(1, size + sizeof(*pool->block)); if (block == NULL) { - RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated " - "by pool: %zu bytes\n", __func__, sz, pool->alloc); + rte_log(RTE_LOG_ERR, acl_logtype, + "%s(%zu)\n failed, currently allocated by pool: %zu bytes\n", + __func__, sz, pool->alloc); siglongjmp(pool->fail, -ENOMEM); return NULL; } diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 128bfabd94e1..871f2c38298c 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -349,14 +349,12 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, - {RTE_LOGTYPE_MALLOC, "lib.malloc"}, {RTE_LOGTYPE_RING, "lib.ring"}, {RTE_LOGTYPE_MEMPOOL, "lib.mempool"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, {RTE_LOGTYPE_LPM, "lib.lpm"}, {RTE_LOGTYPE_KNI, "lib.kni"}, - {RTE_LOGTYPE_ACL, "lib.acl"}, {RTE_LOGTYPE_POWER, "lib.power"}, {RTE_LOGTYPE_METER, "lib.meter"}, {RTE_LOGTYPE_SCHED, "lib.sched"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 1f259b2abc5a..d707098b6359 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -27,7 +27,7 @@ extern "C" { /* SDK log type */ #define RTE_LOGTYPE_EAL 0 /**< Log related to eal. */ -#define RTE_LOGTYPE_MALLOC 1 /**< Log related to malloc. */ + /* was RTE_LOGTYPE_MALLOC */ #define RTE_LOGTYPE_RING 2 /**< Log related to ring. */ #define RTE_LOGTYPE_MEMPOOL 3 /**< Log related to mempool. */ /* was RTE_LOGTYPE_TIMER */ @@ -35,7 +35,7 @@ extern "C" { #define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ #define RTE_LOGTYPE_LPM 7 /**< Log related to LPM. */ #define RTE_LOGTYPE_KNI 8 /**< Log related to KNI. */ -#define RTE_LOGTYPE_ACL 9 /**< Log related to ACL. */ + /* was RTE_LOGTYPE_ACL */ #define RTE_LOGTYPE_POWER 10 /**< Log related to power. */ #define RTE_LOGTYPE_METER 11 /**< Log related to QoS meter. */ #define RTE_LOGTYPE_SCHED 12 /**< Log related to QoS port scheduler. */ -- 2.39.1