From patchwork Fri Aug 7 09:00:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balakrishna Garapati X-Patchwork-Id: 52020 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id D85D522EAD for ; Fri, 7 Aug 2015 09:01:16 +0000 (UTC) Received: by lagz9 with SMTP id z9sf18033855lag.3 for ; Fri, 07 Aug 2015 02:01:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=u8dTKhlxzfDoCK67ITyhJgWVBpk/HtAomVt9HM9A7A8=; b=alh46bXH3kTgivT19xt303gYqs45UbRvtaJXaZn7MfCA+SHwYIovwQgw9AjyMyfaCj uu2u5+SV7+MT5uil4Lyr10qhCn8HaI56QT1/nHtFiazvxXZBXXNvN4n0H7g2IGN+bbgM +lDKYqChlKiUJIHGLTz3WVG2U6Q9XNt9lB/7PLHBhfhoN0tnVpYR1tuIURT8CJcZ0rXn rGcb1pgCDMEw8gz5qjeYPLx8SKSAKczip56qVYIjL9lpqs3AUWfEHvBkLZLK+xn30rxJ sj826BUebAtaju7PDNplL11VEyKcJpatLW7u804bjXSNg8fA4BHl9idwxnT/p38j1HWQ ceYA== X-Gm-Message-State: ALoCoQluzJrQeHejlSrWHhsnSGIhJKh15WeVr+qL2JXVtRtT7NQXuExkXqZkrcDkUHBQsvtuz59r X-Received: by 10.152.28.100 with SMTP id a4mr1814513lah.4.1438938075789; Fri, 07 Aug 2015 02:01:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.104 with SMTP id u8ls450131lae.31.gmail; Fri, 07 Aug 2015 02:01:15 -0700 (PDT) X-Received: by 10.152.37.2 with SMTP id u2mr6483166laj.70.1438938075574; Fri, 07 Aug 2015 02:01:15 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id x3si7011140lal.47.2015.08.07.02.01.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Aug 2015 02:01:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by labd1 with SMTP id d1so4651152lab.1 for ; Fri, 07 Aug 2015 02:01:15 -0700 (PDT) X-Received: by 10.152.4.163 with SMTP id l3mr6553555lal.35.1438938075122; Fri, 07 Aug 2015 02:01:15 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp229768lba; Fri, 7 Aug 2015 02:01:13 -0700 (PDT) X-Received: by 10.140.148.17 with SMTP id 17mr11734770qhu.10.1438938073258; Fri, 07 Aug 2015 02:01:13 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f139si16812104qhe.28.2015.08.07.02.01.12; Fri, 07 Aug 2015 02:01:13 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 1372F6222B; Fri, 7 Aug 2015 09:01:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 1D8DC62068; Fri, 7 Aug 2015 09:01:06 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 4475E62070; Fri, 7 Aug 2015 09:01:03 +0000 (UTC) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com [209.85.217.171]) by lists.linaro.org (Postfix) with ESMTPS id 4F18B62211 for ; Fri, 7 Aug 2015 09:00:24 +0000 (UTC) Received: by lbbtg9 with SMTP id tg9so19277540lbb.1 for ; Fri, 07 Aug 2015 02:00:22 -0700 (PDT) X-Received: by 10.112.55.105 with SMTP id r9mr6434133lbp.89.1438938022747; Fri, 07 Aug 2015 02:00:22 -0700 (PDT) Received: from elxahtkds32.localdomain (host-95-192-176-107.mobileonline.telia.com. [95.192.176.107]) by smtp.gmail.com with ESMTPSA id df8sm2020602lac.3.2015.08.07.02.00.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Aug 2015 02:00:22 -0700 (PDT) From: "Balakrishna.Garapati" To: stuart.haslam@linaro.org, maxim.uvarov@linaro.org Date: Fri, 7 Aug 2015 11:00:17 +0200 Message-Id: <1438938017-6663-1-git-send-email-balakrishna.garapati@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Cc: lng-odp@lists.linaro.org Subject: [lng-odp] [PATCHv4] example:generator:move verbose from worker to control X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: balakrishna.garapati@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Balakrishna.Garapati --- Made updates to print recv stats based on mode example/generator/odp_generator.c | 81 ++++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 14 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index bdee222..5d1c54a 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -101,6 +101,7 @@ static void usage(char *progname); static int scan_ip(char *buf, unsigned int *paddr); static int scan_mac(char *in, odph_ethaddr_t *des); static void tv_sub(struct timeval *recvtime, struct timeval *sendtime); +static void print_global_stats(int num_workers); /** * Sleep for the specified amount of milliseconds @@ -371,7 +372,6 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool) static void *gen_send_thread(void *arg) { int thr; - uint64_t start, now, diff; odp_pktio_t pktio; thread_args_t *thr_args; odp_queue_t outq_def; @@ -393,7 +393,6 @@ static void *gen_send_thread(void *arg) return NULL; } - start = odp_time_cycles(); printf(" [%02i] created mode: SEND\n", thr); for (;;) { int err; @@ -434,15 +433,6 @@ static void *gen_send_thread(void *arg) >= (unsigned int)args->appl.number) { break; } - - now = odp_time_cycles(); - diff = odp_time_diff_cycles(start, now); - if (odp_time_cycles_to_ns(diff) > 20 * ODP_TIME_SEC) { - start = odp_time_cycles(); - printf(" [%02i] total send: %ju\n", - thr, odp_atomic_load_u64(&counters.seq)); - fflush(stdout); - } } /* receive number of reply pks until timeout */ @@ -502,16 +492,16 @@ static void print_pkts(int thr, odp_packet_t pkt_tbl[], unsigned len) continue; odp_atomic_inc_u64(&counters.ip); - rlen += sprintf(msg, "receive Packet proto:IP "); buf = odp_packet_data(pkt); ip = (odph_ipv4hdr_t *)(buf + odp_packet_l3_offset(pkt)); - rlen += sprintf(msg + rlen, "id %d ", - odp_be_to_cpu_16(ip->id)); offset = odp_packet_l4_offset(pkt); /* udp */ if (ip->proto == ODPH_IPPROTO_UDP) { odp_atomic_inc_u64(&counters.udp); + rlen += sprintf(msg, "receive Packet proto:IP "); + rlen += sprintf(msg + rlen, "id %d ", + odp_be_to_cpu_16(ip->id)); udp = (odph_udphdr_t *)(buf + offset); rlen += sprintf(msg + rlen, "UDP payload %d ", odp_be_to_cpu_16(udp->length) - @@ -589,6 +579,67 @@ static void *gen_recv_thread(void *arg) return arg; } + +/** + * printing verbose statistics + * + */ +static void print_global_stats(int num_workers) +{ + uint64_t start, now, diff; + uint64_t pkts, pkts_prev = 0, pps, maximum_pps = 0; + int verbose_interval = 20, worker_count; + odp_thrmask_t thrd_mask; + + start = odp_time_cycles(); + while (1) { + now = odp_time_cycles(); + diff = odp_time_diff_cycles(start, now); + if (odp_time_cycles_to_ns(diff) < + verbose_interval * ODP_TIME_SEC) { + continue; + } + + start = odp_time_cycles(); + + worker_count = odp_thrmask_worker(&thrd_mask); + if (worker_count < num_workers) + break; + if (args->appl.mode == APPL_MODE_PING) { + if (worker_count == num_workers) + break; + } + + if (args->appl.mode == APPL_MODE_RCV) { + pkts = odp_atomic_load_u64(&counters.udp); + if (pkts != 0) + printf(" total receive(UDP: %" PRIu64 ")\n", + pkts); + continue; + } + + if (args->appl.mode == APPL_MODE_PING) { + pkts = odp_atomic_load_u64(&counters.icmp); + if (pkts != 0) + printf(" total receive(ICMP: %" PRIu64 ")\n", + pkts); + } + + pkts = odp_atomic_load_u64(&counters.seq); + printf(" total sent: %" PRIu64 "\n", pkts); + + if (args->appl.mode == APPL_MODE_UDP) { + pps = (pkts - pkts_prev) / verbose_interval; + if (pps > maximum_pps) + maximum_pps = pps; + printf(" %" PRIu64 " pps, %" PRIu64 " max pps\n", + pps, maximum_pps); + } + + pkts_prev = pkts; + }; +} + /** * ODP packet example main function */ @@ -796,6 +847,8 @@ int main(int argc, char *argv[]) } } + print_global_stats(num_workers); + /* Master thread waits for other threads to exit */ odph_linux_pthread_join(thread_tbl, num_workers);