[dpdk-dev] [PATCH 5/5] add FILE arguement to debug functions
Stephen Hemminger
stephen at networkplumber.org
Sat May 3 01:42:56 CEST 2014
The DPDK dump functions are useful for remote debugging of an
applications. But when application runs as a daemon, stdout
is typically routed to /dev/null.
Instead change all these functions to take a stdio FILE * handle
instead. An application can then use open_memstream() to capture
the output.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
app/dump_cfg/main.c | 6 +-
app/test-pmd/cmdline.c | 16 +++---
app/test-pmd/testpmd.c | 2
app/test/commands.c | 16 +++---
app/test/test_common.c | 4 -
app/test/test_ivshmem.c | 4 -
app/test/test_logs.c | 2
app/test/test_malloc.c | 8 +--
app/test/test_mbuf.c | 14 ++---
app/test/test_memory.c | 2
app/test/test_mempool.c | 14 ++---
app/test/test_mempool_perf.c | 6 +-
app/test/test_memzone.c | 32 ++++++------
app/test/test_pci.c | 2
app/test/test_ring.c | 42 ++++++++--------
app/test/test_timer.c | 2
examples/l2fwd-ivshmem/host/host.c | 2
lib/librte_eal/common/eal_common_devargs.c | 12 ++--
lib/librte_eal/common/eal_common_hexdump.c | 20 +++----
lib/librte_eal/common/eal_common_log.c | 8 +--
lib/librte_eal/common/eal_common_memory.c | 4 -
lib/librte_eal/common/eal_common_memzone.c | 4 -
lib/librte_eal/common/eal_common_pci.c | 12 ++--
lib/librte_eal/common/eal_common_tailqs.c | 4 -
lib/librte_eal/common/include/rte_devargs.h | 6 +-
lib/librte_eal/common/include/rte_hexdump.h | 8 ++-
lib/librte_eal/common/include/rte_log.h | 7 +-
lib/librte_eal/common/include/rte_memory.h | 5 +
lib/librte_eal/common/include/rte_memzone.h | 6 +-
lib/librte_eal/common/include/rte_pci.h | 5 +
lib/librte_eal/common/include/rte_tailq.h | 5 +
lib/librte_eal/linuxapp/eal/eal_ivshmem.c | 4 -
lib/librte_ivshmem/rte_ivshmem.c | 9 +--
lib/librte_ivshmem/rte_ivshmem.h | 4 +
lib/librte_malloc/rte_malloc.c | 16 +++---
lib/librte_malloc/rte_malloc.h | 5 +
lib/librte_mbuf/rte_mbuf.c | 10 +--
lib/librte_mbuf/rte_mbuf.h | 4 +
lib/librte_mempool/rte_mempool.c | 72 ++++++++++++++--------------
lib/librte_mempool/rte_mempool.h | 10 +++
lib/librte_ring/rte_ring.c | 52 ++++++++++----------
lib/librte_ring/rte_ring.h | 10 +++
lib/librte_timer/rte_timer.c | 14 ++---
lib/librte_timer/rte_timer.h | 6 +-
44 files changed, 271 insertions(+), 225 deletions(-)
--- a/app/test/commands.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test/commands.c 2014-05-02 16:31:16.423593331 -0700
@@ -275,19 +275,19 @@ static void cmd_dump_parsed(void *parsed
struct cmd_dump_result *res = parsed_result;
if (!strcmp(res->dump, "dump_physmem"))
- rte_dump_physmem_layout();
+ rte_dump_physmem_layout(stdout);
else if (!strcmp(res->dump, "dump_memzone"))
- rte_memzone_dump();
+ rte_memzone_dump(stdout);
else if (!strcmp(res->dump, "dump_log_history"))
- rte_log_dump_history();
+ rte_log_dump_history(stdout);
else if (!strcmp(res->dump, "dump_struct_sizes"))
dump_struct_sizes();
else if (!strcmp(res->dump, "dump_ring"))
- rte_ring_list_dump();
+ rte_ring_list_dump(stdout);
else if (!strcmp(res->dump, "dump_mempool"))
- rte_mempool_list_dump();
+ rte_mempool_list_dump(stdout);
else if (!strcmp(res->dump, "dump_devargs"))
- rte_eal_devargs_dump();
+ rte_eal_devargs_dump(stdout);
}
cmdline_parse_token_string_t cmd_dump_dump =
@@ -325,7 +325,7 @@ static void cmd_dump_one_parsed(void *pa
cmdline_printf(cl, "Cannot find ring\n");
return;
}
- rte_ring_dump(r);
+ rte_ring_dump(stdout, r);
}
else if (!strcmp(res->dump, "dump_mempool")) {
struct rte_mempool *mp;
@@ -334,7 +334,7 @@ static void cmd_dump_one_parsed(void *pa
cmdline_printf(cl, "Cannot find mempool\n");
return;
}
- rte_mempool_dump(mp);
+ rte_mempool_dump(stdout, mp);
}
}
--- a/app/test/test_ivshmem.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test/test_ivshmem.c 2014-05-02 16:31:16.423593331 -0700
@@ -263,10 +263,10 @@ test_ivshmem_api_test(void)
ASSERT(strnlen(buf, sizeof(buf)) != 0, "Buffer is empty");
/* make sure we don't segfault */
- rte_ivshmem_metadata_dump(NULL);
+ rte_ivshmem_metadata_dump(stdout, NULL);
/* dump our metadata */
- rte_ivshmem_metadata_dump(METADATA_NAME);
+ rte_ivshmem_metadata_dump(stdout, METADATA_NAME);
return 0;
}
--- a/app/test/test_logs.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test/test_logs.c 2014-05-02 16:31:16.423593331 -0700
@@ -86,7 +86,7 @@ test_logs(void)
RTE_LOG(DEBUG, TESTAPP1, "this is a debug level message\n");
RTE_LOG(DEBUG, TESTAPP2, "debug level message (not displayed)\n");
- rte_log_dump_history();
+ rte_log_dump_history(stdout);
return 0;
}
--- a/app/test/test_malloc.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test/test_malloc.c 2014-05-02 16:31:16.423593331 -0700
@@ -162,7 +162,7 @@ test_align_overlap_per_lcore(__attribute
rte_free(p2);
rte_free(p3);
}
- rte_malloc_dump_stats("dummy");
+ rte_malloc_dump_stats(stdout, "dummy");
return ret;
}
@@ -258,7 +258,7 @@ test_reordered_free_per_lcore(__attribut
break;
}
}
- rte_malloc_dump_stats("dummy");
+ rte_malloc_dump_stats(stdout, "dummy");
return ret;
}
@@ -365,7 +365,7 @@ test_multi_alloc_statistics(void)
if (!p1)
return -1;
rte_free(p1);
- rte_malloc_dump_stats("stats");
+ rte_malloc_dump_stats(stdout, "stats");
rte_malloc_get_socket_stats(socket,&post_stats);
/* Check statistics reported are correct */
@@ -466,7 +466,7 @@ test_rte_malloc_type_limits(void)
*/
const char *typename = "limit_test";
rte_malloc_set_limit(typename, 64 * 1024);
- rte_malloc_dump_stats(typename);
+ rte_malloc_dump_stats(stdout, typename);
return 0;
}
--- a/app/test/test_mbuf.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test/test_mbuf.c 2014-05-02 16:31:16.423593331 -0700
@@ -158,7 +158,7 @@ test_pktmbuf_with_non_ascii_data(void)
memset(data, 0xff, rte_pktmbuf_pkt_len(m));
if (!rte_pktmbuf_is_contiguous(m))
GOTO_FAIL("Buffer should be continuous");
- rte_pktmbuf_dump(m, MBUF_TEST_DATA_LEN);
+ rte_pktmbuf_dump(stdout, m, MBUF_TEST_DATA_LEN);
rte_pktmbuf_free(m);
@@ -191,7 +191,7 @@ test_one_pktmbuf(void)
if (rte_pktmbuf_pkt_len(m) != 0)
GOTO_FAIL("Bad length");
- rte_pktmbuf_dump(m, 0);
+ rte_pktmbuf_dump(stdout, m, 0);
/* append data */
@@ -205,8 +205,8 @@ test_one_pktmbuf(void)
memset(data, 0x66, rte_pktmbuf_pkt_len(m));
if (!rte_pktmbuf_is_contiguous(m))
GOTO_FAIL("Buffer should be continuous");
- rte_pktmbuf_dump(m, MBUF_TEST_DATA_LEN);
- rte_pktmbuf_dump(m, 2*MBUF_TEST_DATA_LEN);
+ rte_pktmbuf_dump(stdout, m, MBUF_TEST_DATA_LEN);
+ rte_pktmbuf_dump(stdout, m, 2*MBUF_TEST_DATA_LEN);
/* this append should fail */
@@ -274,7 +274,7 @@ test_one_pktmbuf(void)
rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 1);
rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 0);
- rte_pktmbuf_dump(m, 0);
+ rte_pktmbuf_dump(stdout, m, 0);
/* this prepend should fail */
@@ -713,8 +713,8 @@ test_refcnt_mbuf(void)
rte_panic("refernced mbufs: %u, freed mbufs: %u\n",
tref, refcnt_lcore[master]);
- rte_mempool_dump(refcnt_pool);
- rte_ring_dump(refcnt_mbuf_ring);
+ rte_mempool_dump(stdout, refcnt_pool);
+ rte_ring_dump(stdout, refcnt_mbuf_ring);
#endif
return (0);
--- a/app/test/test_mempool.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test/test_mempool.c 2014-05-02 16:31:16.423593331 -0700
@@ -110,12 +110,12 @@ test_mempool_basic(void)
unsigned i, j;
/* dump the mempool status */
- rte_mempool_dump(mp);
+ rte_mempool_dump(stdout, mp);
printf("get an object\n");
if (rte_mempool_get(mp, &obj) < 0)
return -1;
- rte_mempool_dump(mp);
+ rte_mempool_dump(stdout, mp);
/* tests that improve coverage */
printf("get object count\n");
@@ -136,7 +136,7 @@ test_mempool_basic(void)
printf("put the object back\n");
rte_mempool_put(mp, obj);
- rte_mempool_dump(mp);
+ rte_mempool_dump(stdout, mp);
printf("get 2 objects\n");
if (rte_mempool_get(mp, &obj) < 0)
@@ -145,12 +145,12 @@ test_mempool_basic(void)
rte_mempool_put(mp, obj);
return -1;
}
- rte_mempool_dump(mp);
+ rte_mempool_dump(stdout, mp);
printf("put the objects back\n");
rte_mempool_put(mp, obj);
rte_mempool_put(mp, obj2);
- rte_mempool_dump(mp);
+ rte_mempool_dump(stdout, mp);
/*
* get many objects: we cannot get them all because the cache
@@ -488,7 +488,7 @@ test_mempool(void)
return -1;
}
- rte_mempool_list_dump();
+ rte_mempool_list_dump(stdout);
/* basic tests without cache */
mp = mp_nocache;
@@ -517,7 +517,7 @@ test_mempool(void)
if (test_mempool_xmem_misc() < 0)
return -1;
- rte_mempool_list_dump();
+ rte_mempool_list_dump(stdout);
return 0;
}
--- a/app/test/test_mempool_perf.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test/test_mempool_perf.c 2014-05-02 16:31:16.423593331 -0700
@@ -161,8 +161,8 @@ per_lcore_mempool_test(__attribute__((un
ret = rte_mempool_get_bulk(mp, &obj_table[idx],
n_get_bulk);
if (unlikely(ret < 0)) {
- rte_mempool_dump(mp);
- rte_ring_dump(mp->ring);
+ rte_mempool_dump(stdout, mp);
+ rte_ring_dump(stdout, mp->ring);
/* in this case, objects are lost... */
return -1;
}
@@ -325,7 +325,7 @@ test_mempool_perf(void)
if (do_one_mempool_test(rte_lcore_count()) < 0)
return -1;
- rte_mempool_list_dump();
+ rte_mempool_list_dump(stdout);
return 0;
}
--- a/app/test/test_ring.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test/test_ring.c 2014-05-02 16:31:16.423593331 -0700
@@ -112,7 +112,7 @@ static struct rte_ring *r;
if (!(exp)) { \
printf("error at %s:%d\tcondition " #exp " failed\n", \
__func__, __LINE__); \
- rte_ring_dump(r); \
+ rte_ring_dump(stdout, r); \
return (-1); \
}
@@ -273,7 +273,7 @@ test_ring_basic_full_empty(void * const
/* check data */
TEST_RING_VERIFY(0 == memcmp(src, dst, rsz));
- rte_ring_dump(r);
+ rte_ring_dump(stdout, r);
}
return (0);
}
@@ -341,8 +341,8 @@ test_ring_basic(void)
/* check data */
if (memcmp(src, dst, cur_dst - dst)) {
- rte_hexdump("src", src, cur_src - src);
- rte_hexdump("dst", dst, cur_dst - dst);
+ rte_hexdump(stdout, "src", src, cur_src - src);
+ rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n");
goto fail;
}
@@ -387,8 +387,8 @@ test_ring_basic(void)
/* check data */
if (memcmp(src, dst, cur_dst - dst)) {
- rte_hexdump("src", src, cur_src - src);
- rte_hexdump("dst", dst, cur_dst - dst);
+ rte_hexdump(stdout, "src", src, cur_src - src);
+ rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n");
goto fail;
}
@@ -409,8 +409,8 @@ test_ring_basic(void)
/* check data */
if (memcmp(src, dst, cur_dst - dst)) {
- rte_hexdump("src", src, cur_src - src);
- rte_hexdump("dst", dst, cur_dst - dst);
+ rte_hexdump(stdout, "src", src, cur_src - src);
+ rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n");
goto fail;
}
@@ -455,8 +455,8 @@ test_ring_basic(void)
/* check data */
if (memcmp(src, dst, cur_dst - dst)) {
- rte_hexdump("src", src, cur_src - src);
- rte_hexdump("dst", dst, cur_dst - dst);
+ rte_hexdump(stdout, "src", src, cur_src - src);
+ rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n");
goto fail;
}
@@ -550,8 +550,8 @@ test_ring_burst_basic(void)
/* check data */
if (memcmp(src, dst, cur_dst - dst)) {
- rte_hexdump("src", src, cur_src - src);
- rte_hexdump("dst", dst, cur_dst - dst);
+ rte_hexdump(stdout, "src", src, cur_src - src);
+ rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n");
goto fail;
}
@@ -616,8 +616,8 @@ test_ring_burst_basic(void)
/* check data */
if (memcmp(src, dst, cur_dst - dst)) {
- rte_hexdump("src", src, cur_src - src);
- rte_hexdump("dst", dst, cur_dst - dst);
+ rte_hexdump(stdout, "src", src, cur_src - src);
+ rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n");
goto fail;
}
@@ -665,8 +665,8 @@ test_ring_burst_basic(void)
/* check data */
if (memcmp(src, dst, cur_dst - dst)) {
- rte_hexdump("src", src, cur_src - src);
- rte_hexdump("dst", dst, cur_dst - dst);
+ rte_hexdump(stdout, "src", src, cur_src - src);
+ rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n");
goto fail;
}
@@ -688,8 +688,8 @@ test_ring_burst_basic(void)
/* check data */
if (memcmp(src, dst, cur_dst - dst)) {
- rte_hexdump("src", src, cur_src - src);
- rte_hexdump("dst", dst, cur_dst - dst);
+ rte_hexdump(stdout, "src", src, cur_src - src);
+ rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n");
goto fail;
}
@@ -738,8 +738,8 @@ test_ring_burst_basic(void)
/* check data */
if (memcmp(src, dst, cur_dst - dst)) {
- rte_hexdump("src", src, cur_src - src);
- rte_hexdump("dst", dst, cur_dst - dst);
+ rte_hexdump(stdout, "src", src, cur_src - src);
+ rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n");
goto fail;
}
@@ -1388,7 +1388,7 @@ test_ring(void)
return -1;
/* dump the ring status */
- rte_ring_list_dump();
+ rte_ring_list_dump(stdout);
return 0;
}
--- a/app/test/test_timer.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test/test_timer.c 2014-05-02 16:31:16.423593331 -0700
@@ -515,7 +515,7 @@ test_timer(void)
rte_timer_stop_sync(&mytiminfo[i].tim);
}
- rte_timer_dump_stats();
+ rte_timer_dump_stats(stdout);
return 0;
}
--- a/app/test-pmd/testpmd.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test-pmd/testpmd.c 2014-05-02 16:31:16.423593331 -0700
@@ -471,7 +471,7 @@ mbuf_pool_create(uint16_t mbuf_seg_size,
rte_exit(EXIT_FAILURE, "Creation of mbuf pool for socket %u "
"failed\n", socket_id);
} else if (verbose_level > 0) {
- rte_mempool_dump(rte_mp);
+ rte_mempool_dump(stdout, rte_mp);
}
}
--- a/examples/l2fwd-ivshmem/host/host.c 2014-05-02 16:31:16.431593380 -0700
+++ b/examples/l2fwd-ivshmem/host/host.c 2014-05-02 16:31:16.423593331 -0700
@@ -243,7 +243,7 @@ generate_ivshmem_cmdline(const char *con
if (print_to_file(cmdline, config_name) < 0)
return -1;
- rte_ivshmem_metadata_dump(config_name);
+ rte_ivshmem_metadata_dump(stdout, config_name);
return 0;
}
--- a/lib/librte_eal/common/eal_common_log.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/eal_common_log.c 2014-05-02 16:31:16.423593331 -0700
@@ -202,9 +202,9 @@ int rte_log_cur_msg_logtype(void)
return log_cur_msg[lcore_id].logtype;
}
-/* Dump log history on console */
+/* Dump log history to file */
void
-rte_log_dump_history(void)
+rte_log_dump_history(FILE *out)
{
struct log_history_list tmp_log_history;
struct log_history *hist_buf;
@@ -230,7 +230,7 @@ rte_log_dump_history(void)
STAILQ_REMOVE_HEAD(&tmp_log_history, next);
/* write on stdout */
- if (fwrite(hist_buf->buf, hist_buf->size, 1, stdout) == 0) {
+ if (fwrite(hist_buf->buf, hist_buf->size, 1, out) == 0) {
rte_mempool_mp_put(log_history_mp, hist_buf);
break;
}
@@ -238,7 +238,7 @@ rte_log_dump_history(void)
/* put back message structure in pool */
rte_mempool_mp_put(log_history_mp, hist_buf);
}
- fflush(stdout);
+ fflush(out);
rte_spinlock_unlock(&log_dump_lock);
}
--- a/lib/librte_eal/common/include/rte_log.h 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/include/rte_log.h 2014-05-02 16:31:16.423593331 -0700
@@ -173,9 +173,12 @@ int rte_log_cur_msg_logtype(void);
void rte_log_set_history(int enable);
/**
- * Dump the log history to the console.
+ * Dump the log history to a file
+ *
+ * @param f
+ * A pointer to a file for output
*/
-void rte_log_dump_history(void);
+void rte_log_dump_history(FILE *f);
/**
* Add a log message to the history.
--- a/lib/librte_ivshmem/rte_ivshmem.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_ivshmem/rte_ivshmem.c 2014-05-02 16:31:16.423593331 -0700
@@ -821,9 +821,8 @@ rte_ivshmem_metadata_cmdline_generate(ch
return 0;
}
-
void
-rte_ivshmem_metadata_dump(const char *name)
+rte_ivshmem_metadata_dump(FILE *f, const char *name)
{
unsigned i = 0;
struct ivshmem_config * config;
@@ -850,7 +849,7 @@ rte_ivshmem_metadata_dump(const char *na
while (entry->mz.addr != NULL && i < RTE_DIM(config->metadata->entry)) {
- printf("Entry %u: name:<%-20s>, phys:0x%-15lx, len:0x%-15lx, "
+ fprintf(f, "Entry %u: name:<%-20s>, phys:0x%-15lx, len:0x%-15lx, "
"virt:%-15p, off:0x%-15lx\n",
i,
entry->mz.name,
@@ -861,7 +860,7 @@ rte_ivshmem_metadata_dump(const char *na
i++;
#ifdef RTE_LIBRTE_IVSHMEM_DEBUG
- printf("\tHugepage files:\n");
+ fprintf(f, "\tHugepage files:\n");
hugepage_sz = entry->mz.hugepage_sz;
addr = RTE_ALIGN_FLOOR(entry->mz.addr_64, hugepage_sz);
@@ -873,7 +872,7 @@ rte_ivshmem_metadata_dump(const char *na
get_hugefile_by_virt_addr(addr, &e);
- printf("\t0x%"PRIx64 "-0x%" PRIx64 " offset: 0x%" PRIx64 " %s\n",
+ fprintf(f, "\t0x%"PRIx64 "-0x%" PRIx64 " offset: 0x%" PRIx64 " %s\n",
addr, addr + hugepage_sz, e.offset, e.filepath);
}
#endif
--- a/lib/librte_ivshmem/rte_ivshmem.h 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_ivshmem/rte_ivshmem.h 2014-05-02 16:31:16.423593331 -0700
@@ -150,10 +150,12 @@ int rte_ivshmem_metadata_cmdline_generat
/**
* Dump all metadata entries from a given metadata file to the console.
*
+ * @param f
+ * A pointer to a file for output
* @name
* Name of the metadata file to be dumped to console.
*/
-void rte_ivshmem_metadata_dump(const char *name);
+void rte_ivshmem_metadata_dump(FILE *f, const char *name);
#ifdef __cplusplus
--- a/lib/librte_malloc/rte_malloc.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_malloc/rte_malloc.c 2014-05-02 16:31:16.427593355 -0700
@@ -217,7 +217,7 @@ rte_malloc_get_socket_stats(int socket,
* Print stats on memory type. If type is NULL, info on all types is printed
*/
void
-rte_malloc_dump_stats(__rte_unused const char *type)
+rte_malloc_dump_stats(FILE *f, __rte_unused const char *type)
{
unsigned int socket;
struct rte_malloc_socket_stats sock_stats;
@@ -226,14 +226,14 @@ rte_malloc_dump_stats(__rte_unused const
if ((rte_malloc_get_socket_stats(socket, &sock_stats) < 0))
continue;
- printf("Socket:%u\n", socket);
- printf("\tHeap_size:%zu,\n", sock_stats.heap_totalsz_bytes);
- printf("\tFree_size:%zu,\n", sock_stats.heap_freesz_bytes);
- printf("\tAlloc_size:%zu,\n", sock_stats.heap_allocsz_bytes);
- printf("\tGreatest_free_size:%zu,\n",
+ fprintf(f, "Socket:%u\n", socket);
+ fprintf(f, "\tHeap_size:%zu,\n", sock_stats.heap_totalsz_bytes);
+ fprintf(f, "\tFree_size:%zu,\n", sock_stats.heap_freesz_bytes);
+ fprintf(f, "\tAlloc_size:%zu,\n", sock_stats.heap_allocsz_bytes);
+ fprintf(f, "\tGreatest_free_size:%zu,\n",
sock_stats.greatest_free_size);
- printf("\tAlloc_count:%u,\n",sock_stats.alloc_count);
- printf("\tFree_count:%u,\n", sock_stats.free_count);
+ fprintf(f, "\tAlloc_count:%u,\n",sock_stats.alloc_count);
+ fprintf(f, "\tFree_count:%u,\n", sock_stats.free_count);
}
return;
}
--- a/lib/librte_malloc/rte_malloc.h 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_malloc/rte_malloc.h 2014-05-02 16:31:16.427593355 -0700
@@ -40,6 +40,7 @@
* from hugepages.
*/
+#include <stdio.h>
#include <stddef.h>
#include <rte_memory.h>
@@ -296,12 +297,14 @@ rte_malloc_get_socket_stats(int socket,
* Dump for the specified type to the console. If the type argument is
* NULL, all memory types will be dumped.
*
+ * @param f
+ * A pointer to a file for output
* @param type
* A string identifying the type of objects to dump, or NULL
* to dump all objects.
*/
void
-rte_malloc_dump_stats(const char *type);
+rte_malloc_dump_stats(FILE *f, const char *type);
/**
* Set the maximum amount of allocated memory for this type.
--- a/lib/librte_mbuf/rte_mbuf.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_mbuf/rte_mbuf.c 2014-05-02 16:31:16.427593355 -0700
@@ -193,16 +193,16 @@ rte_mbuf_sanity_check(const struct rte_m
/* dump a mbuf on console */
void
-rte_pktmbuf_dump(const struct rte_mbuf *m, unsigned dump_len)
+rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len)
{
unsigned int len;
unsigned nb_segs;
__rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 1);
- printf("dump mbuf at 0x%p, phys=%"PRIx64", buf_len=%u\n",
+ fprintf(f, "dump mbuf at 0x%p, phys=%"PRIx64", buf_len=%u\n",
m, (uint64_t)m->buf_physaddr, (unsigned)m->buf_len);
- printf(" pkt_len=%"PRIu32", ol_flags=%"PRIx16", nb_segs=%u, "
+ fprintf(f, " pkt_len=%"PRIu32", ol_flags=%"PRIx16", nb_segs=%u, "
"in_port=%u\n", m->pkt.pkt_len, m->ol_flags,
(unsigned)m->pkt.nb_segs, (unsigned)m->pkt.in_port);
nb_segs = m->pkt.nb_segs;
@@ -210,13 +210,13 @@ rte_pktmbuf_dump(const struct rte_mbuf *
while (m && nb_segs != 0) {
__rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 0);
- printf(" segment at 0x%p, data=0x%p, data_len=%u\n",
+ fprintf(f, " segment at 0x%p, data=0x%p, data_len=%u\n",
m, m->pkt.data, (unsigned)m->pkt.data_len);
len = dump_len;
if (len > m->pkt.data_len)
len = m->pkt.data_len;
if (len != 0)
- rte_hexdump(NULL, m->pkt.data, len);
+ rte_hexdump(f, NULL, m->pkt.data, len);
dump_len -= len;
m = m->pkt.next;
nb_segs --;
--- a/lib/librte_mbuf/rte_mbuf.h 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_mbuf/rte_mbuf.h 2014-05-02 16:31:16.427593355 -0700
@@ -1026,13 +1026,15 @@ static inline int rte_pktmbuf_is_contigu
* Dump all fields for the given packet mbuf and all its associated
* segments (in the case of a chained buffer).
*
+ * @param f
+ * A pointer to a file for output
* @param m
* The packet mbuf.
* @param dump_len
* If dump_len != 0, also dump the "dump_len" first data bytes of
* the packet.
*/
-void rte_pktmbuf_dump(const struct rte_mbuf *m, unsigned dump_len);
+void rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len);
#ifdef __cplusplus
}
--- a/lib/librte_mempool/rte_mempool.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_mempool/rte_mempool.c 2014-05-02 16:31:16.427593355 -0700
@@ -626,25 +626,25 @@ rte_mempool_count(const struct rte_mempo
/* dump the cache status */
static unsigned
-rte_mempool_dump_cache(const struct rte_mempool *mp)
+rte_mempool_dump_cache(FILE *f, const struct rte_mempool *mp)
{
#if RTE_MEMPOOL_CACHE_MAX_SIZE > 0
unsigned lcore_id;
unsigned count = 0;
unsigned cache_count;
- printf(" cache infos:\n");
- printf(" cache_size=%"PRIu32"\n", mp->cache_size);
+ fprintf(f, " cache infos:\n");
+ fprintf(f, " cache_size=%"PRIu32"\n", mp->cache_size);
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
cache_count = mp->local_cache[lcore_id].len;
- printf(" cache_count[%u]=%u\n", lcore_id, cache_count);
+ fprintf(f, " cache_count[%u]=%u\n", lcore_id, cache_count);
count += cache_count;
}
- printf(" total_cache_count=%u\n", count);
+ fprintf(f, " total_cache_count=%u\n", count);
return count;
#else
RTE_SET_USED(mp);
- printf(" cache disabled\n");
+ fprintf(f, " cache disabled\n");
return 0;
#endif
}
@@ -744,7 +744,7 @@ rte_mempool_audit(const struct rte_mempo
/* dump the status of the mempool on the console */
void
-rte_mempool_dump(const struct rte_mempool *mp)
+rte_mempool_dump(FILE *f, const struct rte_mempool *mp)
{
#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
struct rte_mempool_debug_stats sum;
@@ -753,35 +753,35 @@ rte_mempool_dump(const struct rte_mempoo
unsigned common_count;
unsigned cache_count;
- printf("mempool <%s>@%p\n", mp->name, mp);
- printf(" flags=%x\n", mp->flags);
- printf(" ring=<%s>@%p\n", mp->ring->name, mp->ring);
- printf(" phys_addr=0x%" PRIx64 "\n", mp->phys_addr);
- printf(" size=%"PRIu32"\n", mp->size);
- printf(" header_size=%"PRIu32"\n", mp->header_size);
- printf(" elt_size=%"PRIu32"\n", mp->elt_size);
- printf(" trailer_size=%"PRIu32"\n", mp->trailer_size);
- printf(" total_obj_size=%"PRIu32"\n",
+ fprintf(f, "mempool <%s>@%p\n", mp->name, mp);
+ fprintf(f, " flags=%x\n", mp->flags);
+ fprintf(f, " ring=<%s>@%p\n", mp->ring->name, mp->ring);
+ fprintf(f, " phys_addr=0x%" PRIx64 "\n", mp->phys_addr);
+ fprintf(f, " size=%"PRIu32"\n", mp->size);
+ fprintf(f, " header_size=%"PRIu32"\n", mp->header_size);
+ fprintf(f, " elt_size=%"PRIu32"\n", mp->elt_size);
+ fprintf(f, " trailer_size=%"PRIu32"\n", mp->trailer_size);
+ fprintf(f, " total_obj_size=%"PRIu32"\n",
mp->header_size + mp->elt_size + mp->trailer_size);
- printf(" private_data_size=%"PRIu32"\n", mp->private_data_size);
- printf(" pg_num=%"PRIu32"\n", mp->pg_num);
- printf(" pg_shift=%"PRIu32"\n", mp->pg_shift);
- printf(" pg_mask=%#tx\n", mp->pg_mask);
- printf(" elt_va_start=%#tx\n", mp->elt_va_start);
- printf(" elt_va_end=%#tx\n", mp->elt_va_end);
- printf(" elt_pa[0]=0x%" PRIx64 "\n", mp->elt_pa[0]);
+ fprintf(f, " private_data_size=%"PRIu32"\n", mp->private_data_size);
+ fprintf(f, " pg_num=%"PRIu32"\n", mp->pg_num);
+ fprintf(f, " pg_shift=%"PRIu32"\n", mp->pg_shift);
+ fprintf(f, " pg_mask=%#tx\n", mp->pg_mask);
+ fprintf(f, " elt_va_start=%#tx\n", mp->elt_va_start);
+ fprintf(f, " elt_va_end=%#tx\n", mp->elt_va_end);
+ fprintf(f, " elt_pa[0]=0x%" PRIx64 "\n", mp->elt_pa[0]);
if (mp->size != 0)
- printf(" avg bytes/object=%#Lf\n",
+ fprintf(f, " avg bytes/object=%#Lf\n",
(long double)(mp->elt_va_end - mp->elt_va_start) /
mp->size);
- cache_count = rte_mempool_dump_cache(mp);
+ cache_count = rte_mempool_dump_cache(f, mp);
common_count = rte_ring_count(mp->ring);
if ((cache_count + common_count) > mp->size)
common_count = mp->size - cache_count;
- printf(" common_pool_count=%u\n", common_count);
+ fprintf(f, " common_pool_count=%u\n", common_count);
/* sum and dump statistics */
#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
@@ -794,15 +794,15 @@ rte_mempool_dump(const struct rte_mempoo
sum.get_fail_bulk += mp->stats[lcore_id].get_fail_bulk;
sum.get_fail_objs += mp->stats[lcore_id].get_fail_objs;
}
- printf(" stats:\n");
- printf(" put_bulk=%"PRIu64"\n", sum.put_bulk);
- printf(" put_objs=%"PRIu64"\n", sum.put_objs);
- printf(" get_success_bulk=%"PRIu64"\n", sum.get_success_bulk);
- printf(" get_success_objs=%"PRIu64"\n", sum.get_success_objs);
- printf(" get_fail_bulk=%"PRIu64"\n", sum.get_fail_bulk);
- printf(" get_fail_objs=%"PRIu64"\n", sum.get_fail_objs);
+ fprintf(f, " stats:\n");
+ fprintf(f, " put_bulk=%"PRIu64"\n", sum.put_bulk);
+ fprintf(f, " put_objs=%"PRIu64"\n", sum.put_objs);
+ fprintf(f, " get_success_bulk=%"PRIu64"\n", sum.get_success_bulk);
+ fprintf(f, " get_success_objs=%"PRIu64"\n", sum.get_success_objs);
+ fprintf(f, " get_fail_bulk=%"PRIu64"\n", sum.get_fail_bulk);
+ fprintf(f, " get_fail_objs=%"PRIu64"\n", sum.get_fail_objs);
#else
- printf(" no statistics available\n");
+ fprintf(f, " no statistics available\n");
#endif
rte_mempool_audit(mp);
@@ -810,7 +810,7 @@ rte_mempool_dump(const struct rte_mempoo
/* dump the status of all mempools on the console */
void
-rte_mempool_list_dump(void)
+rte_mempool_list_dump(FILE *f)
{
const struct rte_mempool *mp = NULL;
struct rte_mempool_list *mempool_list;
@@ -824,7 +824,7 @@ rte_mempool_list_dump(void)
rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
TAILQ_FOREACH(mp, mempool_list, next) {
- rte_mempool_dump(mp);
+ rte_mempool_dump(f, mp);
}
rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
--- a/lib/librte_mempool/rte_mempool.h 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_mempool/rte_mempool.h 2014-05-02 16:31:16.427593355 -0700
@@ -59,6 +59,7 @@
* that won't work as rte_lcore_id() will not return a correct value.
*/
+#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
@@ -733,10 +734,12 @@ rte_dom0_mempool_create(const char *name
/**
* Dump the status of the mempool to the console.
*
+ * @param f
+ * A pointer to a file for output
* @param mp
* A pointer to the mempool structure.
*/
-void rte_mempool_dump(const struct rte_mempool *mp);
+void rte_mempool_dump(FILE *f, const struct rte_mempool *mp);
/**
* @internal Put several objects back in the mempool; used internally.
@@ -1298,8 +1301,11 @@ static inline void *rte_mempool_get_priv
/**
* Dump the status of all mempools on the console
+ *
+ * @param f
+ * A pointer to a file for output
*/
-void rte_mempool_list_dump(void);
+void rte_mempool_list_dump(FILE *f);
/**
* Search a mempool from its name
--- a/lib/librte_ring/rte_ring.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_ring/rte_ring.c 2014-05-02 16:31:16.427593355 -0700
@@ -191,26 +191,26 @@ rte_ring_set_water_mark(struct rte_ring
/* dump the status of the ring on the console */
void
-rte_ring_dump(const struct rte_ring *r)
+rte_ring_dump(FILE *f, const struct rte_ring *r)
{
#ifdef RTE_LIBRTE_RING_DEBUG
struct rte_ring_debug_stats sum;
unsigned lcore_id;
#endif
- printf("ring <%s>@%p\n", r->name, r);
- printf(" flags=%x\n", r->flags);
- printf(" size=%"PRIu32"\n", r->prod.size);
- printf(" ct=%"PRIu32"\n", r->cons.tail);
- printf(" ch=%"PRIu32"\n", r->cons.head);
- printf(" pt=%"PRIu32"\n", r->prod.tail);
- printf(" ph=%"PRIu32"\n", r->prod.head);
- printf(" used=%u\n", rte_ring_count(r));
- printf(" avail=%u\n", rte_ring_free_count(r));
+ fprintf(f, "ring <%s>@%p\n", r->name, r);
+ fprintf(f, " flags=%x\n", r->flags);
+ fprintf(f, " size=%"PRIu32"\n", r->prod.size);
+ fprintf(f, " ct=%"PRIu32"\n", r->cons.tail);
+ fprintf(f, " ch=%"PRIu32"\n", r->cons.head);
+ fprintf(f, " pt=%"PRIu32"\n", r->prod.tail);
+ fprintf(f, " ph=%"PRIu32"\n", r->prod.head);
+ fprintf(f, " used=%u\n", rte_ring_count(r));
+ fprintf(f, " avail=%u\n", rte_ring_free_count(r));
if (r->prod.watermark == r->prod.size)
- printf(" watermark=0\n");
+ fprintf(f, " watermark=0\n");
else
- printf(" watermark=%"PRIu32"\n", r->prod.watermark);
+ fprintf(f, " watermark=%"PRIu32"\n", r->prod.watermark);
/* sum and dump statistics */
#ifdef RTE_LIBRTE_RING_DEBUG
@@ -227,25 +227,25 @@ rte_ring_dump(const struct rte_ring *r)
sum.deq_fail_bulk += r->stats[lcore_id].deq_fail_bulk;
sum.deq_fail_objs += r->stats[lcore_id].deq_fail_objs;
}
- printf(" size=%"PRIu32"\n", r->prod.size);
- printf(" enq_success_bulk=%"PRIu64"\n", sum.enq_success_bulk);
- printf(" enq_success_objs=%"PRIu64"\n", sum.enq_success_objs);
- printf(" enq_quota_bulk=%"PRIu64"\n", sum.enq_quota_bulk);
- printf(" enq_quota_objs=%"PRIu64"\n", sum.enq_quota_objs);
- printf(" enq_fail_bulk=%"PRIu64"\n", sum.enq_fail_bulk);
- printf(" enq_fail_objs=%"PRIu64"\n", sum.enq_fail_objs);
- printf(" deq_success_bulk=%"PRIu64"\n", sum.deq_success_bulk);
- printf(" deq_success_objs=%"PRIu64"\n", sum.deq_success_objs);
- printf(" deq_fail_bulk=%"PRIu64"\n", sum.deq_fail_bulk);
- printf(" deq_fail_objs=%"PRIu64"\n", sum.deq_fail_objs);
+ fprintf(f, " size=%"PRIu32"\n", r->prod.size);
+ fprintf(f, " enq_success_bulk=%"PRIu64"\n", sum.enq_success_bulk);
+ fprintf(f, " enq_success_objs=%"PRIu64"\n", sum.enq_success_objs);
+ fprintf(f, " enq_quota_bulk=%"PRIu64"\n", sum.enq_quota_bulk);
+ fprintf(f, " enq_quota_objs=%"PRIu64"\n", sum.enq_quota_objs);
+ fprintf(f, " enq_fail_bulk=%"PRIu64"\n", sum.enq_fail_bulk);
+ fprintf(f, " enq_fail_objs=%"PRIu64"\n", sum.enq_fail_objs);
+ fprintf(f, " deq_success_bulk=%"PRIu64"\n", sum.deq_success_bulk);
+ fprintf(f, " deq_success_objs=%"PRIu64"\n", sum.deq_success_objs);
+ fprintf(f, " deq_fail_bulk=%"PRIu64"\n", sum.deq_fail_bulk);
+ fprintf(f, " deq_fail_objs=%"PRIu64"\n", sum.deq_fail_objs);
#else
- printf(" no statistics available\n");
+ fprintf(f, " no statistics available\n");
#endif
}
/* dump the status of all rings on the console */
void
-rte_ring_list_dump(void)
+rte_ring_list_dump(FILE *f)
{
const struct rte_ring *mp;
struct rte_ring_list *ring_list;
@@ -260,7 +260,7 @@ rte_ring_list_dump(void)
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
TAILQ_FOREACH(mp, ring_list, next) {
- rte_ring_dump(mp);
+ rte_ring_dump(f, mp);
}
rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
--- a/lib/librte_ring/rte_ring.h 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_ring/rte_ring.h 2014-05-02 16:31:16.427593355 -0700
@@ -91,6 +91,7 @@
extern "C" {
#endif
+#include <stdio.h>
#include <stdint.h>
#include <sys/queue.h>
#include <errno.h>
@@ -260,10 +261,12 @@ int rte_ring_set_water_mark(struct rte_r
/**
* Dump the status of the ring to the console.
*
+ * @param f
+ * A pointer to a file for output
* @param r
* A pointer to the ring structure.
*/
-void rte_ring_dump(const struct rte_ring *r);
+void rte_ring_dump(FILE *f, const struct rte_ring *r);
/* the actual enqueue of pointers on the ring.
* Placed here since identical code needed in both
@@ -996,8 +999,11 @@ rte_ring_free_count(const struct rte_rin
/**
* Dump the status of all rings on the console
+ *
+ * @param f
+ * A pointer to a file for output
*/
-void rte_ring_list_dump(void);
+void rte_ring_list_dump(FILE *f);
/**
* Search a ring from its name
--- a/lib/librte_timer/rte_timer.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_timer/rte_timer.c 2014-05-02 16:31:16.427593355 -0700
@@ -582,7 +582,7 @@ done:
}
/* dump statistics about timers */
-void rte_timer_dump_stats(void)
+void rte_timer_dump_stats(FILE *f)
{
#ifdef RTE_LIBRTE_TIMER_DEBUG
struct rte_timer_debug_stats sum;
@@ -595,12 +595,12 @@ void rte_timer_dump_stats(void)
sum.manage += priv_timer[lcore_id].stats.manage;
sum.pending += priv_timer[lcore_id].stats.pending;
}
- printf("Timer statistics:\n");
- printf(" reset = %"PRIu64"\n", sum.reset);
- printf(" stop = %"PRIu64"\n", sum.stop);
- printf(" manage = %"PRIu64"\n", sum.manage);
- printf(" pending = %"PRIu64"\n", sum.pending);
+ fprintf(f, "Timer statistics:\n");
+ fprintf(f, " reset = %"PRIu64"\n", sum.reset);
+ fprintf(f, " stop = %"PRIu64"\n", sum.stop);
+ fprintf(f, " manage = %"PRIu64"\n", sum.manage);
+ fprintf(f, " pending = %"PRIu64"\n", sum.pending);
#else
- printf("No timer statistics, RTE_LIBRTE_TIMER_DEBUG is disabled\n");
+ fprintf(f, "No timer statistics, RTE_LIBRTE_TIMER_DEBUG is disabled\n");
#endif
}
--- a/lib/librte_timer/rte_timer.h 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_timer/rte_timer.h 2014-05-02 16:31:16.427593355 -0700
@@ -63,6 +63,7 @@
* design of this library.
*/
+#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
@@ -321,8 +322,11 @@ void rte_timer_manage(void);
/**
* Dump statistics about timers.
+ *
+ * @param f
+ * A pointer to a file for output
*/
-void rte_timer_dump_stats(void);
+void rte_timer_dump_stats(FILE *f);
#ifdef __cplusplus
}
--- a/app/dump_cfg/main.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/dump_cfg/main.c 2014-05-02 16:31:16.427593355 -0700
@@ -79,15 +79,15 @@ MAIN(int argc, char **argv)
rte_panic("Cannot init EAL\n");
printf("----------- MEMORY_SEGMENTS -----------\n");
- rte_dump_physmem_layout();
+ rte_dump_physmem_layout(stdout);
printf("--------- END_MEMORY_SEGMENTS ---------\n");
printf("------------ MEMORY_ZONES -------------\n");
- rte_memzone_dump();
+ rte_memzone_dump(stdout);
printf("---------- END_MEMORY_ZONES -----------\n");
printf("------------- TAIL_QUEUES -------------\n");
- rte_dump_tailq();
+ rte_dump_tailq(stdout);
printf("---------- END_TAIL_QUEUES ------------\n");
return 0;
--- a/app/test/test_memzone.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test/test_memzone.c 2014-05-02 16:31:16.427593355 -0700
@@ -294,9 +294,9 @@ test_memzone_reserve_max(void)
/* check if the memzone is in our memseg and subtract length */
if ((config->mem_config->memzone[memzone_idx].addr >=
- ms[memseg_idx].addr) &&
- (config->mem_config->memzone[memzone_idx].addr <
- (RTE_PTR_ADD(ms[memseg_idx].addr, ms[memseg_idx].len)))) {
+ ms[memseg_idx].addr) &&
+ (config->mem_config->memzone[memzone_idx].addr <
+ (RTE_PTR_ADD(ms[memseg_idx].addr, ms[memseg_idx].len)))) {
/* since the zones can now be aligned and occasionally skip
* some space, we should calculate the length based on
* reported length and start addresses difference. Addresses
@@ -304,11 +304,11 @@ test_memzone_reserve_max(void)
* them being in the right order.
*/
len -= RTE_PTR_DIFF(
- config->mem_config->memzone[memzone_idx].addr,
- last_addr);
+ config->mem_config->memzone[memzone_idx].addr,
+ last_addr);
len -= config->mem_config->memzone[memzone_idx].len;
last_addr = RTE_PTR_ADD(config->mem_config->memzone[memzone_idx].addr,
- (size_t) config->mem_config->memzone[memzone_idx].len);
+ (size_t) config->mem_config->memzone[memzone_idx].len);
}
}
@@ -326,17 +326,17 @@ test_memzone_reserve_max(void)
mz = rte_memzone_reserve("max_zone", 0, SOCKET_ID_ANY, 0);
if (mz == NULL){
printf("Failed to reserve a big chunk of memory\n");
- rte_dump_physmem_layout();
- rte_memzone_dump();
+ rte_dump_physmem_layout(stdout);
+ rte_memzone_dump(stdout);
return -1;
}
if (mz->len != maxlen) {
printf("Memzone reserve with 0 size did not return bigest block\n");
printf("Expected size = %zu, actual size = %zu\n",
- maxlen, mz->len);
- rte_dump_physmem_layout();
- rte_memzone_dump();
+ maxlen, mz->len);
+ rte_dump_physmem_layout(stdout);
+ rte_memzone_dump(stdout);
return -1;
}
@@ -422,8 +422,8 @@ test_memzone_reserve_max_aligned(void)
SOCKET_ID_ANY, 0, align);
if (mz == NULL){
printf("Failed to reserve a big chunk of memory\n");
- rte_dump_physmem_layout();
- rte_memzone_dump();
+ rte_dump_physmem_layout(stdout);
+ rte_memzone_dump(stdout);
return -1;
}
@@ -432,8 +432,8 @@ test_memzone_reserve_max_aligned(void)
" bigest block\n", align);
printf("Expected size = %zu, actual size = %zu\n",
maxlen, mz->len);
- rte_dump_physmem_layout();
- rte_memzone_dump();
+ rte_dump_physmem_layout(stdout);
+ rte_memzone_dump(stdout);
return -1;
}
@@ -947,7 +947,7 @@ test_memzone(void)
if (memzone1 == NULL || memzone2 == NULL || memzone4 == NULL)
return -1;
- rte_memzone_dump();
+ rte_memzone_dump(stdout);
/* check cache-line alignments */
printf("check alignments and lengths\n");
--- a/lib/librte_eal/common/eal_common_devargs.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/eal_common_devargs.c 2014-05-02 16:31:16.427593355 -0700
@@ -122,31 +122,31 @@ rte_eal_devargs_type_count(enum rte_devt
/* dump the user devices on the console */
void
-rte_eal_devargs_dump(void)
+rte_eal_devargs_dump(FILE *f)
{
struct rte_devargs *devargs;
- printf("User device white list:\n");
+ fprintf(f, "User device white list:\n");
TAILQ_FOREACH(devargs, &devargs_list, next) {
if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
- printf(" PCI whitelist " PCI_PRI_FMT " %s\n",
+ fprintf(f, " PCI whitelist " PCI_PRI_FMT " %s\n",
devargs->pci.addr.domain,
devargs->pci.addr.bus,
devargs->pci.addr.devid,
devargs->pci.addr.function,
devargs->args);
else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI)
- printf(" PCI blacklist " PCI_PRI_FMT " %s\n",
+ fprintf(f, " PCI blacklist " PCI_PRI_FMT " %s\n",
devargs->pci.addr.domain,
devargs->pci.addr.bus,
devargs->pci.addr.devid,
devargs->pci.addr.function,
devargs->args);
else if (devargs->type == RTE_DEVTYPE_VIRTUAL)
- printf(" VIRTUAL %s %s\n",
+ fprintf(f, " VIRTUAL %s %s\n",
devargs->virtual.drv_name,
devargs->args);
else
- printf(" UNKNOWN %s\n", devargs->args);
+ fprintf(f, " UNKNOWN %s\n", devargs->args);
}
}
--- a/lib/librte_eal/common/eal_common_memory.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/eal_common_memory.c 2014-05-02 16:31:16.427593355 -0700
@@ -82,7 +82,7 @@ rte_eal_get_physmem_size(void)
/* Dump the physical memory layout on console */
void
-rte_dump_physmem_layout(void)
+rte_dump_physmem_layout(FILE *f)
{
const struct rte_mem_config *mcfg;
unsigned i = 0;
@@ -94,7 +94,7 @@ rte_dump_physmem_layout(void)
if (mcfg->memseg[i].addr == NULL)
break;
- printf("Segment %u: phys:0x%"PRIx64", len:%zu, "
+ fprintf(f, "Segment %u: phys:0x%"PRIx64", len:%zu, "
"virt:%p, socket_id:%"PRId32", "
"hugepage_sz:%zu, nchannel:%"PRIx32", "
"nrank:%"PRIx32"\n", i,
--- a/lib/librte_eal/common/eal_common_memzone.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/eal_common_memzone.c 2014-05-02 16:31:16.427593355 -0700
@@ -385,7 +385,7 @@ rte_memzone_lookup(const char *name)
/* Dump all reserved memory zones on console */
void
-rte_memzone_dump(void)
+rte_memzone_dump(FILE *f)
{
struct rte_mem_config *mcfg;
unsigned i = 0;
@@ -398,7 +398,7 @@ rte_memzone_dump(void)
for (i=0; i<RTE_MAX_MEMZONE; i++) {
if (mcfg->memzone[i].addr == NULL)
break;
- printf("Zone %u: name:<%s>, phys:0x%"PRIx64", len:0x%zx"
+ fprintf(f, "Zone %u: name:<%s>, phys:0x%"PRIx64", len:0x%zx"
", virt:%p, socket_id:%"PRId32", flags:%"PRIx32"\n", i,
mcfg->memzone[i].name,
mcfg->memzone[i].phys_addr,
--- a/lib/librte_eal/common/include/rte_devargs.h 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/include/rte_devargs.h 2014-05-02 16:31:16.427593355 -0700
@@ -48,6 +48,7 @@
extern "C" {
#endif
+#include <stdio.h>
#include <sys/queue.h>
#include <rte_pci.h>
@@ -135,8 +136,11 @@ rte_eal_devargs_type_count(enum rte_devt
/**
* This function dumps the list of user device and their arguments.
+ *
+ * @param f
+ * A pointer to a file for output
*/
-void rte_eal_devargs_dump(void);
+void rte_eal_devargs_dump(FILE *f);
#ifdef __cplusplus
}
--- a/lib/librte_eal/common/include/rte_memory.h 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/include/rte_memory.h 2014-05-02 16:31:16.427593355 -0700
@@ -139,8 +139,11 @@ const struct rte_memseg *rte_eal_get_phy
/**
* Dump the physical memory layout to the console.
+ *
+ * @param f
+ * A pointer to a file for output
*/
-void rte_dump_physmem_layout(void);
+void rte_dump_physmem_layout(FILE *f);
/**
* Get the total amount of available physical memory.
--- a/lib/librte_eal/common/include/rte_memzone.h 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/include/rte_memzone.h 2014-05-02 16:31:16.427593355 -0700
@@ -51,6 +51,7 @@
* be done at initialization time only.
*/
+#include <stdio.h>
#include <rte_memory.h>
#ifdef __cplusplus
@@ -245,8 +246,11 @@ const struct rte_memzone *rte_memzone_lo
/**
* Dump all reserved memzones to the console.
+ *
+ * @param f
+ * A pointer to a file for output
*/
-void rte_memzone_dump(void);
+void rte_memzone_dump(FILE *);
/**
* Walk list of all memzones
--- a/lib/librte_eal/linuxapp/eal/eal_ivshmem.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/linuxapp/eal/eal_ivshmem.c 2014-05-02 16:31:16.427593355 -0700
@@ -825,8 +825,8 @@ rte_eal_ivshmem_obj_init(void)
}
#ifdef RTE_LIBRTE_IVSHMEM_DEBUG
- rte_memzone_dump();
- rte_ring_list_dump();
+ rte_memzone_dump(stdout);
+ rte_ring_list_dump(stdout);
#endif
return 0;
--- a/app/test-pmd/cmdline.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test-pmd/cmdline.c 2014-05-02 16:31:16.427593355 -0700
@@ -5023,19 +5023,19 @@ static void cmd_dump_parsed(void *parsed
struct cmd_dump_result *res = parsed_result;
if (!strcmp(res->dump, "dump_physmem"))
- rte_dump_physmem_layout();
+ rte_dump_physmem_layout(stdout);
else if (!strcmp(res->dump, "dump_memzone"))
- rte_memzone_dump();
+ rte_memzone_dump(stdout);
else if (!strcmp(res->dump, "dump_log_history"))
- rte_log_dump_history();
+ rte_log_dump_history(stdout);
else if (!strcmp(res->dump, "dump_struct_sizes"))
dump_struct_sizes();
else if (!strcmp(res->dump, "dump_ring"))
- rte_ring_list_dump();
+ rte_ring_list_dump(stdout);
else if (!strcmp(res->dump, "dump_mempool"))
- rte_mempool_list_dump();
+ rte_mempool_list_dump(stdout);
else if (!strcmp(res->dump, "dump_devargs"))
- rte_eal_devargs_dump();
+ rte_eal_devargs_dump(stdout);
}
cmdline_parse_token_string_t cmd_dump_dump =
@@ -5077,7 +5077,7 @@ static void cmd_dump_one_parsed(void *pa
cmdline_printf(cl, "Cannot find ring\n");
return;
}
- rte_ring_dump(r);
+ rte_ring_dump(stdout, r);
} else if (!strcmp(res->dump, "dump_mempool")) {
struct rte_mempool *mp;
mp = rte_mempool_lookup(res->name);
@@ -5085,7 +5085,7 @@ static void cmd_dump_one_parsed(void *pa
cmdline_printf(cl, "Cannot find mempool\n");
return;
}
- rte_mempool_dump(mp);
+ rte_mempool_dump(stdout, mp);
}
}
--- a/app/test/test_memory.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test/test_memory.c 2014-05-02 16:31:16.427593355 -0700
@@ -63,7 +63,7 @@ test_memory(void)
* that at least one line is dumped
*/
printf("Dump memory layout\n");
- rte_dump_physmem_layout();
+ rte_dump_physmem_layout(stdout);
/* check that memory size is != 0 */
s = rte_eal_get_physmem_size();
--- a/lib/librte_eal/common/eal_common_tailqs.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/eal_common_tailqs.c 2014-05-02 16:31:16.427593355 -0700
@@ -108,7 +108,7 @@ rte_eal_tailq_reserve_by_idx(const unsig
}
void
-rte_dump_tailq(void)
+rte_dump_tailq(FILE *f)
{
struct rte_mem_config *mcfg;
unsigned i = 0;
@@ -120,7 +120,7 @@ rte_dump_tailq(void)
const struct rte_tailq_head *tailq = &mcfg->tailq_head[i];
const struct rte_dummy_head *head = &tailq->tailq_head;
- printf("Tailq %u: qname:<%s>, tqh_first:%p, tqh_last:%p\n", i,
+ fprintf(f, "Tailq %u: qname:<%s>, tqh_first:%p, tqh_last:%p\n", i,
(rte_tailq_names[i] != NULL ? rte_tailq_names[i]:"nil"),
head->tqh_first, head->tqh_last);
}
--- a/lib/librte_eal/common/include/rte_tailq.h 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/include/rte_tailq.h 2014-05-02 16:31:16.427593355 -0700
@@ -170,8 +170,11 @@ struct rte_tailq_head *rte_eal_tailq_res
/**
* Dump tail queues to the console.
+ *
+ * @param f
+ * A pointer to a file for output
*/
-void rte_dump_tailq(void);
+void rte_dump_tailq(FILE *f);
/**
* Lookup for a tail queue.
--- a/lib/librte_eal/common/eal_common_hexdump.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/eal_common_hexdump.c 2014-05-02 16:31:16.427593355 -0700
@@ -53,13 +53,13 @@
*/
void
-rte_hexdump(const char * title, const void * buf, unsigned int len)
+rte_hexdump(FILE *f, const char * title, const void * buf, unsigned int len)
{
unsigned int i, out, ofs;
const unsigned char *data = buf;
char line[LINE_LEN]; /* space needed 8+16*3+3+16 == 75 */
- printf("%s at [%p], len=%u\n", (title)? title : " Dump data", data, len);
+ fprintf(f, "%s at [%p], len=%u\n", (title)? title : " Dump data", data, len);
ofs = 0;
while (ofs < len) {
/* format the line in the buffer, then use printf to output to screen */
@@ -74,9 +74,9 @@ rte_hexdump(const char * title, const vo
c = '.';
out += rte_snprintf(line+out, LINE_LEN - out, "%c", c);
}
- printf("%s\n", line);
+ fprintf(f, "%s\n", line);
}
- fflush(stdout);
+ fflush(f);
}
/**************************************************************************//**
@@ -92,20 +92,20 @@ rte_hexdump(const char * title, const vo
*/
void
-rte_memdump(const char * title, const void * buf, unsigned int len)
+rte_memdump(FILE *f, const char * title, const void * buf, unsigned int len)
{
unsigned int i, out;
const unsigned char *data = buf;
char line[LINE_LEN];
if ( title )
- printf("%s: ", title);
+ fprintf(f, "%s: ", title);
line[0] = '\0';
for (i = 0, out = 0; i < len; i++) {
// Make sure we do not overrun the line buffer length.
if ( out >= (LINE_LEN - 4) ) {
- printf("%s", line);
+ fprintf(f, "%s", line);
out = 0;
line[out] = '\0';
}
@@ -113,9 +113,9 @@ rte_memdump(const char * title, const vo
(data[i] & 0xff), ((i+1) < len)? ":" : "");
}
if ( out > 0 )
- printf("%s", line);
- printf("\n");
+ fprintf(f, "%s", line);
+ fprintf(f, "\n");
- fflush(stdout);
+ fflush(f);
}
--- a/lib/librte_eal/common/eal_common_pci.c 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/eal_common_pci.c 2014-05-02 16:31:16.427593355 -0700
@@ -171,18 +171,18 @@ rte_eal_pci_probe(void)
/* dump one device */
static int
-pci_dump_one_device(struct rte_pci_device *dev)
+pci_dump_one_device(FILE *f, struct rte_pci_device *dev)
{
int i;
- printf(PCI_PRI_FMT, dev->addr.domain, dev->addr.bus,
+ fprintf(f, PCI_PRI_FMT, dev->addr.domain, dev->addr.bus,
dev->addr.devid, dev->addr.function);
- printf(" - vendor:%x device:%x\n", dev->id.vendor_id,
+ fprintf(f, " - vendor:%x device:%x\n", dev->id.vendor_id,
dev->id.device_id);
for (i = 0; i != sizeof(dev->mem_resource) /
sizeof(dev->mem_resource[0]); i++) {
- printf(" %16.16"PRIx64" %16.16"PRIx64"\n",
+ fprintf(f, " %16.16"PRIx64" %16.16"PRIx64"\n",
dev->mem_resource[i].phys_addr,
dev->mem_resource[i].len);
}
@@ -191,12 +191,12 @@ pci_dump_one_device(struct rte_pci_devic
/* dump devices on the bus */
void
-rte_eal_pci_dump(void)
+rte_eal_pci_dump(FILE *f)
{
struct rte_pci_device *dev = NULL;
TAILQ_FOREACH(dev, &pci_device_list, next) {
- pci_dump_one_device(dev);
+ pci_dump_one_device(f, dev);
}
}
--- a/lib/librte_eal/common/include/rte_hexdump.h 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/include/rte_hexdump.h 2014-05-02 16:31:16.427593355 -0700
@@ -46,6 +46,8 @@ extern "C" {
/**
* Dump out memory in a special hex dump format.
*
+* @param f
+* A pointer to a file for output
* @param title
* If not NULL this string is printed as a header to the output.
* @param buf
@@ -57,11 +59,13 @@ extern "C" {
*/
extern void
-rte_hexdump(const char * title, const void * buf, unsigned int len);
+rte_hexdump(FILE *f, const char * title, const void * buf, unsigned int len);
/**
* Dump out memory in a hex format with colons between bytes.
*
+* @param f
+* A pointer to a file for output
* @param title
* If not NULL this string is printed as a header to the output.
* @param buf
@@ -73,7 +77,7 @@ rte_hexdump(const char * title, const vo
*/
void
-rte_memdump(const char * title, const void * buf, unsigned int len);
+rte_memdump(FILE *f, const char * title, const void * buf, unsigned int len);
#ifdef __cplusplus
--- a/lib/librte_eal/common/include/rte_pci.h 2014-05-02 16:31:16.431593380 -0700
+++ b/lib/librte_eal/common/include/rte_pci.h 2014-05-02 16:31:16.427593355 -0700
@@ -271,8 +271,11 @@ int rte_eal_pci_probe(void);
/**
* Dump the content of the PCI bus.
+ *
+ * @param f
+ * A pointer to a file for output
*/
-void rte_eal_pci_dump(void);
+void rte_eal_pci_dump(FILE *f);
/**
* Register a PCI driver.
--- a/app/test/test_common.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test/test_common.c 2014-05-02 16:31:16.427593355 -0700
@@ -83,8 +83,8 @@ test_misc(void)
if (rte_bsf32(129))
FAIL("rte_bsf32");
- rte_memdump("test", memdump, sizeof(memdump));
- rte_hexdump("test", memdump, sizeof(memdump));
+ rte_memdump(stdout, "test", memdump, sizeof(memdump));
+ rte_hexdump(stdout, "test", memdump, sizeof(memdump));
rte_pause();
--- a/app/test/test_pci.c 2014-05-02 16:31:16.431593380 -0700
+++ b/app/test/test_pci.c 2014-05-02 16:31:16.427593355 -0700
@@ -153,7 +153,7 @@ test_pci(void)
struct rte_devargs_list save_devargs_list;
printf("Dump all devices\n");
- rte_eal_pci_dump();
+ rte_eal_pci_dump(stdout);
if (driver_registered == 0) {
rte_eal_pci_register(&my_driver);
rte_eal_pci_register(&my_driver2);
More information about the dev
mailing list