log: introduce logtype register macro
[dpdk.git] / drivers / common / dpaax / dpaax_iova_table.c
index 075053b..5ba8ed1 100644 (file)
@@ -7,9 +7,6 @@
 #include "dpaax_iova_table.h"
 #include "dpaax_logs.h"
 
-/* Global dpaax logger identifier */
-int dpaax_logger;
-
 /* Global table reference */
 struct dpaax_iova_table *dpaax_iova_table_p;
 
@@ -68,9 +65,12 @@ read_memory_node(unsigned int *count)
        *count = 0;
 
        ret = glob(MEM_NODE_PATH_GLOB, 0, NULL, &result);
+       if (ret != 0)
+               ret = glob(MEM_NODE_PATH_GLOB_VM, 0, NULL, &result);
+
        if (ret != 0) {
-               DPAAX_ERR("Unable to glob device-tree memory node: (%s)(%d)",
-                          MEM_NODE_PATH_GLOB, ret);
+               DPAAX_DEBUG("Unable to glob device-tree memory node (err: %d)",
+                       ret);
                goto out;
        }
 
@@ -78,8 +78,8 @@ read_memory_node(unsigned int *count)
                /* Either more than one memory@<addr> node found, or none.
                 * In either case, cannot work ahead.
                 */
-               DPAAX_ERR("Found (%zu) entries in device-tree. Not supported!",
-                         result.gl_pathc);
+               DPAAX_DEBUG("Found (%zu) entries in device-tree. Not supported!",
+                           result.gl_pathc);
                goto out;
        }
 
@@ -87,28 +87,29 @@ read_memory_node(unsigned int *count)
                    result.gl_pathv[0]);
        fd = open(result.gl_pathv[0], O_RDONLY);
        if (fd < 0) {
-               DPAAX_ERR("Unable to open the device-tree node: (%s)(fd=%d)",
-                         MEM_NODE_PATH_GLOB, fd);
+               DPAAX_DEBUG("Unable to open the device-tree node: (%s)(fd=%d)",
+                           MEM_NODE_PATH_GLOB, fd);
                goto cleanup;
        }
 
        /* Stat to get the file size */
        ret = fstat(fd, &statbuf);
        if (ret != 0) {
-               DPAAX_ERR("Unable to get device-tree memory node size.");
+               DPAAX_DEBUG("Unable to get device-tree memory node size.");
                goto cleanup;
        }
 
-       DPAAX_DEBUG("Size of device-tree mem node: %lu", statbuf.st_size);
+       DPAAX_DEBUG("Size of device-tree mem node: %" PRIu64, statbuf.st_size);
        if (statbuf.st_size > MEM_NODE_FILE_LEN) {
-               DPAAX_WARN("More memory nodes available than assumed.");
-               DPAAX_WARN("System may not work properly!");
+               DPAAX_DEBUG("More memory nodes available than assumed.");
+               DPAAX_DEBUG("System may not work properly!");
        }
 
        ret = read(fd, file_data, statbuf.st_size > MEM_NODE_FILE_LEN ?
                                  MEM_NODE_FILE_LEN : statbuf.st_size);
        if (ret <= 0) {
-               DPAAX_ERR("Unable to read device-tree memory node: (%d)", ret);
+               DPAAX_DEBUG("Unable to read device-tree memory node: (%d)",
+                           ret);
                goto cleanup;
        }
 
@@ -117,15 +118,15 @@ read_memory_node(unsigned int *count)
         */
        *count = (statbuf.st_size / 16);
        if ((*count) <= 0 || (statbuf.st_size % 16 != 0)) {
-               DPAAX_ERR("Invalid memory node values or count. (size=%lu)",
-                         statbuf.st_size);
+               DPAAX_DEBUG("Invalid memory node values or count. (size=%" PRIu64 ")",
+                           statbuf.st_size);
                goto cleanup;
        }
 
        /* each entry is of 16 bytes, and size/16 is total count of entries */
        nodes = malloc(sizeof(struct reg_node) * (*count));
        if (!nodes) {
-               DPAAX_ERR("Failure in allocating working memory.");
+               DPAAX_DEBUG("Failure in allocating working memory.");
                goto cleanup;
        }
        memset(nodes, 0, sizeof(struct reg_node) * (*count));
@@ -139,7 +140,8 @@ read_memory_node(unsigned int *count)
 
        DPAAX_DEBUG("Device-tree memory node data:");
        do {
-               DPAAX_DEBUG("\n    %08" PRIx64 " %08zu", nodes[j].addr, nodes[j].len);
+               DPAAX_DEBUG("    %08" PRIx64 " %08zu",
+                           nodes[j].addr, nodes[j].len);
        } while (--j);
 
 cleanup:
@@ -172,7 +174,7 @@ dpaax_iova_table_populate(void)
        }
 
        nodes = read_memory_node(&node_count);
-       if (nodes == NULL || node_count <= 0) {
+       if (nodes == NULL) {
                DPAAX_WARN("PA->VA translation not available;");
                DPAAX_WARN("Expect performance impact.");
                return -1;
@@ -240,7 +242,7 @@ dpaax_iova_table_populate(void)
        /* Release memory associated with nodes array - not required now */
        free(nodes);
 
-       DPAAX_DEBUG("Adding mem-event handler\n");
+       DPAAX_DEBUG("Adding mem-event handler");
        ret = dpaax_handle_memevents();
        if (ret) {
                DPAAX_ERR("Unable to add mem-event handler");
@@ -305,10 +307,11 @@ dpaax_iova_table_update(phys_addr_t paddr, void *vaddr, size_t length)
                         * case.
                         */
                        entry[i].pages[e_offset] = align_vaddr;
+#ifdef RTE_COMMON_DPAAX_DEBUG
                        DPAAX_DEBUG("Added: vaddr=%zu for Phy:%"PRIu64" at %zu"
                                    " remaining len %zu", align_vaddr,
                                    align_paddr, e_offset, req_length);
-
+#endif
                        /* Incoming request can be larger than the
                         * DPAAX_MEM_SPLIT size - in which case, multiple
                         * entries in entry->pages[] are filled up.
@@ -335,10 +338,11 @@ dpaax_iova_table_update(phys_addr_t paddr, void *vaddr, size_t length)
                            vaddr, paddr);
                return -1;
        }
-
+#ifdef RTE_COMMON_DPAAX_DEBUG
        DPAAX_DEBUG("Add: Found slot at (%"PRIu64")[(%zu)] for vaddr:(%p),"
                    " phy(%"PRIu64"), len(%zu)", entry[i].start, e_offset,
                    vaddr, paddr, length);
+#endif
        return 0;
 }
 
@@ -403,13 +407,13 @@ dpaax_memevent_cb(enum rte_mem_event type, const void *addr, size_t len,
                phys_addr = rte_mem_virt2phy(ms->addr);
                virt_addr = ms->addr;
                map_len = ms->len;
-
+#ifdef RTE_COMMON_DPAAX_DEBUG
                DPAAX_DEBUG("Request for %s, va=%p, virt_addr=%p,"
                            "iova=%"PRIu64", map_len=%zu",
                            type == RTE_MEM_EVENT_ALLOC ?
                            "alloc" : "dealloc",
                            va, virt_addr, phys_addr, map_len);
-
+#endif
                if (type == RTE_MEM_EVENT_ALLOC)
                        ret = dpaax_iova_table_update(phys_addr, virt_addr,
                                                      map_len);
@@ -420,9 +424,9 @@ dpaax_memevent_cb(enum rte_mem_event type, const void *addr, size_t len,
                        ret = dpaax_iova_table_update(phys_addr, 0, map_len);
 
                if (ret != 0) {
-                       DPAAX_ERR("PA-Table entry update failed. "
-                                 "Map=%d, addr=%p, len=%zu, err:(%d)",
-                                 type, va, map_len, ret);
+                       DPAAX_DEBUG("PA-Table entry update failed. "
+                                   "Map=%d, addr=%p, len=%zu, err:(%d)",
+                                   type, va, map_len, ret);
                        return;
                }
 
@@ -456,9 +460,4 @@ dpaax_handle_memevents(void)
                                               dpaax_memevent_cb, NULL);
 }
 
-RTE_INIT(dpaax_log)
-{
-       dpaax_logger = rte_log_register("pmd.common.dpaax");
-       if (dpaax_logger >= 0)
-               rte_log_set_level(dpaax_logger, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaax_logger, pmd.common.dpaax, ERR);