Skip to content

Commit ae67895

Browse files
lib: add more logging helpers
Add helpers for logging messages in libraries instead of calling RTE_LOG() directly. Those helpers take care of adding a \n: this will make the transition to RTE_LOG_LINE trivial. Note: - for acl and sched libraries that still has some debug multilines messages, a direct call to RTE_LOG is used: this will make it easier to notice such special cases, Signed-off-by: David Marchand <david.marchand@redhat.com>
1 parent f286e83 commit ae67895

File tree

139 files changed

+2435
-2315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+2435
-2315
lines changed

lib/acl/acl_bld.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,8 @@ build_trie(struct acl_build_context *context, struct rte_acl_build_rule *head,
10171017
break;
10181018

10191019
default:
1020-
RTE_LOG(ERR, ACL,
1021-
"Error in rule[%u] type - %hhu\n",
1020+
ACL_LOG(ERR,
1021+
"Error in rule[%u] type - %hhu",
10221022
rule->f->data.userdata,
10231023
rule->config->defs[n].type);
10241024
return NULL;
@@ -1374,7 +1374,7 @@ acl_build_tries(struct acl_build_context *context,
13741374

13751375
last = build_one_trie(context, rule_sets, n, context->node_max);
13761376
if (context->bld_tries[n].trie == NULL) {
1377-
RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n);
1377+
ACL_LOG(ERR, "Build of %u-th trie failed", n);
13781378
return -ENOMEM;
13791379
}
13801380

@@ -1383,8 +1383,8 @@ acl_build_tries(struct acl_build_context *context,
13831383
break;
13841384

13851385
if (num_tries == RTE_DIM(context->tries)) {
1386-
RTE_LOG(ERR, ACL,
1387-
"Exceeded max number of tries: %u\n",
1386+
ACL_LOG(ERR,
1387+
"Exceeded max number of tries: %u",
13881388
num_tries);
13891389
return -ENOMEM;
13901390
}
@@ -1409,7 +1409,7 @@ acl_build_tries(struct acl_build_context *context,
14091409
*/
14101410
last = build_one_trie(context, rule_sets, n, INT32_MAX);
14111411
if (context->bld_tries[n].trie == NULL || last != NULL) {
1412-
RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n);
1412+
ACL_LOG(ERR, "Build of %u-th trie failed", n);
14131413
return -ENOMEM;
14141414
}
14151415

@@ -1435,8 +1435,8 @@ acl_build_log(const struct acl_build_context *ctx)
14351435

14361436
for (n = 0; n < RTE_DIM(ctx->tries); n++) {
14371437
if (ctx->tries[n].count != 0)
1438-
RTE_LOG(DEBUG, ACL,
1439-
"trie %u: number of rules: %u, indexes: %u\n",
1438+
ACL_LOG(DEBUG,
1439+
"trie %u: number of rules: %u, indexes: %u",
14401440
n, ctx->tries[n].count,
14411441
ctx->tries[n].num_data_indexes);
14421442
}
@@ -1526,8 +1526,8 @@ acl_bld(struct acl_build_context *bcx, struct rte_acl_ctx *ctx,
15261526

15271527
/* build phase runs out of memory. */
15281528
if (rc != 0) {
1529-
RTE_LOG(ERR, ACL,
1530-
"ACL context: %s, %s() failed with error code: %d\n",
1529+
ACL_LOG(ERR,
1530+
"ACL context: %s, %s() failed with error code: %d",
15311531
bcx->acx->name, __func__, rc);
15321532
return rc;
15331533
}
@@ -1568,8 +1568,8 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
15681568

15691569
for (i = 0; i != cfg->num_fields; i++) {
15701570
if (cfg->defs[i].type > RTE_ACL_FIELD_TYPE_BITMASK) {
1571-
RTE_LOG(ERR, ACL,
1572-
"ACL context: %s, invalid type: %hhu for %u-th field\n",
1571+
ACL_LOG(ERR,
1572+
"ACL context: %s, invalid type: %hhu for %u-th field",
15731573
ctx->name, cfg->defs[i].type, i);
15741574
return -EINVAL;
15751575
}
@@ -1580,8 +1580,8 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
15801580
;
15811581

15821582
if (j == RTE_DIM(field_sizes)) {
1583-
RTE_LOG(ERR, ACL,
1584-
"ACL context: %s, invalid size: %hhu for %u-th field\n",
1583+
ACL_LOG(ERR,
1584+
"ACL context: %s, invalid size: %hhu for %u-th field",
15851585
ctx->name, cfg->defs[i].size, i);
15861586
return -EINVAL;
15871587
}

lib/acl/acl_gen.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,18 +471,18 @@ rte_acl_gen(struct rte_acl_ctx *ctx, struct rte_acl_trie *trie,
471471
XMM_SIZE;
472472

473473
if (total_size > max_size) {
474-
RTE_LOG(DEBUG, ACL,
474+
ACL_LOG(DEBUG,
475475
"Gen phase for ACL ctx \"%s\" exceeds max_size limit, "
476-
"bytes required: %zu, allowed: %zu\n",
476+
"bytes required: %zu, allowed: %zu",
477477
ctx->name, total_size, max_size);
478478
return -ERANGE;
479479
}
480480

481481
mem = rte_zmalloc_socket(ctx->name, total_size, RTE_CACHE_LINE_SIZE,
482482
ctx->socket_id);
483483
if (mem == NULL) {
484-
RTE_LOG(ERR, ACL,
485-
"allocation of %zu bytes on socket %d for %s failed\n",
484+
ACL_LOG(ERR,
485+
"allocation of %zu bytes on socket %d for %s failed",
486486
total_size, ctx->socket_id, ctx->name);
487487
return -ENOMEM;
488488
}

lib/acl/acl_log.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44

55
extern int acl_logtype;
66
#define RTE_LOGTYPE_ACL acl_logtype
7+
#define ACL_LOG(level, fmt, ...) \
8+
RTE_LOG(level, ACL, fmt "\n", ## __VA_ARGS__)

lib/acl/rte_acl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,15 @@ rte_acl_create(const struct rte_acl_param *param)
399399
te = rte_zmalloc("ACL_TAILQ_ENTRY", sizeof(*te), 0);
400400

401401
if (te == NULL) {
402-
RTE_LOG(ERR, ACL, "Cannot allocate tailq entry!\n");
402+
ACL_LOG(ERR, "Cannot allocate tailq entry!");
403403
goto exit;
404404
}
405405

406406
ctx = rte_zmalloc_socket(name, sz, RTE_CACHE_LINE_SIZE, param->socket_id);
407407

408408
if (ctx == NULL) {
409-
RTE_LOG(ERR, ACL,
410-
"allocation of %zu bytes on socket %d for %s failed\n",
409+
ACL_LOG(ERR,
410+
"allocation of %zu bytes on socket %d for %s failed",
411411
sz, param->socket_id, name);
412412
rte_free(te);
413413
goto exit;
@@ -473,7 +473,7 @@ rte_acl_add_rules(struct rte_acl_ctx *ctx, const struct rte_acl_rule *rules,
473473
((uintptr_t)rules + i * ctx->rule_sz);
474474
rc = acl_check_rule(&rv->data);
475475
if (rc != 0) {
476-
RTE_LOG(ERR, ACL, "%s(%s): rule #%u is invalid\n",
476+
ACL_LOG(ERR, "%s(%s): rule #%u is invalid",
477477
__func__, ctx->name, i + 1);
478478
return rc;
479479
}

lib/acl/tb_mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ tb_pool(struct tb_mem_pool *pool, size_t sz)
2626
size = sz + pool->alignment - 1;
2727
block = calloc(1, size + sizeof(*pool->block));
2828
if (block == NULL) {
29-
RTE_LOG(ERR, ACL, "%s(%zu) failed, currently allocated by pool: %zu bytes\n",
29+
ACL_LOG(ERR, "%s(%zu) failed, currently allocated by pool: %zu bytes",
3030
__func__, sz, pool->alloc);
3131
siglongjmp(pool->fail, -ENOMEM);
3232
return NULL;

lib/eal/common/eal_common_bus.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ rte_bus_register(struct rte_bus *bus)
3535
RTE_VERIFY(!bus->plug || bus->unplug);
3636

3737
TAILQ_INSERT_TAIL(&rte_bus_list, bus, next);
38-
RTE_LOG(DEBUG, EAL, "Registered [%s] bus.\n", rte_bus_name(bus));
38+
EAL_LOG(DEBUG, "Registered [%s] bus.", rte_bus_name(bus));
3939
}
4040

4141
void
4242
rte_bus_unregister(struct rte_bus *bus)
4343
{
4444
TAILQ_REMOVE(&rte_bus_list, bus, next);
45-
RTE_LOG(DEBUG, EAL, "Unregistered [%s] bus.\n", rte_bus_name(bus));
45+
EAL_LOG(DEBUG, "Unregistered [%s] bus.", rte_bus_name(bus));
4646
}
4747

4848
/* Scan all the buses for registered devices */
@@ -55,7 +55,7 @@ rte_bus_scan(void)
5555
TAILQ_FOREACH(bus, &rte_bus_list, next) {
5656
ret = bus->scan();
5757
if (ret)
58-
RTE_LOG(ERR, EAL, "Scan for (%s) bus failed.\n",
58+
EAL_LOG(ERR, "Scan for (%s) bus failed.",
5959
rte_bus_name(bus));
6060
}
6161

@@ -77,14 +77,14 @@ rte_bus_probe(void)
7777

7878
ret = bus->probe();
7979
if (ret)
80-
RTE_LOG(ERR, EAL, "Bus (%s) probe failed.\n",
80+
EAL_LOG(ERR, "Bus (%s) probe failed.",
8181
rte_bus_name(bus));
8282
}
8383

8484
if (vbus) {
8585
ret = vbus->probe();
8686
if (ret)
87-
RTE_LOG(ERR, EAL, "Bus (%s) probe failed.\n",
87+
EAL_LOG(ERR, "Bus (%s) probe failed.",
8888
rte_bus_name(vbus));
8989
}
9090

@@ -133,7 +133,7 @@ rte_bus_dump(FILE *f)
133133
TAILQ_FOREACH(bus, &rte_bus_list, next) {
134134
ret = bus_dump_one(f, bus);
135135
if (ret) {
136-
RTE_LOG(ERR, EAL, "Unable to write to stream (%d)\n",
136+
EAL_LOG(ERR, "Unable to write to stream (%d)",
137137
ret);
138138
break;
139139
}
@@ -235,15 +235,15 @@ rte_bus_get_iommu_class(void)
235235
continue;
236236

237237
bus_iova_mode = bus->get_iommu_class();
238-
RTE_LOG(DEBUG, EAL, "Bus %s wants IOVA as '%s'\n",
238+
EAL_LOG(DEBUG, "Bus %s wants IOVA as '%s'",
239239
rte_bus_name(bus),
240240
bus_iova_mode == RTE_IOVA_DC ? "DC" :
241241
(bus_iova_mode == RTE_IOVA_PA ? "PA" : "VA"));
242242
if (bus_iova_mode == RTE_IOVA_PA) {
243243
buses_want_pa = true;
244244
if (!RTE_IOVA_IN_MBUF)
245-
RTE_LOG(WARNING, EAL,
246-
"Bus %s wants IOVA as PA not compatible with 'enable_iova_as_pa=false' build option.\n",
245+
EAL_LOG(WARNING,
246+
"Bus %s wants IOVA as PA not compatible with 'enable_iova_as_pa=false' build option.",
247247
rte_bus_name(bus));
248248
} else if (bus_iova_mode == RTE_IOVA_VA)
249249
buses_want_va = true;
@@ -255,8 +255,8 @@ rte_bus_get_iommu_class(void)
255255
} else {
256256
mode = RTE_IOVA_DC;
257257
if (buses_want_va) {
258-
RTE_LOG(WARNING, EAL, "Some buses want 'VA' but forcing 'DC' because other buses want 'PA'.\n");
259-
RTE_LOG(WARNING, EAL, "Depending on the final decision by the EAL, not all buses may be able to initialize.\n");
258+
EAL_LOG(WARNING, "Some buses want 'VA' but forcing 'DC' because other buses want 'PA'.");
259+
EAL_LOG(WARNING, "Depending on the final decision by the EAL, not all buses may be able to initialize.");
260260
}
261261
}
262262

lib/eal/common/eal_common_class.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <rte_class.h>
1010
#include <rte_debug.h>
1111

12+
#include "eal_private.h"
13+
1214
static struct rte_class_list rte_class_list =
1315
TAILQ_HEAD_INITIALIZER(rte_class_list);
1416

@@ -19,14 +21,14 @@ rte_class_register(struct rte_class *class)
1921
RTE_VERIFY(class->name && strlen(class->name));
2022

2123
TAILQ_INSERT_TAIL(&rte_class_list, class, next);
22-
RTE_LOG(DEBUG, EAL, "Registered [%s] device class.\n", class->name);
24+
EAL_LOG(DEBUG, "Registered [%s] device class.", class->name);
2325
}
2426

2527
void
2628
rte_class_unregister(struct rte_class *class)
2729
{
2830
TAILQ_REMOVE(&rte_class_list, class, next);
29-
RTE_LOG(DEBUG, EAL, "Unregistered [%s] device class.\n", class->name);
31+
EAL_LOG(DEBUG, "Unregistered [%s] device class.", class->name);
3032
}
3133

3234
struct rte_class *

lib/eal/common/eal_common_config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int
3131
eal_set_runtime_dir(const char *run_dir)
3232
{
3333
if (strlcpy(runtime_dir, run_dir, PATH_MAX) >= PATH_MAX) {
34-
RTE_LOG(ERR, EAL, "Runtime directory string too long\n");
34+
EAL_LOG(ERR, "Runtime directory string too long");
3535
return -1;
3636
}
3737

lib/eal/common/eal_common_debug.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
#include <rte_debug.h>
1212
#include <rte_errno.h>
1313

14+
#include "eal_private.h"
15+
1416
void
1517
__rte_panic(const char *funcname, const char *format, ...)
1618
{
1719
va_list ap;
1820

19-
rte_log(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, "PANIC in %s():\n", funcname);
21+
EAL_LOG(CRIT, "PANIC in %s():", funcname);
2022
va_start(ap, format);
2123
rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap);
2224
va_end(ap);
@@ -42,7 +44,7 @@ rte_exit(int exit_code, const char *format, ...)
4244
va_end(ap);
4345

4446
if (rte_eal_cleanup() != 0 && rte_errno != EALREADY)
45-
RTE_LOG(CRIT, EAL,
46-
"EAL could not release all resources\n");
47+
EAL_LOG(CRIT,
48+
"EAL could not release all resources");
4749
exit(exit_code);
4850
}

0 commit comments

Comments
 (0)