From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BF195A0546; Thu, 27 May 2021 18:25:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F2F540150; Thu, 27 May 2021 18:25:01 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 28E3C40143 for ; Thu, 27 May 2021 18:25:00 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id D53C17F57F; Thu, 27 May 2021 19:24:59 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id B5B847F50B; Thu, 27 May 2021 19:24:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru B5B847F50B Authentication-Results: shelob.oktetlabs.ru/B5B847F50B; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Xiaoyun Li Cc: dev@dpdk.org Date: Thu, 27 May 2021 19:24:52 +0300 Message-Id: <20210527162452.1568351-1-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] app/testpmd: send failure logs to stderr X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Running with stdout suppressed or redirected for further processing is very confusing in the case of errors. Signed-off-by: Andrew Rybchenko --- app/test-pmd/testpmd.c | 151 ++++++++++++++++++++--------------------- 1 file changed, 75 insertions(+), 76 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 8ed1b97dec..a5ad4ef4e9 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1126,11 +1126,9 @@ check_nb_rxq(queueid_t rxq) allowed_max_rxq = get_allowed_max_nb_rxq(&pid); if (rxq > allowed_max_rxq) { - printf("Fail: input rxq (%u) can't be greater " - "than max_rx_queues (%u) of port %u\n", - rxq, - allowed_max_rxq, - pid); + fprintf(stderr, + "Fail: input rxq (%u) can't be greater than max_rx_queues (%u) of port %u\n", + rxq, allowed_max_rxq, pid); return -1; } return 0; @@ -1176,11 +1174,9 @@ check_nb_txq(queueid_t txq) allowed_max_txq = get_allowed_max_nb_txq(&pid); if (txq > allowed_max_txq) { - printf("Fail: input txq (%u) can't be greater " - "than max_tx_queues (%u) of port %u\n", - txq, - allowed_max_txq, - pid); + fprintf(stderr, + "Fail: input txq (%u) can't be greater than max_tx_queues (%u) of port %u\n", + txq, allowed_max_txq, pid); return -1; } return 0; @@ -1251,21 +1247,17 @@ check_nb_rxd(queueid_t rxd) allowed_max_rxd = get_allowed_max_nb_rxd(&pid); if (rxd > allowed_max_rxd) { - printf("Fail: input rxd (%u) can't be greater " - "than max_rxds (%u) of port %u\n", - rxd, - allowed_max_rxd, - pid); + fprintf(stderr, + "Fail: input rxd (%u) can't be greater than max_rxds (%u) of port %u\n", + rxd, allowed_max_rxd, pid); return -1; } allowed_min_rxd = get_allowed_min_nb_rxd(&pid); if (rxd < allowed_min_rxd) { - printf("Fail: input rxd (%u) can't be less " - "than min_rxds (%u) of port %u\n", - rxd, - allowed_min_rxd, - pid); + fprintf(stderr, + "Fail: input rxd (%u) can't be less than min_rxds (%u) of port %u\n", + rxd, allowed_min_rxd, pid); return -1; } @@ -1336,21 +1328,17 @@ check_nb_txd(queueid_t txd) allowed_max_txd = get_allowed_max_nb_txd(&pid); if (txd > allowed_max_txd) { - printf("Fail: input txd (%u) can't be greater " - "than max_txds (%u) of port %u\n", - txd, - allowed_max_txd, - pid); + fprintf(stderr, + "Fail: input txd (%u) can't be greater than max_txds (%u) of port %u\n", + txd, allowed_max_txd, pid); return -1; } allowed_min_txd = get_allowed_min_nb_txd(&pid); if (txd < allowed_min_txd) { - printf("Fail: input txd (%u) can't be less " - "than min_txds (%u) of port %u\n", - txd, - allowed_min_txd, - pid); + fprintf(stderr, + "Fail: input txd (%u) can't be less than min_txds (%u) of port %u\n", + txd, allowed_min_txd, pid); return -1; } return 0; @@ -1396,9 +1384,9 @@ check_nb_hairpinq(queueid_t hairpinq) allowed_max_hairpinq = get_allowed_max_nb_hairpinq(&pid); if (hairpinq > allowed_max_hairpinq) { - printf("Fail: input hairpin (%u) can't be greater " - "than max_hairpin_queues (%u) of port %u\n", - hairpinq, allowed_max_hairpinq, pid); + fprintf(stderr, + "Fail: input hairpin (%u) can't be greater than max_hairpin_queues (%u) of port %u\n", + hairpinq, allowed_max_hairpinq, pid); return -1; } return 0; @@ -1454,7 +1442,8 @@ init_config(void) ret = update_jumbo_frame_offload(pid); if (ret != 0) - printf("Updating jumbo frame offload failed for port %u\n", + fprintf(stderr, + "Updating jumbo frame offload failed for port %u\n", pid); if (!(port->dev_info.tx_offload_capa & @@ -1628,15 +1617,15 @@ init_fwd_streams(void) RTE_ETH_FOREACH_DEV(pid) { port = &ports[pid]; if (nb_rxq > port->dev_info.max_rx_queues) { - printf("Fail: nb_rxq(%d) is greater than " - "max_rx_queues(%d)\n", nb_rxq, - port->dev_info.max_rx_queues); + fprintf(stderr, + "Fail: nb_rxq(%d) is greater than max_rx_queues(%d)\n", + nb_rxq, port->dev_info.max_rx_queues); return -1; } if (nb_txq > port->dev_info.max_tx_queues) { - printf("Fail: nb_txq(%d) is greater than " - "max_tx_queues(%d)\n", nb_txq, - port->dev_info.max_tx_queues); + fprintf(stderr, + "Fail: nb_txq(%d) is greater than max_tx_queues(%d)\n", + nb_txq, port->dev_info.max_tx_queues); return -1; } if (numa_support) { @@ -1663,7 +1652,8 @@ init_fwd_streams(void) q = RTE_MAX(nb_rxq, nb_txq); if (q == 0) { - printf("Fail: Cannot allocate fwd streams as number of queues is 0\n"); + fprintf(stderr, + "Fail: Cannot allocate fwd streams as number of queues is 0\n"); return -1; } nb_fwd_streams_new = (streamid_t)(nb_ports * q); @@ -2120,8 +2110,8 @@ launch_packet_forwarding(lcore_function_t *pkt_fwd_on_lcore) diag = rte_eal_remote_launch(pkt_fwd_on_lcore, fwd_lcores[i], lc_id); if (diag != 0) - printf("launch lcore %u failed - diag=%d\n", - lc_id, diag); + fprintf(stderr, "launch lcore %u failed - diag=%d\n", + lc_id, diag); } } } @@ -2223,14 +2213,14 @@ void dev_set_link_up(portid_t pid) { if (rte_eth_dev_set_link_up(pid) < 0) - printf("\nSet link up fail.\n"); + fprintf(stderr, "\nSet link up fail.\n"); } void dev_set_link_down(portid_t pid) { if (rte_eth_dev_set_link_down(pid) < 0) - printf("\nSet link down fail.\n"); + fprintf(stderr, "\nSet link down fail.\n"); } static int @@ -2353,8 +2343,8 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi) RTE_PORT_STOPPED) == 0) printf("Port %d can not be set back " "to stopped\n", pi); - printf("Fail to configure port %d hairpin " - "queues\n", pi); + fprintf(stderr, "Fail to configure port %d hairpin queues\n", + pi); /* try to reconfigure queues next time */ port->need_reconfig_queues = 1; return -1; @@ -2376,8 +2366,8 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi) RTE_PORT_STOPPED) == 0) printf("Port %d can not be set back " "to stopped\n", pi); - printf("Fail to configure port %d hairpin " - "queues\n", pi); + fprintf(stderr, "Fail to configure port %d hairpin queues\n", + pi); /* try to reconfigure queues next time */ port->need_reconfig_queues = 1; return -1; @@ -2467,8 +2457,9 @@ start_port(portid_t pid) if (flow_isolate_all) { int ret = port_flow_isolate(pi, 1); if (ret) { - printf("Failed to apply isolated" - " mode on port %d\n", pi); + fprintf(stderr, + "Failed to apply isolated mode on port %d\n", + pi); return -1; } } @@ -2477,8 +2468,9 @@ start_port(portid_t pid) port->socket_id); if (nb_hairpinq > 0 && rte_eth_dev_hairpin_capability_get(pi, &cap)) { - printf("Port %d doesn't support hairpin " - "queues\n", pi); + fprintf(stderr, + "Port %d doesn't support hairpin queues\n", + pi); return -1; } /* configure port */ @@ -2490,7 +2482,8 @@ start_port(portid_t pid) RTE_PORT_HANDLING, RTE_PORT_STOPPED) == 0) printf("Port %d can not be set back " "to stopped\n", pi); - printf("Fail to configure port %d\n", pi); + fprintf(stderr, "Fail to configure port %d\n", + pi); /* try to reconfigure port next time */ port->need_reconfig = 1; return -1; @@ -2521,8 +2514,9 @@ start_port(portid_t pid) RTE_PORT_STOPPED) == 0) printf("Port %d can not be set back " "to stopped\n", pi); - printf("Fail to configure port %d tx queues\n", - pi); + fprintf(stderr, + "Fail to configure port %d tx queues\n", + pi); /* try to reconfigure queues next time */ port->need_reconfig_queues = 1; return -1; @@ -2535,7 +2529,8 @@ start_port(portid_t pid) mbuf_pool_find (rxring_numa[pi], 0); if (mp == NULL) { - printf("Failed to setup RX queue:" + fprintf(stderr, + "Failed to setup RX queue:" "No mempool allocation" " on the socket %d\n", rxring_numa[pi]); @@ -2552,7 +2547,8 @@ start_port(portid_t pid) mbuf_pool_find (port->socket_id, 0); if (mp == NULL) { - printf("Failed to setup RX queue:" + fprintf(stderr, + "Failed to setup RX queue:" "No mempool allocation" " on the socket %d\n", port->socket_id); @@ -2573,8 +2569,9 @@ start_port(portid_t pid) RTE_PORT_STOPPED) == 0) printf("Port %d can not be set back " "to stopped\n", pi); - printf("Fail to configure port %d rx queues\n", - pi); + fprintf(stderr, + "Fail to configure port %d rx queues\n", + pi); /* try to reconfigure queues next time */ port->need_reconfig_queues = 1; return -1; @@ -2588,9 +2585,9 @@ start_port(portid_t pid) diag = rte_eth_dev_set_ptypes(pi, RTE_PTYPE_UNKNOWN, NULL, 0); if (diag < 0) - printf( - "Port %d: Failed to disable Ptype parsing\n", - pi); + fprintf(stderr, + "Port %d: Failed to disable Ptype parsing\n", + pi); } p_pi = pi; @@ -2599,8 +2596,8 @@ start_port(portid_t pid) /* start port */ diag = rte_eth_dev_start(pi); if (diag < 0) { - printf("Fail to start port %d: %s\n", pi, - rte_strerror(-diag)); + fprintf(stderr, "Fail to start port %d: %s\n", + pi, rte_strerror(-diag)); /* Fail to setup rx queue, return */ if (rte_atomic16_cmpset(&(port->port_status), @@ -2648,10 +2645,10 @@ start_port(portid_t pid) continue; diag = rte_eth_hairpin_bind(pi, peer_pl[j]); if (diag < 0) { - printf("Error during binding hairpin" - " Tx port %u to %u: %s\n", - pi, peer_pl[j], - rte_strerror(-diag)); + fprintf(stderr, + "Error during binding hairpin Tx port %u to %u: %s\n", + pi, peer_pl[j], + rte_strerror(-diag)); return -1; } } @@ -2665,10 +2662,10 @@ start_port(portid_t pid) continue; diag = rte_eth_hairpin_bind(peer_pl[j], pi); if (diag < 0) { - printf("Error during binding hairpin" - " Tx port %u to %u: %s\n", - peer_pl[j], pi, - rte_strerror(-diag)); + fprintf(stderr, + "Error during binding hairpin Tx port %u to %u: %s\n", + peer_pl[j], pi, + rte_strerror(-diag)); return -1; } } @@ -2848,7 +2845,8 @@ reset_port(portid_t pid) port->need_reconfig = 1; port->need_reconfig_queues = 1; } else { - printf("Failed to reset port %d. diag=%d\n", pi, diag); + fprintf(stderr, "Failed to reset port %d. diag=%d\n", + pi, diag); } } @@ -3103,7 +3101,8 @@ check_all_ports_link_status(uint32_t port_mask) if (ret < 0) { all_ports_up = 0; if (print_flag == 1) - printf("Port %u link get failed: %s\n", + fprintf(stderr, + "Port %u link get failed: %s\n", portid, rte_strerror(-ret)); continue; } @@ -3401,7 +3400,7 @@ update_jumbo_frame_offload(portid_t portid) ret = rte_eth_dev_set_mtu(portid, port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead); if (ret) - printf("Failed to set MTU to %u for port %u\n", + fprintf(stderr, "Failed to set MTU to %u for port %u\n", port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead, portid); } -- 2.30.2