Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/mempool/rte_mempool.c       | 33 ++++++++++++++++++---------------
 lib/mempool/rte_mempool_log.h   | 10 ++++++++++
 lib/mempool/rte_mempool_ops.c   | 12 ++++++------
 5 files changed, 35 insertions(+), 23 deletions(-)
 create mode 100644 lib/mempool/rte_mempool_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 04c9d43351da..90d388192712 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
        {RTE_LOGTYPE_EAL,        "lib.eal"},
-       {RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
        {RTE_LOGTYPE_PMD,        "pmd"},
        {RTE_LOGTYPE_HASH,       "lib.hash"},
        {RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index a99fe383c89b..f583352ec1ea 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -29,7 +29,7 @@ extern "C" {
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
                                 /* was RTE_LOGTYPE_MALLOC */
                                 /* was RTE_LOGTYPE_RING */
-#define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
+                                /* was RTE_LOGTYPE_MEMPOOL */
                                 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index 45b5df6199b0..911a2b4dd850 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -30,6 +30,7 @@
 
 #include "rte_mempool.h"
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
 
 TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
 
@@ -774,7 +775,7 @@ rte_mempool_cache_create(uint32_t size, int socket_id)
        cache = rte_zmalloc_socket("MEMPOOL_CACHE", sizeof(*cache),
                                  RTE_CACHE_LINE_SIZE, socket_id);
        if (cache == NULL) {
-               RTE_LOG(ERR, MEMPOOL, "Cannot allocate mempool cache.\n");
+               MEMPOOL_LOG(ERR, "Cannot allocate mempool cache.");
                rte_errno = ENOMEM;
                return NULL;
        }
@@ -876,7 +877,7 @@ rte_mempool_create_empty(const char *name, unsigned n, 
unsigned elt_size,
        /* try to allocate tailq entry */
        te = rte_zmalloc("MEMPOOL_TAILQ_ENTRY", sizeof(*te), 0);
        if (te == NULL) {
-               RTE_LOG(ERR, MEMPOOL, "Cannot allocate tailq entry!\n");
+               MEMPOOL_LOG(ERR, "Cannot allocate tailq entry!");
                goto exit_unlock;
        }
 
@@ -1088,25 +1089,25 @@ void rte_mempool_check_cookies(const struct rte_mempool 
*mp,
 
                if (free == 0) {
                        if (cookie != RTE_MEMPOOL_HEADER_COOKIE1) {
-                               RTE_LOG(CRIT, MEMPOOL,
-                                       "obj=%p, mempool=%p, cookie=%" PRIx64 
"\n",
-                                       obj, (const void *) mp, cookie);
+                               MEMPOOL_LOG(CRIT,
+                                           "obj=%p, mempool=%p, cookie=%" 
PRIx64,
+                                           obj, (const void *) mp, cookie);
                                rte_panic("MEMPOOL: bad header cookie (put)\n");
                        }
                        hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE2;
                } else if (free == 1) {
                        if (cookie != RTE_MEMPOOL_HEADER_COOKIE2) {
-                               RTE_LOG(CRIT, MEMPOOL,
-                                       "obj=%p, mempool=%p, cookie=%" PRIx64 
"\n",
-                                       obj, (const void *) mp, cookie);
+                               MEMPOOL_LOG(CRIT,
+                                           "obj=%p, mempool=%p, cookie=%" 
PRIx64,
+                                           obj, (const void *) mp, cookie);
                                rte_panic("MEMPOOL: bad header cookie (get)\n");
                        }
                        hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE1;
                } else if (free == 2) {
                        if (cookie != RTE_MEMPOOL_HEADER_COOKIE1 &&
                            cookie != RTE_MEMPOOL_HEADER_COOKIE2) {
-                               RTE_LOG(CRIT, MEMPOOL,
-                                       "obj=%p, mempool=%p, cookie=%" PRIx64 
"\n",
+                               MEMPOOL_LOG(CRIT,
+                                       "obj=%p, mempool=%p, cookie=%" PRIx64,
                                        obj, (const void *) mp, cookie);
                                rte_panic("MEMPOOL: bad header cookie 
(audit)\n");
                        }
@@ -1114,9 +1115,9 @@ void rte_mempool_check_cookies(const struct rte_mempool 
*mp,
                tlr = rte_mempool_get_trailer(obj);
                cookie = tlr->cookie;
                if (cookie != RTE_MEMPOOL_TRAILER_COOKIE) {
-                       RTE_LOG(CRIT, MEMPOOL,
-                               "obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
-                               obj, (const void *) mp, cookie);
+                       MEPOOL_LOG(CRIT,
+                                  "obj=%p, mempool=%p, cookie=%" PRIx64,
+                                  obj, (const void *) mp, cookie);
                        rte_panic("MEMPOOL: bad trailer cookie\n");
                }
        }
@@ -1200,7 +1201,7 @@ mempool_audit_cache(const struct rte_mempool *mp)
                const struct rte_mempool_cache *cache;
                cache = &mp->local_cache[lcore_id];
                if (cache->len > RTE_DIM(cache->objs)) {
-                       RTE_LOG(CRIT, MEMPOOL, "badness on cache[%u]\n",
+                       MEMPOOL_LOG(CRIT, "badness on cache[%u]",
                                lcore_id);
                        rte_panic("MEMPOOL: invalid cache len\n");
                }
@@ -1429,7 +1430,7 @@ 
rte_mempool_event_callback_register(rte_mempool_event_callback *func,
 
        cb = calloc(1, sizeof(*cb));
        if (cb == NULL) {
-               RTE_LOG(ERR, MEMPOOL, "Cannot allocate event callback!\n");
+               MEMPOOL_LOG(ERR, "Cannot allocate event callback!");
                ret = -ENOMEM;
                goto exit;
        }
@@ -1563,3 +1564,5 @@ RTE_INIT(mempool_init_telemetry)
        rte_telemetry_register_cmd("/mempool/info", mempool_handle_info,
                "Returns mempool info. Parameters: pool_name");
 }
+
+RTE_LOG_REGISTER_DEFAULT(mempool_logtype, INFO);
diff --git a/lib/mempool/rte_mempool_log.h b/lib/mempool/rte_mempool_log.h
new file mode 100644
index 000000000000..3d252f761408
--- /dev/null
+++ b/lib/mempool/rte_mempool_log.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation.
+ * Copyright 2014 6WIND S.A.
+ */
+
+extern int mempool_logtype;
+
+#define MEMPOOL_LOG(level, fmt, args...)               \
+       rte_log(RTE_LOG_ ## level, mempool_logtype,     \
+               "%s(): " fmt "\n", __func__, ##args)
diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c
index 3b43edc548a0..e04e75b91ba6 100644
--- a/lib/mempool/rte_mempool_ops.c
+++ b/lib/mempool/rte_mempool_ops.c
@@ -12,6 +12,7 @@
 #include <dev_driver.h>
 
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
 
 /* indirect jump table to support external memory pools. */
 struct rte_mempool_ops_table rte_mempool_ops_table = {
@@ -31,23 +32,22 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h)
        if (rte_mempool_ops_table.num_ops >=
                        RTE_MEMPOOL_MAX_OPS_IDX) {
                rte_spinlock_unlock(&rte_mempool_ops_table.sl);
-               RTE_LOG(ERR, MEMPOOL,
-                       "Maximum number of mempool ops structs exceeded\n");
+               MEMPOOL_LOG(ERR,
+                       "Maximum number of mempool ops structs exceeded");
                return -ENOSPC;
        }
 
        if (h->alloc == NULL || h->enqueue == NULL ||
                        h->dequeue == NULL || h->get_count == NULL) {
                rte_spinlock_unlock(&rte_mempool_ops_table.sl);
-               RTE_LOG(ERR, MEMPOOL,
-                       "Missing callback while registering mempool ops\n");
+               MEMPOOL_LOG(ERR,
+                           "Missing callback while registering mempool ops");
                return -EINVAL;
        }
 
        if (strlen(h->name) >= sizeof(ops->name) - 1) {
                rte_spinlock_unlock(&rte_mempool_ops_table.sl);
-               RTE_LOG(DEBUG, EAL, "%s(): mempool_ops <%s>: name too long\n",
-                               __func__, h->name);
+               MEMPOOL_LOG(DEBUG, "mempool_ops <%s>: name too long\n", 
h->name);
                rte_errno = EEXIST;
                return -EEXIST;
        }
-- 
2.39.1

Reply via email to