add FILE argument to debug functions

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@networkplumber.org>
[Thomas: fix quota_watermark example]
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
This commit is contained in:
Stephen Hemminger 2014-05-02 16:42:56 -07:00 committed by Thomas Monjalon
parent c738c6a644
commit 591a9d7985
45 changed files with 272 additions and 226 deletions

View File

@ -79,15 +79,15 @@ MAIN(int argc, char **argv)
rte_panic("Cannot init EAL\n"); rte_panic("Cannot init EAL\n");
printf("----------- MEMORY_SEGMENTS -----------\n"); printf("----------- MEMORY_SEGMENTS -----------\n");
rte_dump_physmem_layout(); rte_dump_physmem_layout(stdout);
printf("--------- END_MEMORY_SEGMENTS ---------\n"); printf("--------- END_MEMORY_SEGMENTS ---------\n");
printf("------------ MEMORY_ZONES -------------\n"); printf("------------ MEMORY_ZONES -------------\n");
rte_memzone_dump(); rte_memzone_dump(stdout);
printf("---------- END_MEMORY_ZONES -----------\n"); printf("---------- END_MEMORY_ZONES -----------\n");
printf("------------- TAIL_QUEUES -------------\n"); printf("------------- TAIL_QUEUES -------------\n");
rte_dump_tailq(); rte_dump_tailq(stdout);
printf("---------- END_TAIL_QUEUES ------------\n"); printf("---------- END_TAIL_QUEUES ------------\n");
return 0; return 0;

View File

@ -5068,19 +5068,19 @@ static void cmd_dump_parsed(void *parsed_result,
struct cmd_dump_result *res = parsed_result; struct cmd_dump_result *res = parsed_result;
if (!strcmp(res->dump, "dump_physmem")) if (!strcmp(res->dump, "dump_physmem"))
rte_dump_physmem_layout(); rte_dump_physmem_layout(stdout);
else if (!strcmp(res->dump, "dump_memzone")) else if (!strcmp(res->dump, "dump_memzone"))
rte_memzone_dump(); rte_memzone_dump(stdout);
else if (!strcmp(res->dump, "dump_log_history")) 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")) else if (!strcmp(res->dump, "dump_struct_sizes"))
dump_struct_sizes(); dump_struct_sizes();
else if (!strcmp(res->dump, "dump_ring")) else if (!strcmp(res->dump, "dump_ring"))
rte_ring_list_dump(); rte_ring_list_dump(stdout);
else if (!strcmp(res->dump, "dump_mempool")) else if (!strcmp(res->dump, "dump_mempool"))
rte_mempool_list_dump(); rte_mempool_list_dump(stdout);
else if (!strcmp(res->dump, "dump_devargs")) else if (!strcmp(res->dump, "dump_devargs"))
rte_eal_devargs_dump(); rte_eal_devargs_dump(stdout);
} }
cmdline_parse_token_string_t cmd_dump_dump = cmdline_parse_token_string_t cmd_dump_dump =
@ -5122,7 +5122,7 @@ static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
cmdline_printf(cl, "Cannot find ring\n"); cmdline_printf(cl, "Cannot find ring\n");
return; return;
} }
rte_ring_dump(r); rte_ring_dump(stdout, r);
} else if (!strcmp(res->dump, "dump_mempool")) { } else if (!strcmp(res->dump, "dump_mempool")) {
struct rte_mempool *mp; struct rte_mempool *mp;
mp = rte_mempool_lookup(res->name); mp = rte_mempool_lookup(res->name);
@ -5130,7 +5130,7 @@ static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
cmdline_printf(cl, "Cannot find mempool\n"); cmdline_printf(cl, "Cannot find mempool\n");
return; return;
} }
rte_mempool_dump(mp); rte_mempool_dump(stdout, mp);
} }
} }

View File

@ -480,7 +480,7 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,
rte_exit(EXIT_FAILURE, "Creation of mbuf pool for socket %u " rte_exit(EXIT_FAILURE, "Creation of mbuf pool for socket %u "
"failed\n", socket_id); "failed\n", socket_id);
} else if (verbose_level > 0) { } else if (verbose_level > 0) {
rte_mempool_dump(rte_mp); rte_mempool_dump(stdout, rte_mp);
} }
} }

View File

@ -275,19 +275,19 @@ static void cmd_dump_parsed(void *parsed_result,
struct cmd_dump_result *res = parsed_result; struct cmd_dump_result *res = parsed_result;
if (!strcmp(res->dump, "dump_physmem")) if (!strcmp(res->dump, "dump_physmem"))
rte_dump_physmem_layout(); rte_dump_physmem_layout(stdout);
else if (!strcmp(res->dump, "dump_memzone")) else if (!strcmp(res->dump, "dump_memzone"))
rte_memzone_dump(); rte_memzone_dump(stdout);
else if (!strcmp(res->dump, "dump_log_history")) 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")) else if (!strcmp(res->dump, "dump_struct_sizes"))
dump_struct_sizes(); dump_struct_sizes();
else if (!strcmp(res->dump, "dump_ring")) else if (!strcmp(res->dump, "dump_ring"))
rte_ring_list_dump(); rte_ring_list_dump(stdout);
else if (!strcmp(res->dump, "dump_mempool")) else if (!strcmp(res->dump, "dump_mempool"))
rte_mempool_list_dump(); rte_mempool_list_dump(stdout);
else if (!strcmp(res->dump, "dump_devargs")) else if (!strcmp(res->dump, "dump_devargs"))
rte_eal_devargs_dump(); rte_eal_devargs_dump(stdout);
} }
cmdline_parse_token_string_t cmd_dump_dump = cmdline_parse_token_string_t cmd_dump_dump =
@ -325,7 +325,7 @@ static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
cmdline_printf(cl, "Cannot find ring\n"); cmdline_printf(cl, "Cannot find ring\n");
return; return;
} }
rte_ring_dump(r); rte_ring_dump(stdout, r);
} }
else if (!strcmp(res->dump, "dump_mempool")) { else if (!strcmp(res->dump, "dump_mempool")) {
struct rte_mempool *mp; struct rte_mempool *mp;
@ -334,7 +334,7 @@ static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
cmdline_printf(cl, "Cannot find mempool\n"); cmdline_printf(cl, "Cannot find mempool\n");
return; return;
} }
rte_mempool_dump(mp); rte_mempool_dump(stdout, mp);
} }
} }

View File

@ -83,8 +83,8 @@ test_misc(void)
if (rte_bsf32(129)) if (rte_bsf32(129))
FAIL("rte_bsf32"); FAIL("rte_bsf32");
rte_memdump("test", memdump, sizeof(memdump)); rte_memdump(stdout, "test", memdump, sizeof(memdump));
rte_hexdump("test", memdump, sizeof(memdump)); rte_hexdump(stdout, "test", memdump, sizeof(memdump));
rte_pause(); rte_pause();

View File

@ -263,10 +263,10 @@ test_ivshmem_api_test(void)
ASSERT(strnlen(buf, sizeof(buf)) != 0, "Buffer is empty"); ASSERT(strnlen(buf, sizeof(buf)) != 0, "Buffer is empty");
/* make sure we don't segfault */ /* make sure we don't segfault */
rte_ivshmem_metadata_dump(NULL); rte_ivshmem_metadata_dump(stdout, NULL);
/* dump our metadata */ /* dump our metadata */
rte_ivshmem_metadata_dump(METADATA_NAME); rte_ivshmem_metadata_dump(stdout, METADATA_NAME);
return 0; return 0;
} }

View File

@ -86,7 +86,7 @@ test_logs(void)
RTE_LOG(DEBUG, TESTAPP1, "this is a debug level message\n"); RTE_LOG(DEBUG, TESTAPP1, "this is a debug level message\n");
RTE_LOG(DEBUG, TESTAPP2, "debug level message (not displayed)\n"); RTE_LOG(DEBUG, TESTAPP2, "debug level message (not displayed)\n");
rte_log_dump_history(); rte_log_dump_history(stdout);
return 0; return 0;
} }

View File

@ -162,7 +162,7 @@ test_align_overlap_per_lcore(__attribute__((unused)) void *arg)
rte_free(p2); rte_free(p2);
rte_free(p3); rte_free(p3);
} }
rte_malloc_dump_stats("dummy"); rte_malloc_dump_stats(stdout, "dummy");
return ret; return ret;
} }
@ -258,7 +258,7 @@ test_reordered_free_per_lcore(__attribute__((unused)) void *arg)
break; break;
} }
} }
rte_malloc_dump_stats("dummy"); rte_malloc_dump_stats(stdout, "dummy");
return ret; return ret;
} }
@ -365,7 +365,7 @@ test_multi_alloc_statistics(void)
if (!p1) if (!p1)
return -1; return -1;
rte_free(p1); rte_free(p1);
rte_malloc_dump_stats("stats"); rte_malloc_dump_stats(stdout, "stats");
rte_malloc_get_socket_stats(socket,&post_stats); rte_malloc_get_socket_stats(socket,&post_stats);
/* Check statistics reported are correct */ /* Check statistics reported are correct */
@ -466,7 +466,7 @@ test_rte_malloc_type_limits(void)
*/ */
const char *typename = "limit_test"; const char *typename = "limit_test";
rte_malloc_set_limit(typename, 64 * 1024); rte_malloc_set_limit(typename, 64 * 1024);
rte_malloc_dump_stats(typename); rte_malloc_dump_stats(stdout, typename);
return 0; return 0;
} }

View File

@ -158,7 +158,7 @@ test_pktmbuf_with_non_ascii_data(void)
memset(data, 0xff, rte_pktmbuf_pkt_len(m)); memset(data, 0xff, rte_pktmbuf_pkt_len(m));
if (!rte_pktmbuf_is_contiguous(m)) if (!rte_pktmbuf_is_contiguous(m))
GOTO_FAIL("Buffer should be continuous"); 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); rte_pktmbuf_free(m);
@ -191,7 +191,7 @@ test_one_pktmbuf(void)
if (rte_pktmbuf_pkt_len(m) != 0) if (rte_pktmbuf_pkt_len(m) != 0)
GOTO_FAIL("Bad length"); GOTO_FAIL("Bad length");
rte_pktmbuf_dump(m, 0); rte_pktmbuf_dump(stdout, m, 0);
/* append data */ /* append data */
@ -205,8 +205,8 @@ test_one_pktmbuf(void)
memset(data, 0x66, rte_pktmbuf_pkt_len(m)); memset(data, 0x66, rte_pktmbuf_pkt_len(m));
if (!rte_pktmbuf_is_contiguous(m)) if (!rte_pktmbuf_is_contiguous(m))
GOTO_FAIL("Buffer should be continuous"); 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_dump(m, 2*MBUF_TEST_DATA_LEN); rte_pktmbuf_dump(stdout, m, 2*MBUF_TEST_DATA_LEN);
/* this append should fail */ /* 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, 1);
rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 0); rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 0);
rte_pktmbuf_dump(m, 0); rte_pktmbuf_dump(stdout, m, 0);
/* this prepend should fail */ /* this prepend should fail */
@ -713,8 +713,8 @@ test_refcnt_mbuf(void)
rte_panic("refernced mbufs: %u, freed mbufs: %u\n", rte_panic("refernced mbufs: %u, freed mbufs: %u\n",
tref, refcnt_lcore[master]); tref, refcnt_lcore[master]);
rte_mempool_dump(refcnt_pool); rte_mempool_dump(stdout, refcnt_pool);
rte_ring_dump(refcnt_mbuf_ring); rte_ring_dump(stdout, refcnt_mbuf_ring);
#endif #endif
return (0); return (0);

View File

@ -63,7 +63,7 @@ test_memory(void)
* that at least one line is dumped * that at least one line is dumped
*/ */
printf("Dump memory layout\n"); printf("Dump memory layout\n");
rte_dump_physmem_layout(); rte_dump_physmem_layout(stdout);
/* check that memory size is != 0 */ /* check that memory size is != 0 */
s = rte_eal_get_physmem_size(); s = rte_eal_get_physmem_size();

View File

@ -110,12 +110,12 @@ test_mempool_basic(void)
unsigned i, j; unsigned i, j;
/* dump the mempool status */ /* dump the mempool status */
rte_mempool_dump(mp); rte_mempool_dump(stdout, mp);
printf("get an object\n"); printf("get an object\n");
if (rte_mempool_get(mp, &obj) < 0) if (rte_mempool_get(mp, &obj) < 0)
return -1; return -1;
rte_mempool_dump(mp); rte_mempool_dump(stdout, mp);
/* tests that improve coverage */ /* tests that improve coverage */
printf("get object count\n"); printf("get object count\n");
@ -136,7 +136,7 @@ test_mempool_basic(void)
printf("put the object back\n"); printf("put the object back\n");
rte_mempool_put(mp, obj); rte_mempool_put(mp, obj);
rte_mempool_dump(mp); rte_mempool_dump(stdout, mp);
printf("get 2 objects\n"); printf("get 2 objects\n");
if (rte_mempool_get(mp, &obj) < 0) if (rte_mempool_get(mp, &obj) < 0)
@ -145,12 +145,12 @@ test_mempool_basic(void)
rte_mempool_put(mp, obj); rte_mempool_put(mp, obj);
return -1; return -1;
} }
rte_mempool_dump(mp); rte_mempool_dump(stdout, mp);
printf("put the objects back\n"); printf("put the objects back\n");
rte_mempool_put(mp, obj); rte_mempool_put(mp, obj);
rte_mempool_put(mp, obj2); 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 * get many objects: we cannot get them all because the cache
@ -488,7 +488,7 @@ test_mempool(void)
return -1; return -1;
} }
rte_mempool_list_dump(); rte_mempool_list_dump(stdout);
/* basic tests without cache */ /* basic tests without cache */
mp = mp_nocache; mp = mp_nocache;
@ -517,7 +517,7 @@ test_mempool(void)
if (test_mempool_xmem_misc() < 0) if (test_mempool_xmem_misc() < 0)
return -1; return -1;
rte_mempool_list_dump(); rte_mempool_list_dump(stdout);
return 0; return 0;
} }

View File

@ -161,8 +161,8 @@ per_lcore_mempool_test(__attribute__((unused)) void *arg)
ret = rte_mempool_get_bulk(mp, &obj_table[idx], ret = rte_mempool_get_bulk(mp, &obj_table[idx],
n_get_bulk); n_get_bulk);
if (unlikely(ret < 0)) { if (unlikely(ret < 0)) {
rte_mempool_dump(mp); rte_mempool_dump(stdout, mp);
rte_ring_dump(mp->ring); rte_ring_dump(stdout, mp->ring);
/* in this case, objects are lost... */ /* in this case, objects are lost... */
return -1; return -1;
} }
@ -325,7 +325,7 @@ test_mempool_perf(void)
if (do_one_mempool_test(rte_lcore_count()) < 0) if (do_one_mempool_test(rte_lcore_count()) < 0)
return -1; return -1;
rte_mempool_list_dump(); rte_mempool_list_dump(stdout);
return 0; return 0;
} }

View File

@ -326,8 +326,8 @@ test_memzone_reserve_max(void)
mz = rte_memzone_reserve("max_zone", 0, SOCKET_ID_ANY, 0); mz = rte_memzone_reserve("max_zone", 0, SOCKET_ID_ANY, 0);
if (mz == NULL){ if (mz == NULL){
printf("Failed to reserve a big chunk of memory\n"); printf("Failed to reserve a big chunk of memory\n");
rte_dump_physmem_layout(); rte_dump_physmem_layout(stdout);
rte_memzone_dump(); rte_memzone_dump(stdout);
return -1; return -1;
} }
@ -335,8 +335,8 @@ test_memzone_reserve_max(void)
printf("Memzone reserve with 0 size did not return bigest block\n"); printf("Memzone reserve with 0 size did not return bigest block\n");
printf("Expected size = %zu, actual size = %zu\n", printf("Expected size = %zu, actual size = %zu\n",
maxlen, mz->len); maxlen, mz->len);
rte_dump_physmem_layout(); rte_dump_physmem_layout(stdout);
rte_memzone_dump(); rte_memzone_dump(stdout);
return -1; return -1;
} }
@ -422,8 +422,8 @@ test_memzone_reserve_max_aligned(void)
SOCKET_ID_ANY, 0, align); SOCKET_ID_ANY, 0, align);
if (mz == NULL){ if (mz == NULL){
printf("Failed to reserve a big chunk of memory\n"); printf("Failed to reserve a big chunk of memory\n");
rte_dump_physmem_layout(); rte_dump_physmem_layout(stdout);
rte_memzone_dump(); rte_memzone_dump(stdout);
return -1; return -1;
} }
@ -432,8 +432,8 @@ test_memzone_reserve_max_aligned(void)
" bigest block\n", align); " bigest block\n", align);
printf("Expected size = %zu, actual size = %zu\n", printf("Expected size = %zu, actual size = %zu\n",
maxlen, mz->len); maxlen, mz->len);
rte_dump_physmem_layout(); rte_dump_physmem_layout(stdout);
rte_memzone_dump(); rte_memzone_dump(stdout);
return -1; return -1;
} }
@ -947,7 +947,7 @@ test_memzone(void)
if (memzone1 == NULL || memzone2 == NULL || memzone4 == NULL) if (memzone1 == NULL || memzone2 == NULL || memzone4 == NULL)
return -1; return -1;
rte_memzone_dump(); rte_memzone_dump(stdout);
/* check cache-line alignments */ /* check cache-line alignments */
printf("check alignments and lengths\n"); printf("check alignments and lengths\n");

View File

@ -153,7 +153,7 @@ test_pci(void)
struct rte_devargs_list save_devargs_list; struct rte_devargs_list save_devargs_list;
printf("Dump all devices\n"); printf("Dump all devices\n");
rte_eal_pci_dump(); rte_eal_pci_dump(stdout);
if (driver_registered == 0) { if (driver_registered == 0) {
rte_eal_pci_register(&my_driver); rte_eal_pci_register(&my_driver);
rte_eal_pci_register(&my_driver2); rte_eal_pci_register(&my_driver2);

View File

@ -112,7 +112,7 @@ static struct rte_ring *r;
if (!(exp)) { \ if (!(exp)) { \
printf("error at %s:%d\tcondition " #exp " failed\n", \ printf("error at %s:%d\tcondition " #exp " failed\n", \
__func__, __LINE__); \ __func__, __LINE__); \
rte_ring_dump(r); \ rte_ring_dump(stdout, r); \
return (-1); \ return (-1); \
} }
@ -273,7 +273,7 @@ test_ring_basic_full_empty(void * const src[], void *dst[])
/* check data */ /* check data */
TEST_RING_VERIFY(0 == memcmp(src, dst, rsz)); TEST_RING_VERIFY(0 == memcmp(src, dst, rsz));
rte_ring_dump(r); rte_ring_dump(stdout, r);
} }
return (0); return (0);
} }
@ -341,8 +341,8 @@ test_ring_basic(void)
/* check data */ /* check data */
if (memcmp(src, dst, cur_dst - dst)) { if (memcmp(src, dst, cur_dst - dst)) {
rte_hexdump("src", src, cur_src - src); rte_hexdump(stdout, "src", src, cur_src - src);
rte_hexdump("dst", dst, cur_dst - dst); rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n"); printf("data after dequeue is not the same\n");
goto fail; goto fail;
} }
@ -387,8 +387,8 @@ test_ring_basic(void)
/* check data */ /* check data */
if (memcmp(src, dst, cur_dst - dst)) { if (memcmp(src, dst, cur_dst - dst)) {
rte_hexdump("src", src, cur_src - src); rte_hexdump(stdout, "src", src, cur_src - src);
rte_hexdump("dst", dst, cur_dst - dst); rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n"); printf("data after dequeue is not the same\n");
goto fail; goto fail;
} }
@ -409,8 +409,8 @@ test_ring_basic(void)
/* check data */ /* check data */
if (memcmp(src, dst, cur_dst - dst)) { if (memcmp(src, dst, cur_dst - dst)) {
rte_hexdump("src", src, cur_src - src); rte_hexdump(stdout, "src", src, cur_src - src);
rte_hexdump("dst", dst, cur_dst - dst); rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n"); printf("data after dequeue is not the same\n");
goto fail; goto fail;
} }
@ -455,8 +455,8 @@ test_ring_basic(void)
/* check data */ /* check data */
if (memcmp(src, dst, cur_dst - dst)) { if (memcmp(src, dst, cur_dst - dst)) {
rte_hexdump("src", src, cur_src - src); rte_hexdump(stdout, "src", src, cur_src - src);
rte_hexdump("dst", dst, cur_dst - dst); rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n"); printf("data after dequeue is not the same\n");
goto fail; goto fail;
} }
@ -550,8 +550,8 @@ test_ring_burst_basic(void)
/* check data */ /* check data */
if (memcmp(src, dst, cur_dst - dst)) { if (memcmp(src, dst, cur_dst - dst)) {
rte_hexdump("src", src, cur_src - src); rte_hexdump(stdout, "src", src, cur_src - src);
rte_hexdump("dst", dst, cur_dst - dst); rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n"); printf("data after dequeue is not the same\n");
goto fail; goto fail;
} }
@ -616,8 +616,8 @@ test_ring_burst_basic(void)
/* check data */ /* check data */
if (memcmp(src, dst, cur_dst - dst)) { if (memcmp(src, dst, cur_dst - dst)) {
rte_hexdump("src", src, cur_src - src); rte_hexdump(stdout, "src", src, cur_src - src);
rte_hexdump("dst", dst, cur_dst - dst); rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n"); printf("data after dequeue is not the same\n");
goto fail; goto fail;
} }
@ -665,8 +665,8 @@ test_ring_burst_basic(void)
/* check data */ /* check data */
if (memcmp(src, dst, cur_dst - dst)) { if (memcmp(src, dst, cur_dst - dst)) {
rte_hexdump("src", src, cur_src - src); rte_hexdump(stdout, "src", src, cur_src - src);
rte_hexdump("dst", dst, cur_dst - dst); rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n"); printf("data after dequeue is not the same\n");
goto fail; goto fail;
} }
@ -688,8 +688,8 @@ test_ring_burst_basic(void)
/* check data */ /* check data */
if (memcmp(src, dst, cur_dst - dst)) { if (memcmp(src, dst, cur_dst - dst)) {
rte_hexdump("src", src, cur_src - src); rte_hexdump(stdout, "src", src, cur_src - src);
rte_hexdump("dst", dst, cur_dst - dst); rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n"); printf("data after dequeue is not the same\n");
goto fail; goto fail;
} }
@ -738,8 +738,8 @@ test_ring_burst_basic(void)
/* check data */ /* check data */
if (memcmp(src, dst, cur_dst - dst)) { if (memcmp(src, dst, cur_dst - dst)) {
rte_hexdump("src", src, cur_src - src); rte_hexdump(stdout, "src", src, cur_src - src);
rte_hexdump("dst", dst, cur_dst - dst); rte_hexdump(stdout, "dst", dst, cur_dst - dst);
printf("data after dequeue is not the same\n"); printf("data after dequeue is not the same\n");
goto fail; goto fail;
} }
@ -1388,7 +1388,7 @@ test_ring(void)
return -1; return -1;
/* dump the ring status */ /* dump the ring status */
rte_ring_list_dump(); rte_ring_list_dump(stdout);
return 0; return 0;
} }

View File

@ -515,7 +515,7 @@ test_timer(void)
rte_timer_stop_sync(&mytiminfo[i].tim); rte_timer_stop_sync(&mytiminfo[i].tim);
} }
rte_timer_dump_stats(); rte_timer_dump_stats(stdout);
return 0; return 0;
} }

View File

@ -243,7 +243,7 @@ generate_ivshmem_cmdline(const char *config_name)
if (print_to_file(cmdline, config_name) < 0) if (print_to_file(cmdline, config_name) < 0)
return -1; return -1;
rte_ivshmem_metadata_dump(config_name); rte_ivshmem_metadata_dump(stdout, config_name);
return 0; return 0;
} }

View File

@ -193,7 +193,7 @@ cmd_show_handler(__attribute__((unused)) void *parsed_result,
if (ring == NULL) if (ring == NULL)
cmdline_printf(cl, "Cannot find ring \"%s\"\n", tokens->variable); cmdline_printf(cl, "Cannot find ring \"%s\"\n", tokens->variable);
else else
rte_ring_dump(ring); rte_ring_dump(stdout, ring);
} }
} }

View File

@ -122,31 +122,31 @@ rte_eal_devargs_type_count(enum rte_devtype devtype)
/* dump the user devices on the console */ /* dump the user devices on the console */
void void
rte_eal_devargs_dump(void) rte_eal_devargs_dump(FILE *f)
{ {
struct rte_devargs *devargs; struct rte_devargs *devargs;
printf("User device white list:\n"); fprintf(f, "User device white list:\n");
TAILQ_FOREACH(devargs, &devargs_list, next) { TAILQ_FOREACH(devargs, &devargs_list, next) {
if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) 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.domain,
devargs->pci.addr.bus, devargs->pci.addr.bus,
devargs->pci.addr.devid, devargs->pci.addr.devid,
devargs->pci.addr.function, devargs->pci.addr.function,
devargs->args); devargs->args);
else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) 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.domain,
devargs->pci.addr.bus, devargs->pci.addr.bus,
devargs->pci.addr.devid, devargs->pci.addr.devid,
devargs->pci.addr.function, devargs->pci.addr.function,
devargs->args); devargs->args);
else if (devargs->type == RTE_DEVTYPE_VIRTUAL) else if (devargs->type == RTE_DEVTYPE_VIRTUAL)
printf(" VIRTUAL %s %s\n", fprintf(f, " VIRTUAL %s %s\n",
devargs->virtual.drv_name, devargs->virtual.drv_name,
devargs->args); devargs->args);
else else
printf(" UNKNOWN %s\n", devargs->args); fprintf(f, " UNKNOWN %s\n", devargs->args);
} }
} }

View File

@ -53,13 +53,13 @@
*/ */
void 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; unsigned int i, out, ofs;
const unsigned char *data = buf; const unsigned char *data = buf;
char line[LINE_LEN]; /* space needed 8+16*3+3+16 == 75 */ 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; ofs = 0;
while (ofs < len) { while (ofs < len) {
/* format the line in the buffer, then use printf to output to screen */ /* format the line in the buffer, then use printf to output to screen */
@ -74,9 +74,9 @@ rte_hexdump(const char * title, const void * buf, unsigned int len)
c = '.'; c = '.';
out += rte_snprintf(line+out, LINE_LEN - out, "%c", 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 void * buf, unsigned int len)
*/ */
void 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; unsigned int i, out;
const unsigned char *data = buf; const unsigned char *data = buf;
char line[LINE_LEN]; char line[LINE_LEN];
if ( title ) if ( title )
printf("%s: ", title); fprintf(f, "%s: ", title);
line[0] = '\0'; line[0] = '\0';
for (i = 0, out = 0; i < len; i++) { for (i = 0, out = 0; i < len; i++) {
// Make sure we do not overrun the line buffer length. // Make sure we do not overrun the line buffer length.
if ( out >= (LINE_LEN - 4) ) { if ( out >= (LINE_LEN - 4) ) {
printf("%s", line); fprintf(f, "%s", line);
out = 0; out = 0;
line[out] = '\0'; line[out] = '\0';
} }
@ -113,9 +113,9 @@ rte_memdump(const char * title, const void * buf, unsigned int len)
(data[i] & 0xff), ((i+1) < len)? ":" : ""); (data[i] & 0xff), ((i+1) < len)? ":" : "");
} }
if ( out > 0 ) if ( out > 0 )
printf("%s", line); fprintf(f, "%s", line);
printf("\n"); fprintf(f, "\n");
fflush(stdout); fflush(f);
} }

View File

@ -202,9 +202,9 @@ int rte_log_cur_msg_logtype(void)
return log_cur_msg[lcore_id].logtype; return log_cur_msg[lcore_id].logtype;
} }
/* Dump log history on console */ /* Dump log history to file */
void void
rte_log_dump_history(void) rte_log_dump_history(FILE *out)
{ {
struct log_history_list tmp_log_history; struct log_history_list tmp_log_history;
struct log_history *hist_buf; struct log_history *hist_buf;
@ -230,7 +230,7 @@ rte_log_dump_history(void)
STAILQ_REMOVE_HEAD(&tmp_log_history, next); STAILQ_REMOVE_HEAD(&tmp_log_history, next);
/* write on stdout */ /* 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); rte_mempool_mp_put(log_history_mp, hist_buf);
break; break;
} }
@ -238,7 +238,7 @@ rte_log_dump_history(void)
/* put back message structure in pool */ /* put back message structure in pool */
rte_mempool_mp_put(log_history_mp, hist_buf); rte_mempool_mp_put(log_history_mp, hist_buf);
} }
fflush(stdout); fflush(out);
rte_spinlock_unlock(&log_dump_lock); rte_spinlock_unlock(&log_dump_lock);
} }

View File

@ -82,7 +82,7 @@ rte_eal_get_physmem_size(void)
/* Dump the physical memory layout on console */ /* Dump the physical memory layout on console */
void void
rte_dump_physmem_layout(void) rte_dump_physmem_layout(FILE *f)
{ {
const struct rte_mem_config *mcfg; const struct rte_mem_config *mcfg;
unsigned i = 0; unsigned i = 0;
@ -94,7 +94,7 @@ rte_dump_physmem_layout(void)
if (mcfg->memseg[i].addr == NULL) if (mcfg->memseg[i].addr == NULL)
break; break;
printf("Segment %u: phys:0x%"PRIx64", len:%zu, " fprintf(f, "Segment %u: phys:0x%"PRIx64", len:%zu, "
"virt:%p, socket_id:%"PRId32", " "virt:%p, socket_id:%"PRId32", "
"hugepage_sz:%zu, nchannel:%"PRIx32", " "hugepage_sz:%zu, nchannel:%"PRIx32", "
"nrank:%"PRIx32"\n", i, "nrank:%"PRIx32"\n", i,

View File

@ -385,7 +385,7 @@ rte_memzone_lookup(const char *name)
/* Dump all reserved memory zones on console */ /* Dump all reserved memory zones on console */
void void
rte_memzone_dump(void) rte_memzone_dump(FILE *f)
{ {
struct rte_mem_config *mcfg; struct rte_mem_config *mcfg;
unsigned i = 0; unsigned i = 0;
@ -398,7 +398,7 @@ rte_memzone_dump(void)
for (i=0; i<RTE_MAX_MEMZONE; i++) { for (i=0; i<RTE_MAX_MEMZONE; i++) {
if (mcfg->memzone[i].addr == NULL) if (mcfg->memzone[i].addr == NULL)
break; 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, ", virt:%p, socket_id:%"PRId32", flags:%"PRIx32"\n", i,
mcfg->memzone[i].name, mcfg->memzone[i].name,
mcfg->memzone[i].phys_addr, mcfg->memzone[i].phys_addr,

View File

@ -171,18 +171,18 @@ rte_eal_pci_probe(void)
/* dump one device */ /* dump one device */
static int static int
pci_dump_one_device(struct rte_pci_device *dev) pci_dump_one_device(FILE *f, struct rte_pci_device *dev)
{ {
int i; 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); 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); dev->id.device_id);
for (i = 0; i != sizeof(dev->mem_resource) / for (i = 0; i != sizeof(dev->mem_resource) /
sizeof(dev->mem_resource[0]); i++) { 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].phys_addr,
dev->mem_resource[i].len); dev->mem_resource[i].len);
} }
@ -191,12 +191,12 @@ pci_dump_one_device(struct rte_pci_device *dev)
/* dump devices on the bus */ /* dump devices on the bus */
void void
rte_eal_pci_dump(void) rte_eal_pci_dump(FILE *f)
{ {
struct rte_pci_device *dev = NULL; struct rte_pci_device *dev = NULL;
TAILQ_FOREACH(dev, &pci_device_list, next) { TAILQ_FOREACH(dev, &pci_device_list, next) {
pci_dump_one_device(dev); pci_dump_one_device(f, dev);
} }
} }

View File

@ -108,7 +108,7 @@ rte_eal_tailq_reserve_by_idx(const unsigned tailq_idx)
} }
void void
rte_dump_tailq(void) rte_dump_tailq(FILE *f)
{ {
struct rte_mem_config *mcfg; struct rte_mem_config *mcfg;
unsigned i = 0; unsigned i = 0;
@ -120,7 +120,7 @@ rte_dump_tailq(void)
const struct rte_tailq_head *tailq = &mcfg->tailq_head[i]; const struct rte_tailq_head *tailq = &mcfg->tailq_head[i];
const struct rte_dummy_head *head = &tailq->tailq_head; 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"), (rte_tailq_names[i] != NULL ? rte_tailq_names[i]:"nil"),
head->tqh_first, head->tqh_last); head->tqh_first, head->tqh_last);
} }

View File

@ -48,6 +48,7 @@
extern "C" { extern "C" {
#endif #endif
#include <stdio.h>
#include <sys/queue.h> #include <sys/queue.h>
#include <rte_pci.h> #include <rte_pci.h>
@ -135,8 +136,11 @@ rte_eal_devargs_type_count(enum rte_devtype devtype);
/** /**
* This function dumps the list of user device and their arguments. * 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 #ifdef __cplusplus
} }

View File

@ -46,6 +46,8 @@ extern "C" {
/** /**
* Dump out memory in a special hex dump format. * Dump out memory in a special hex dump format.
* *
* @param f
* A pointer to a file for output
* @param title * @param title
* If not NULL this string is printed as a header to the output. * If not NULL this string is printed as a header to the output.
* @param buf * @param buf
@ -57,11 +59,13 @@ extern "C" {
*/ */
extern void 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. * Dump out memory in a hex format with colons between bytes.
* *
* @param f
* A pointer to a file for output
* @param title * @param title
* If not NULL this string is printed as a header to the output. * If not NULL this string is printed as a header to the output.
* @param buf * @param buf
@ -73,7 +77,7 @@ rte_hexdump(const char * title, const void * buf, unsigned int len);
*/ */
void 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 #ifdef __cplusplus

View File

@ -173,9 +173,12 @@ int rte_log_cur_msg_logtype(void);
void rte_log_set_history(int enable); 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. * Add a log message to the history.

View File

@ -139,8 +139,11 @@ const struct rte_memseg *rte_eal_get_physmem_layout(void);
/** /**
* Dump the physical memory layout to the console. * 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. * Get the total amount of available physical memory.

View File

@ -51,6 +51,7 @@
* be done at initialization time only. * be done at initialization time only.
*/ */
#include <stdio.h>
#include <rte_memory.h> #include <rte_memory.h>
#ifdef __cplusplus #ifdef __cplusplus
@ -245,8 +246,11 @@ const struct rte_memzone *rte_memzone_lookup(const char *name);
/** /**
* Dump all reserved memzones to the console. * 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 *);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -271,8 +271,11 @@ int rte_eal_pci_probe(void);
/** /**
* Dump the content of the PCI bus. * 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. * Register a PCI driver.

View File

@ -170,8 +170,11 @@ struct rte_tailq_head *rte_eal_tailq_reserve_by_idx(const unsigned idx);
/** /**
* Dump tail queues to the console. * 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. * Lookup for a tail queue.

View File

@ -825,8 +825,8 @@ rte_eal_ivshmem_obj_init(void)
} }
#ifdef RTE_LIBRTE_IVSHMEM_DEBUG #ifdef RTE_LIBRTE_IVSHMEM_DEBUG
rte_memzone_dump(); rte_memzone_dump(stdout);
rte_ring_list_dump(); rte_ring_list_dump(stdout);
#endif #endif
return 0; return 0;

View File

@ -821,9 +821,8 @@ rte_ivshmem_metadata_cmdline_generate(char *buffer, unsigned size, const char *n
return 0; return 0;
} }
void void
rte_ivshmem_metadata_dump(const char *name) rte_ivshmem_metadata_dump(FILE *f, const char *name)
{ {
unsigned i = 0; unsigned i = 0;
struct ivshmem_config * config; struct ivshmem_config * config;
@ -850,7 +849,7 @@ rte_ivshmem_metadata_dump(const char *name)
while (entry->mz.addr != NULL && i < RTE_DIM(config->metadata->entry)) { 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", "virt:%-15p, off:0x%-15lx\n",
i, i,
entry->mz.name, entry->mz.name,
@ -861,7 +860,7 @@ rte_ivshmem_metadata_dump(const char *name)
i++; i++;
#ifdef RTE_LIBRTE_IVSHMEM_DEBUG #ifdef RTE_LIBRTE_IVSHMEM_DEBUG
printf("\tHugepage files:\n"); fprintf(f, "\tHugepage files:\n");
hugepage_sz = entry->mz.hugepage_sz; hugepage_sz = entry->mz.hugepage_sz;
addr = RTE_ALIGN_FLOOR(entry->mz.addr_64, hugepage_sz); addr = RTE_ALIGN_FLOOR(entry->mz.addr_64, hugepage_sz);
@ -873,7 +872,7 @@ rte_ivshmem_metadata_dump(const char *name)
get_hugefile_by_virt_addr(addr, &e); 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); addr, addr + hugepage_sz, e.offset, e.filepath);
} }
#endif #endif

View File

@ -150,10 +150,12 @@ int rte_ivshmem_metadata_cmdline_generate(char *buffer, unsigned size,
/** /**
* Dump all metadata entries from a given metadata file to the console. * Dump all metadata entries from a given metadata file to the console.
* *
* @param f
* A pointer to a file for output
* @name * @name
* Name of the metadata file to be dumped to console. * 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 #ifdef __cplusplus

View File

@ -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 * Print stats on memory type. If type is NULL, info on all types is printed
*/ */
void void
rte_malloc_dump_stats(__rte_unused const char *type) rte_malloc_dump_stats(FILE *f, __rte_unused const char *type)
{ {
unsigned int socket; unsigned int socket;
struct rte_malloc_socket_stats sock_stats; struct rte_malloc_socket_stats sock_stats;
@ -226,14 +226,14 @@ rte_malloc_dump_stats(__rte_unused const char *type)
if ((rte_malloc_get_socket_stats(socket, &sock_stats) < 0)) if ((rte_malloc_get_socket_stats(socket, &sock_stats) < 0))
continue; continue;
printf("Socket:%u\n", socket); fprintf(f, "Socket:%u\n", socket);
printf("\tHeap_size:%zu,\n", sock_stats.heap_totalsz_bytes); fprintf(f, "\tHeap_size:%zu,\n", sock_stats.heap_totalsz_bytes);
printf("\tFree_size:%zu,\n", sock_stats.heap_freesz_bytes); fprintf(f, "\tFree_size:%zu,\n", sock_stats.heap_freesz_bytes);
printf("\tAlloc_size:%zu,\n", sock_stats.heap_allocsz_bytes); fprintf(f, "\tAlloc_size:%zu,\n", sock_stats.heap_allocsz_bytes);
printf("\tGreatest_free_size:%zu,\n", fprintf(f, "\tGreatest_free_size:%zu,\n",
sock_stats.greatest_free_size); sock_stats.greatest_free_size);
printf("\tAlloc_count:%u,\n",sock_stats.alloc_count); fprintf(f, "\tAlloc_count:%u,\n",sock_stats.alloc_count);
printf("\tFree_count:%u,\n", sock_stats.free_count); fprintf(f, "\tFree_count:%u,\n", sock_stats.free_count);
} }
return; return;
} }

View File

@ -40,6 +40,7 @@
* from hugepages. * from hugepages.
*/ */
#include <stdio.h>
#include <stddef.h> #include <stddef.h>
#include <rte_memory.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 * Dump for the specified type to the console. If the type argument is
* NULL, all memory types will be dumped. * NULL, all memory types will be dumped.
* *
* @param f
* A pointer to a file for output
* @param type * @param type
* A string identifying the type of objects to dump, or NULL * A string identifying the type of objects to dump, or NULL
* to dump all objects. * to dump all objects.
*/ */
void 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. * Set the maximum amount of allocated memory for this type.

View File

@ -193,16 +193,16 @@ rte_mbuf_sanity_check(const struct rte_mbuf *m, enum rte_mbuf_type t,
/* dump a mbuf on console */ /* dump a mbuf on console */
void 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 int len;
unsigned nb_segs; unsigned nb_segs;
__rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 1); __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); 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, "in_port=%u\n", m->pkt.pkt_len, m->ol_flags,
(unsigned)m->pkt.nb_segs, (unsigned)m->pkt.in_port); (unsigned)m->pkt.nb_segs, (unsigned)m->pkt.in_port);
nb_segs = m->pkt.nb_segs; nb_segs = m->pkt.nb_segs;
@ -210,13 +210,13 @@ rte_pktmbuf_dump(const struct rte_mbuf *m, unsigned dump_len)
while (m && nb_segs != 0) { while (m && nb_segs != 0) {
__rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 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); m, m->pkt.data, (unsigned)m->pkt.data_len);
len = dump_len; len = dump_len;
if (len > m->pkt.data_len) if (len > m->pkt.data_len)
len = m->pkt.data_len; len = m->pkt.data_len;
if (len != 0) if (len != 0)
rte_hexdump(NULL, m->pkt.data, len); rte_hexdump(f, NULL, m->pkt.data, len);
dump_len -= len; dump_len -= len;
m = m->pkt.next; m = m->pkt.next;
nb_segs --; nb_segs --;

View File

@ -1026,13 +1026,15 @@ static inline int rte_pktmbuf_is_contiguous(const struct rte_mbuf *m)
* Dump all fields for the given packet mbuf and all its associated * Dump all fields for the given packet mbuf and all its associated
* segments (in the case of a chained buffer). * segments (in the case of a chained buffer).
* *
* @param f
* A pointer to a file for output
* @param m * @param m
* The packet mbuf. * The packet mbuf.
* @param dump_len * @param dump_len
* If dump_len != 0, also dump the "dump_len" first data bytes of * If dump_len != 0, also dump the "dump_len" first data bytes of
* the packet. * 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 #ifdef __cplusplus
} }

View File

@ -625,25 +625,25 @@ rte_mempool_count(const struct rte_mempool *mp)
/* dump the cache status */ /* dump the cache status */
static unsigned 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 #if RTE_MEMPOOL_CACHE_MAX_SIZE > 0
unsigned lcore_id; unsigned lcore_id;
unsigned count = 0; unsigned count = 0;
unsigned cache_count; unsigned cache_count;
printf(" cache infos:\n"); fprintf(f, " cache infos:\n");
printf(" cache_size=%"PRIu32"\n", mp->cache_size); fprintf(f, " cache_size=%"PRIu32"\n", mp->cache_size);
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
cache_count = mp->local_cache[lcore_id].len; 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; count += cache_count;
} }
printf(" total_cache_count=%u\n", count); fprintf(f, " total_cache_count=%u\n", count);
return count; return count;
#else #else
RTE_SET_USED(mp); RTE_SET_USED(mp);
printf(" cache disabled\n"); fprintf(f, " cache disabled\n");
return 0; return 0;
#endif #endif
} }
@ -743,7 +743,7 @@ rte_mempool_audit(const struct rte_mempool *mp)
/* dump the status of the mempool on the console */ /* dump the status of the mempool on the console */
void void
rte_mempool_dump(const struct rte_mempool *mp) rte_mempool_dump(FILE *f, const struct rte_mempool *mp)
{ {
#ifdef RTE_LIBRTE_MEMPOOL_DEBUG #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
struct rte_mempool_debug_stats sum; struct rte_mempool_debug_stats sum;
@ -752,35 +752,35 @@ rte_mempool_dump(const struct rte_mempool *mp)
unsigned common_count; unsigned common_count;
unsigned cache_count; unsigned cache_count;
printf("mempool <%s>@%p\n", mp->name, mp); fprintf(f, "mempool <%s>@%p\n", mp->name, mp);
printf(" flags=%x\n", mp->flags); fprintf(f, " flags=%x\n", mp->flags);
printf(" ring=<%s>@%p\n", mp->ring->name, mp->ring); fprintf(f, " ring=<%s>@%p\n", mp->ring->name, mp->ring);
printf(" phys_addr=0x%" PRIx64 "\n", mp->phys_addr); fprintf(f, " phys_addr=0x%" PRIx64 "\n", mp->phys_addr);
printf(" size=%"PRIu32"\n", mp->size); fprintf(f, " size=%"PRIu32"\n", mp->size);
printf(" header_size=%"PRIu32"\n", mp->header_size); fprintf(f, " header_size=%"PRIu32"\n", mp->header_size);
printf(" elt_size=%"PRIu32"\n", mp->elt_size); fprintf(f, " elt_size=%"PRIu32"\n", mp->elt_size);
printf(" trailer_size=%"PRIu32"\n", mp->trailer_size); fprintf(f, " trailer_size=%"PRIu32"\n", mp->trailer_size);
printf(" total_obj_size=%"PRIu32"\n", fprintf(f, " total_obj_size=%"PRIu32"\n",
mp->header_size + mp->elt_size + mp->trailer_size); mp->header_size + mp->elt_size + mp->trailer_size);
printf(" private_data_size=%"PRIu32"\n", mp->private_data_size); fprintf(f, " private_data_size=%"PRIu32"\n", mp->private_data_size);
printf(" pg_num=%"PRIu32"\n", mp->pg_num); fprintf(f, " pg_num=%"PRIu32"\n", mp->pg_num);
printf(" pg_shift=%"PRIu32"\n", mp->pg_shift); fprintf(f, " pg_shift=%"PRIu32"\n", mp->pg_shift);
printf(" pg_mask=%#tx\n", mp->pg_mask); fprintf(f, " pg_mask=%#tx\n", mp->pg_mask);
printf(" elt_va_start=%#tx\n", mp->elt_va_start); fprintf(f, " elt_va_start=%#tx\n", mp->elt_va_start);
printf(" elt_va_end=%#tx\n", mp->elt_va_end); fprintf(f, " elt_va_end=%#tx\n", mp->elt_va_end);
printf(" elt_pa[0]=0x%" PRIx64 "\n", mp->elt_pa[0]); fprintf(f, " elt_pa[0]=0x%" PRIx64 "\n", mp->elt_pa[0]);
if (mp->size != 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) / (long double)(mp->elt_va_end - mp->elt_va_start) /
mp->size); mp->size);
cache_count = rte_mempool_dump_cache(mp); cache_count = rte_mempool_dump_cache(f, mp);
common_count = rte_ring_count(mp->ring); common_count = rte_ring_count(mp->ring);
if ((cache_count + common_count) > mp->size) if ((cache_count + common_count) > mp->size)
common_count = mp->size - cache_count; 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 */ /* sum and dump statistics */
#ifdef RTE_LIBRTE_MEMPOOL_DEBUG #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
@ -793,15 +793,15 @@ rte_mempool_dump(const struct rte_mempool *mp)
sum.get_fail_bulk += mp->stats[lcore_id].get_fail_bulk; sum.get_fail_bulk += mp->stats[lcore_id].get_fail_bulk;
sum.get_fail_objs += mp->stats[lcore_id].get_fail_objs; sum.get_fail_objs += mp->stats[lcore_id].get_fail_objs;
} }
printf(" stats:\n"); fprintf(f, " stats:\n");
printf(" put_bulk=%"PRIu64"\n", sum.put_bulk); fprintf(f, " put_bulk=%"PRIu64"\n", sum.put_bulk);
printf(" put_objs=%"PRIu64"\n", sum.put_objs); fprintf(f, " put_objs=%"PRIu64"\n", sum.put_objs);
printf(" get_success_bulk=%"PRIu64"\n", sum.get_success_bulk); fprintf(f, " get_success_bulk=%"PRIu64"\n", sum.get_success_bulk);
printf(" get_success_objs=%"PRIu64"\n", sum.get_success_objs); fprintf(f, " get_success_objs=%"PRIu64"\n", sum.get_success_objs);
printf(" get_fail_bulk=%"PRIu64"\n", sum.get_fail_bulk); fprintf(f, " get_fail_bulk=%"PRIu64"\n", sum.get_fail_bulk);
printf(" get_fail_objs=%"PRIu64"\n", sum.get_fail_objs); fprintf(f, " get_fail_objs=%"PRIu64"\n", sum.get_fail_objs);
#else #else
printf(" no statistics available\n"); fprintf(f, " no statistics available\n");
#endif #endif
rte_mempool_audit(mp); rte_mempool_audit(mp);
@ -809,7 +809,7 @@ rte_mempool_dump(const struct rte_mempool *mp)
/* dump the status of all mempools on the console */ /* dump the status of all mempools on the console */
void void
rte_mempool_list_dump(void) rte_mempool_list_dump(FILE *f)
{ {
const struct rte_mempool *mp = NULL; const struct rte_mempool *mp = NULL;
struct rte_mempool_list *mempool_list; struct rte_mempool_list *mempool_list;
@ -823,7 +823,7 @@ rte_mempool_list_dump(void)
rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK); rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
TAILQ_FOREACH(mp, mempool_list, next) { TAILQ_FOREACH(mp, mempool_list, next) {
rte_mempool_dump(mp); rte_mempool_dump(f, mp);
} }
rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK); rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);

View File

@ -59,6 +59,7 @@
* that won't work as rte_lcore_id() will not return a correct value. * that won't work as rte_lcore_id() will not return a correct value.
*/ */
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <errno.h> #include <errno.h>
@ -733,10 +734,12 @@ rte_dom0_mempool_create(const char *name, unsigned n, unsigned elt_size,
/** /**
* Dump the status of the mempool to the console. * Dump the status of the mempool to the console.
* *
* @param f
* A pointer to a file for output
* @param mp * @param mp
* A pointer to the mempool structure. * 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. * @internal Put several objects back in the mempool; used internally.
@ -1298,8 +1301,11 @@ static inline void *rte_mempool_get_priv(struct rte_mempool *mp)
/** /**
* Dump the status of all mempools on the console * 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 * Search a mempool from its name

View File

@ -216,26 +216,26 @@ rte_ring_set_water_mark(struct rte_ring *r, unsigned count)
/* dump the status of the ring on the console */ /* dump the status of the ring on the console */
void void
rte_ring_dump(const struct rte_ring *r) rte_ring_dump(FILE *f, const struct rte_ring *r)
{ {
#ifdef RTE_LIBRTE_RING_DEBUG #ifdef RTE_LIBRTE_RING_DEBUG
struct rte_ring_debug_stats sum; struct rte_ring_debug_stats sum;
unsigned lcore_id; unsigned lcore_id;
#endif #endif
printf("ring <%s>@%p\n", r->name, r); fprintf(f, "ring <%s>@%p\n", r->name, r);
printf(" flags=%x\n", r->flags); fprintf(f, " flags=%x\n", r->flags);
printf(" size=%"PRIu32"\n", r->prod.size); fprintf(f, " size=%"PRIu32"\n", r->prod.size);
printf(" ct=%"PRIu32"\n", r->cons.tail); fprintf(f, " ct=%"PRIu32"\n", r->cons.tail);
printf(" ch=%"PRIu32"\n", r->cons.head); fprintf(f, " ch=%"PRIu32"\n", r->cons.head);
printf(" pt=%"PRIu32"\n", r->prod.tail); fprintf(f, " pt=%"PRIu32"\n", r->prod.tail);
printf(" ph=%"PRIu32"\n", r->prod.head); fprintf(f, " ph=%"PRIu32"\n", r->prod.head);
printf(" used=%u\n", rte_ring_count(r)); fprintf(f, " used=%u\n", rte_ring_count(r));
printf(" avail=%u\n", rte_ring_free_count(r)); fprintf(f, " avail=%u\n", rte_ring_free_count(r));
if (r->prod.watermark == r->prod.size) if (r->prod.watermark == r->prod.size)
printf(" watermark=0\n"); fprintf(f, " watermark=0\n");
else else
printf(" watermark=%"PRIu32"\n", r->prod.watermark); fprintf(f, " watermark=%"PRIu32"\n", r->prod.watermark);
/* sum and dump statistics */ /* sum and dump statistics */
#ifdef RTE_LIBRTE_RING_DEBUG #ifdef RTE_LIBRTE_RING_DEBUG
@ -252,25 +252,25 @@ rte_ring_dump(const struct rte_ring *r)
sum.deq_fail_bulk += r->stats[lcore_id].deq_fail_bulk; sum.deq_fail_bulk += r->stats[lcore_id].deq_fail_bulk;
sum.deq_fail_objs += r->stats[lcore_id].deq_fail_objs; sum.deq_fail_objs += r->stats[lcore_id].deq_fail_objs;
} }
printf(" size=%"PRIu32"\n", r->prod.size); fprintf(f, " size=%"PRIu32"\n", r->prod.size);
printf(" enq_success_bulk=%"PRIu64"\n", sum.enq_success_bulk); fprintf(f, " enq_success_bulk=%"PRIu64"\n", sum.enq_success_bulk);
printf(" enq_success_objs=%"PRIu64"\n", sum.enq_success_objs); fprintf(f, " enq_success_objs=%"PRIu64"\n", sum.enq_success_objs);
printf(" enq_quota_bulk=%"PRIu64"\n", sum.enq_quota_bulk); fprintf(f, " enq_quota_bulk=%"PRIu64"\n", sum.enq_quota_bulk);
printf(" enq_quota_objs=%"PRIu64"\n", sum.enq_quota_objs); fprintf(f, " enq_quota_objs=%"PRIu64"\n", sum.enq_quota_objs);
printf(" enq_fail_bulk=%"PRIu64"\n", sum.enq_fail_bulk); fprintf(f, " enq_fail_bulk=%"PRIu64"\n", sum.enq_fail_bulk);
printf(" enq_fail_objs=%"PRIu64"\n", sum.enq_fail_objs); fprintf(f, " enq_fail_objs=%"PRIu64"\n", sum.enq_fail_objs);
printf(" deq_success_bulk=%"PRIu64"\n", sum.deq_success_bulk); fprintf(f, " deq_success_bulk=%"PRIu64"\n", sum.deq_success_bulk);
printf(" deq_success_objs=%"PRIu64"\n", sum.deq_success_objs); fprintf(f, " deq_success_objs=%"PRIu64"\n", sum.deq_success_objs);
printf(" deq_fail_bulk=%"PRIu64"\n", sum.deq_fail_bulk); fprintf(f, " deq_fail_bulk=%"PRIu64"\n", sum.deq_fail_bulk);
printf(" deq_fail_objs=%"PRIu64"\n", sum.deq_fail_objs); fprintf(f, " deq_fail_objs=%"PRIu64"\n", sum.deq_fail_objs);
#else #else
printf(" no statistics available\n"); fprintf(f, " no statistics available\n");
#endif #endif
} }
/* dump the status of all rings on the console */ /* dump the status of all rings on the console */
void void
rte_ring_list_dump(void) rte_ring_list_dump(FILE *f)
{ {
const struct rte_ring *mp; const struct rte_ring *mp;
struct rte_ring_list *ring_list; struct rte_ring_list *ring_list;
@ -285,7 +285,7 @@ rte_ring_list_dump(void)
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK); rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
TAILQ_FOREACH(mp, ring_list, next) { TAILQ_FOREACH(mp, ring_list, next) {
rte_ring_dump(mp); rte_ring_dump(f, mp);
} }
rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK); rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);

View File

@ -91,6 +91,7 @@
extern "C" { extern "C" {
#endif #endif
#include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <sys/queue.h> #include <sys/queue.h>
#include <errno.h> #include <errno.h>
@ -317,10 +318,12 @@ int rte_ring_set_water_mark(struct rte_ring *r, unsigned count);
/** /**
* Dump the status of the ring to the console. * Dump the status of the ring to the console.
* *
* @param f
* A pointer to a file for output
* @param r * @param r
* A pointer to the ring structure. * 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. /* the actual enqueue of pointers on the ring.
* Placed here since identical code needed in both * Placed here since identical code needed in both
@ -1053,8 +1056,11 @@ rte_ring_free_count(const struct rte_ring *r)
/** /**
* Dump the status of all rings on the console * 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 * Search a ring from its name

View File

@ -582,7 +582,7 @@ void rte_timer_manage(void)
} }
/* dump statistics about timers */ /* dump statistics about timers */
void rte_timer_dump_stats(void) void rte_timer_dump_stats(FILE *f)
{ {
#ifdef RTE_LIBRTE_TIMER_DEBUG #ifdef RTE_LIBRTE_TIMER_DEBUG
struct rte_timer_debug_stats sum; 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.manage += priv_timer[lcore_id].stats.manage;
sum.pending += priv_timer[lcore_id].stats.pending; sum.pending += priv_timer[lcore_id].stats.pending;
} }
printf("Timer statistics:\n"); fprintf(f, "Timer statistics:\n");
printf(" reset = %"PRIu64"\n", sum.reset); fprintf(f, " reset = %"PRIu64"\n", sum.reset);
printf(" stop = %"PRIu64"\n", sum.stop); fprintf(f, " stop = %"PRIu64"\n", sum.stop);
printf(" manage = %"PRIu64"\n", sum.manage); fprintf(f, " manage = %"PRIu64"\n", sum.manage);
printf(" pending = %"PRIu64"\n", sum.pending); fprintf(f, " pending = %"PRIu64"\n", sum.pending);
#else #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 #endif
} }

View File

@ -63,6 +63,7 @@
* design of this library. * design of this library.
*/ */
#include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
@ -321,8 +322,11 @@ void rte_timer_manage(void);
/** /**
* Dump statistics about timers. * 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 #ifdef __cplusplus
} }