From patchwork Tue Aug 4 09:07:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balakrishna Garapati X-Patchwork-Id: 51904 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 011B622E8E for ; Tue, 4 Aug 2015 09:08:16 +0000 (UTC) Received: by wibdx1 with SMTP id dx1sf4045469wib.2 for ; Tue, 04 Aug 2015 02:08: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=QJe/25vXwoN2qkafuS4Ah1Tp59IH8oSykWMIcDBf86U=; b=e4QpObo4ylHih9Yk20Qa8Oteoog0jOA5CW8uGKpuzjDevSDo5WqhIMuU+TdhLrXlIS 1E67JueFeF/pRUADf0XhuMS/JLuoOIPeR8vWfd+VMNBNDSn74ZEil1JO1P+xpCcAManI d72T0khuJ0OMMQQN+Olarl1wlpXSZCOO4c0hSEdR8Sq58jiUEwYT4XyAt8Wmy1DPFRqc R6V0IByT+CDrqPOQZJZcKGo9lSn/Kbbio5pscH0zxaPy9IZJfPYYhVmR8/JrKSYnQT2C LY5DdbBklR3kMueAlKToLLUrktXTV68M6FfzOvxX79vSKAGY58nwYW4SNgVEihhANqmx mPKg== X-Gm-Message-State: ALoCoQlNRWqld/RieArmAjzuyicLvrVljrZT29n3F+Hk/1Oo4JjNIlfuPoNRT7DtNwkXaJRE8lgl X-Received: by 10.194.173.3 with SMTP id bg3mr803429wjc.5.1438679295316; Tue, 04 Aug 2015 02:08:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.129 with SMTP id s1ls18861las.11.gmail; Tue, 04 Aug 2015 02:08:15 -0700 (PDT) X-Received: by 10.112.83.135 with SMTP id q7mr2212320lby.13.1438679295145; Tue, 04 Aug 2015 02:08:15 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id q12si226851laa.172.2015.08.04.02.08.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Aug 2015 02:08:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by labsr2 with SMTP id sr2so2729598lab.2 for ; Tue, 04 Aug 2015 02:08:15 -0700 (PDT) X-Received: by 10.112.166.2 with SMTP id zc2mr2179184lbb.29.1438679295038; Tue, 04 Aug 2015 02:08: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 l6csp2302005lba; Tue, 4 Aug 2015 02:08:13 -0700 (PDT) X-Received: by 10.107.152.148 with SMTP id a142mr2385353ioe.196.1438679293313; Tue, 04 Aug 2015 02:08:13 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g14si645335igt.9.2015.08.04.02.08.12; Tue, 04 Aug 2015 02:08: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 CBD2561F6C; Tue, 4 Aug 2015 09:08:11 +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_H3, RCVD_IN_MSPIKE_WL, 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 CAEA161F65; Tue, 4 Aug 2015 09:08:07 +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 405AA61F66; Tue, 4 Aug 2015 09:08:06 +0000 (UTC) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com [209.85.215.49]) by lists.linaro.org (Postfix) with ESMTPS id 2511A61F52 for ; Tue, 4 Aug 2015 09:08:05 +0000 (UTC) Received: by labow3 with SMTP id ow3so2735494lab.1 for ; Tue, 04 Aug 2015 02:08:04 -0700 (PDT) X-Received: by 10.152.36.41 with SMTP id n9mr2193063laj.79.1438679283970; Tue, 04 Aug 2015 02:08:03 -0700 (PDT) Received: from elxahtkds32.localdomain (host-95-192-5-28.mobileonline.telia.com. [95.192.5.28]) by smtp.gmail.com with ESMTPSA id x4sm89517lae.19.2015.08.04.02.08.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Aug 2015 02:08:03 -0700 (PDT) From: "Balakrishna.Garapati" To: stuart.haslam@linaro.org, maxim.uvarov@linaro.org Date: Tue, 4 Aug 2015 11:07:57 +0200 Message-Id: <1438679277-28178-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] [PATCHv2] 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.41 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 --- Added packet rate stats example/generator/odp_generator.c | 67 ++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index bdee222..aee6e7e 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(void); /** * 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 */ @@ -589,6 +579,59 @@ static void *gen_recv_thread(void *arg) return arg; } + +/** + * printing verbose statistics + * + */ +static void print_global_stats(void) +{ + uint64_t start, now, diff; + uint64_t pkts, pkts_prev = 0, pps, maximum_pps = 0; + int loop_forever = 1, verbose_interval = 20; + + if (args->appl.timeout != -1 || args->appl.number > 0) + loop_forever = 0; + + start = odp_time_cycles(); + do { + pkts = 0; + now = odp_time_cycles(); + diff = odp_time_diff_cycles(start, now); + if (odp_time_cycles_to_ns(diff) > + verbose_interval * ODP_TIME_SEC) { + start = odp_time_cycles(); + + if (odp_atomic_load_u64(&counters.seq) > 0) { + pkts = odp_atomic_load_u64(&counters.seq); + printf(" total send: %ju\n", pkts); + } + + pps = (pkts - pkts_prev) / verbose_interval; + if (pps > maximum_pps) + maximum_pps = pps; + + printf(" %" PRIu64 " pps, %" PRIu64 " max pps \n", + pps, maximum_pps); + + if (args->appl.mode == APPL_MODE_RCV || + odp_atomic_load_u64(&counters.icmp) != 0 || + odp_atomic_load_u64(&counters.udp) != 0) { + printf(" total receive(icmp:%ju, udp:%ju)\n", + odp_atomic_load_u64(&counters.icmp), + odp_atomic_load_u64(&counters.udp)); + } + + if (args->appl.number > 0 && + odp_atomic_load_u64(&counters.icmp) >= + (unsigned int)args->appl.number) + break; + + pkts_prev = pkts; + } + } while (loop_forever || args->appl.timeout >= 0); +} + /** * ODP packet example main function */ @@ -796,6 +839,8 @@ int main(int argc, char *argv[]) } } + print_global_stats(); + /* Master thread waits for other threads to exit */ odph_linux_pthread_join(thread_tbl, num_workers);