@@ -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;
}
@@ -5,6 +5,7 @@
#include <rte_acl.h>
#include "tb_mem.h"
#include "acl.h"
+#include "acl_log.h"
#define ACL_POOL_ALIGN 8
#define ACL_POOL_ALLOC_MIN 0x800000
@@ -1014,8 +1015,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 +1372,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 +1381,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 +1406,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 +1421,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 +1433,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 +1524,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 +1566,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 +1578,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;
}
}
@@ -4,6 +4,7 @@
#include <rte_acl.h>
#include "acl.h"
+#include "acl_log.h"
#define QRANGE_MIN ((uint8_t)INT8_MIN)
@@ -32,18 +33,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 +472,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 +482,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;
}
new file mode 100644
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#ifndef _ACL_LOG_H_
+#define _ACL_LOG_H_
+
+extern int acl_logtype;
+#define ACL_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, acl_logtype, \
+ "%s(): " fmt "\n", __func__, ##args)
+
+#endif /* _ACL_LOG_H_ */
@@ -6,8 +6,10 @@
#include <rte_string_fns.h>
#include <rte_acl.h>
#include <rte_tailq.h>
+#include <rte_log.h>
#include "acl.h"
+#include "acl_log.h"
TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
@@ -400,15 +402,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 +476,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 +546,5 @@ rte_acl_list_dump(void)
}
rte_mcfg_tailq_read_unlock();
}
+
+RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO);
@@ -3,6 +3,9 @@
*/
#include "tb_mem.h"
+#include "acl_log.h"
+
+#include <rte_log.h>
/*
* Memory management routines for temporary memory.
@@ -25,8 +28,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);
+ ACL_LOG(ERR,
+ "allocation size %zu failed, currently allocated by pool: %zu bytes\n",
+ sz, pool->alloc);
siglongjmp(pool->fail, -ENOMEM);
return NULL;
}
@@ -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"},
@@ -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. */