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;
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 =
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);
cmdline_printf(cl, "Cannot find mempool\n");
return;
}
- rte_mempool_dump(mp);
+ rte_mempool_dump(stdout, mp);
}
}
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);
}
}
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 =
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;
cmdline_printf(cl, "Cannot find mempool\n");
return;
}
- rte_mempool_dump(mp);
+ rte_mempool_dump(stdout, mp);
}
}
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();
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;
}
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;
}
rte_free(p2);
rte_free(p3);
}
- rte_malloc_dump_stats("dummy");
+ rte_malloc_dump_stats(stdout, "dummy");
return ret;
}
break;
}
}
- rte_malloc_dump_stats("dummy");
+ rte_malloc_dump_stats(stdout, "dummy");
return ret;
}
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 */
*/
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;
}
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);
if (rte_pktmbuf_pkt_len(m) != 0)
GOTO_FAIL("Bad length");
- rte_pktmbuf_dump(m, 0);
+ rte_pktmbuf_dump(stdout, m, 0);
/* append data */
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 */
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 */
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);
* 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();
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");
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)
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
return -1;
}
- rte_mempool_list_dump();
+ rte_mempool_list_dump(stdout);
/* basic tests without cache */
mp = mp_nocache;
if (test_mempool_xmem_misc() < 0)
return -1;
- rte_mempool_list_dump();
+ rte_mempool_list_dump(stdout);
return 0;
}
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;
}
if (do_one_mempool_test(rte_lcore_count()) < 0)
return -1;
- rte_mempool_list_dump();
+ rte_mempool_list_dump(stdout);
return 0;
}
/* 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
* 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);
}
}
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;
}
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;
}
" 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;
}
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");
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);
if (!(exp)) { \
printf("error at %s:%d\tcondition " #exp " failed\n", \
__func__, __LINE__); \
- rte_ring_dump(r); \
+ rte_ring_dump(stdout, r); \
return (-1); \
}
/* check data */
TEST_RING_VERIFY(0 == memcmp(src, dst, rsz));
- rte_ring_dump(r);
+ rte_ring_dump(stdout, r);
}
return (0);
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
return -1;
/* dump the ring status */
- rte_ring_list_dump();
+ rte_ring_list_dump(stdout);
return 0;
}
rte_timer_stop_sync(&mytiminfo[i].tim);
}
- rte_timer_dump_stats();
+ rte_timer_dump_stats(stdout);
return 0;
}
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;
}
if (ring == NULL)
cmdline_printf(cl, "Cannot find ring \"%s\"\n", tokens->variable);
else
- rte_ring_dump(ring);
+ rte_ring_dump(stdout, ring);
}
}
/* 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);
}
}
*/
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 */
c = '.';
out += rte_snprintf(line+out, LINE_LEN - out, "%c", c);
}
- printf("%s\n", line);
+ fprintf(f, "%s\n", line);
}
- fflush(stdout);
+ fflush(f);
}
/**************************************************************************//**
*/
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';
}
(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);
}
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;
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;
}
/* 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);
}
/* 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;
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,
/* 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;
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,
/* 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);
}
/* 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);
}
}
}
void
-rte_dump_tailq(void)
+rte_dump_tailq(FILE *f)
{
struct rte_mem_config *mcfg;
unsigned i = 0;
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);
}
extern "C" {
#endif
+#include <stdio.h>
#include <sys/queue.h>
#include <rte_pci.h>
/**
* 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
}
/**
* 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
*/
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
*/
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
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.
/**
* 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.
* be done at initialization time only.
*/
+#include <stdio.h>
#include <rte_memory.h>
#ifdef __cplusplus
/**
* 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
}
/**
* 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.
/**
* 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.
}
#ifdef RTE_LIBRTE_IVSHMEM_DEBUG
- rte_memzone_dump();
- rte_ring_list_dump();
+ rte_memzone_dump(stdout);
+ rte_ring_list_dump(stdout);
#endif
return 0;
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;
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,
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);
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
/**
* 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
* 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;
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;
}
* from hugepages.
*/
+#include <stdio.h>
#include <stddef.h>
#include <rte_memory.h>
* 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.
/* 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;
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 --;
* 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
}
/* 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
}
/* 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;
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
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);
/* 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;
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);
* 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>
/**
* 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.
/**
* 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
/* 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
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;
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);
extern "C" {
#endif
+#include <stdio.h>
#include <stdint.h>
#include <sys/queue.h>
#include <errno.h>
/**
* 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
/**
* 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
}
/* 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;
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
}
* design of this library.
*/
+#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
/**
* 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
}