diff --git a/samples/net/zperf/src/zperf_tcp_uploader.c b/samples/net/zperf/src/zperf_tcp_uploader.c index cc7ec6ea32..6f23871f2e 100644 --- a/samples/net/zperf/src/zperf_tcp_uploader.c +++ b/samples/net/zperf/src/zperf_tcp_uploader.c @@ -31,6 +31,7 @@ void zperf_tcp_upload(const struct shell *shell, u32_t nb_packets = 0U, nb_errors = 0U; u32_t start_time, last_print_time, end_time; u8_t time_elapsed = 0U, finished = 0U; + u32_t alloc_errors = 0U; if (packet_size > PACKET_SIZE_MAX) { shell_fprintf(shell, SHELL_WARNING, @@ -66,11 +67,24 @@ void zperf_tcp_upload(const struct shell *shell, packet_size, NULL, K_NO_WAIT, NULL); if (ret < 0) { - shell_fprintf(shell, SHELL_WARNING, + if (nb_errors == 0 && ret != -ENOMEM) { + shell_fprintf(shell, SHELL_WARNING, "Failed to send the packet (%d)\n", ret); + } + nb_errors++; - break; + + if (ret == -ENOMEM) { + /* Ignore memory errors as we just run out of + * buffers which is kind of expected if the + * buffer count is not optimized for the test + * and device. + */ + alloc_errors++; + } else { + break; + } } else { nb_packets++; @@ -100,5 +114,15 @@ void zperf_tcp_upload(const struct shell *shell, results->packet_size = packet_size; results->nb_packets_errors = nb_errors; + if (alloc_errors > 0) { + shell_fprintf(shell, SHELL_WARNING, + "There was %u network buffer allocation " + "errors during send.\nConsider increasing the " + "value of CONFIG_NET_BUF_TX_COUNT and\n" + "optionally CONFIG_NET_PKT_TX_COUNT Kconfig " + "options.\n", + alloc_errors); + } + net_context_put(ctx); }