From: Olivier Matz Date: Fri, 8 Dec 2017 13:19:10 +0000 (+0100) Subject: app/testpmd: register a specific log type X-Git-Tag: spdx-start~753 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=285fd1019333dce2d76477cc4cd2f488cba37412;p=dpdk.git app/testpmd: register a specific log type Instead of using USERx logs, register a dynamic log type, as introduced in commit c1b5fa94a46f ("eal: support dynamic log types"). Signed-off-by: Olivier Matz Acked-by: Wenzhuo Lu --- diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index aa29f5fc10..5f96a1d2ee 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -563,7 +563,7 @@ pkt_copy_split(const struct rte_mbuf *pkt) while (i != 0) { p = rte_pktmbuf_alloc(mp); if (p == NULL) { - RTE_LOG(ERR, USER1, + TESTPMD_LOG(ERR, "failed to allocate %u-th of %u mbuf " "from mempool: %s\n", nb_seg - i, nb_seg, mp->name); @@ -572,7 +572,7 @@ pkt_copy_split(const struct rte_mbuf *pkt) md[--i] = p; if (rte_pktmbuf_tailroom(md[i]) < seglen[i]) { - RTE_LOG(ERR, USER1, "mempool %s, %u-th segment: " + TESTPMD_LOG(ERR, "mempool %s, %u-th segment: " "expected seglen: %u, " "actual mbuf tailroom: %u\n", mp->name, i, seglen[i], @@ -585,7 +585,7 @@ pkt_copy_split(const struct rte_mbuf *pkt) if (i == 0) { rc = mbuf_copy_split(pkt, md, seglen, nb_seg); if (rc < 0) - RTE_LOG(ERR, USER1, + TESTPMD_LOG(ERR, "mbuf_copy_split for %p(len=%u, nb_seg=%u) " "into %u segments failed with error code: %d\n", pkt, pkt->pkt_len, pkt->nb_segs, nb_seg, rc); @@ -895,8 +895,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) if (ret >= 0) nb_segments += ret; else { - RTE_LOG(DEBUG, USER1, - "Unable to segment packet"); + TESTPMD_LOG(DEBUG, "Unable to segment packet"); rte_pktmbuf_free(pkts_burst[i]); } } diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 47e145cb47..9414d0e384 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -62,6 +62,7 @@ #include "testpmd.h" uint16_t verbose_level = 0; /**< Silent by default. */ +int testpmd_logtype; /**< Log type for testpmd logs */ /* use master core for command line ? */ uint8_t interactive = 0; @@ -483,7 +484,7 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, mb_size = sizeof(struct rte_mbuf) + mbuf_seg_size; mbuf_poolname_build(socket_id, pool_name, sizeof(pool_name)); - RTE_LOG(INFO, USER1, + TESTPMD_LOG(INFO, "create a new mbuf pool <%s>: n=%u, size=%u, socket=%u\n", pool_name, nb_mbuf, mbuf_seg_size, socket_id); @@ -1775,7 +1776,7 @@ detach_port(portid_t port_id) port_flow_flush(port_id); if (rte_eth_dev_detach(port_id, name)) { - RTE_LOG(ERR, USER1, "Failed to detach port '%s'\n", name); + TESTPMD_LOG(ERR, "Failed to detach port '%s'\n", name); return; } @@ -1884,7 +1885,7 @@ rmv_event_callback(void *arg) close_port(port_id); printf("removing device %s\n", dev->device->name); if (rte_eal_dev_detach(dev->device)) - RTE_LOG(ERR, USER1, "Failed to detach device %s\n", + TESTPMD_LOG(ERR, "Failed to detach device %s\n", dev->device->name); } @@ -2355,8 +2356,13 @@ main(int argc, char** argv) if (diag < 0) rte_panic("Cannot init EAL\n"); + testpmd_logtype = rte_log_register("testpmd"); + if (testpmd_logtype < 0) + rte_panic("Cannot register log type"); + rte_log_set_level(testpmd_logtype, RTE_LOG_DEBUG); + if (mlockall(MCL_CURRENT | MCL_FUTURE)) { - RTE_LOG(NOTICE, USER1, "mlockall() failed with error \"%s\"\n", + TESTPMD_LOG(NOTICE, "mlockall() failed with error \"%s\"\n", strerror(errno)); } @@ -2367,7 +2373,7 @@ main(int argc, char** argv) nb_ports = (portid_t) rte_eth_dev_count(); if (nb_ports == 0) - RTE_LOG(WARNING, EAL, "No probed ethernet devices\n"); + TESTPMD_LOG(WARNING, "No probed ethernet devices\n"); /* allocate port structures, and init them */ init_port(); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 4d7f27c3e6..2a266fd1b7 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -324,6 +324,7 @@ extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */ /* globals used for configuration */ extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */ +extern int testpmd_logtype; /**< Log type for testpmd logs */ extern uint8_t interactive; extern uint8_t auto_start; extern uint8_t tx_first; @@ -718,4 +719,7 @@ int new_socket_id(unsigned int socket_id); #endif #endif /* __GCC__ */ +#define TESTPMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, testpmd_logtype, "testpmd: " fmt, ## args) + #endif /* _TESTPMD_H_ */