From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0065.outbound.protection.outlook.com [104.47.34.65]) by dpdk.org (Postfix) with ESMTP id 68C191D006 for ; Fri, 8 Jun 2018 19:10:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t1ZXoF60oJTVz2CVz3Y9C6iGwz6u1u/MNDxBPjech/U=; b=QJni0EPy+9q0o5PqQTJzVKfqzyKDndL3EZGTi6AKu9CBSCzU3E9gPVWEc/ooQ4pdeNXbtjaCv68ujbHoaRvlKEeE4rSgz1BEpCJSF7Fas5AzLwTv6jn3+KjwVf+SYpNbqytiyvdEQEeQmGIKOm9pvjZOUsvgCob7kcrEOAI2lyY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Anoob.Joseph@cavium.com; Received: from ajoseph83.caveonetworks.com.caveonetworks.com (115.113.156.2) by SN6PR07MB4911.namprd07.prod.outlook.com (2603:10b6:805:3c::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.15; Fri, 8 Jun 2018 17:10:46 +0000 From: Anoob Joseph To: Bruce Richardson , Pablo de Lara Cc: Anoob Joseph , Jerin Jacob , Narayana Prasad , dev@dpdk.org Date: Fri, 8 Jun 2018 22:39:22 +0530 Message-Id: <1528477766-15788-12-git-send-email-anoob.joseph@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528477766-15788-1-git-send-email-anoob.joseph@caviumnetworks.com> References: <1528477766-15788-1-git-send-email-anoob.joseph@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: BM1PR01CA0111.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00::27) To SN6PR07MB4911.namprd07.prod.outlook.com (2603:10b6:805:3c::29) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:SN6PR07MB4911; X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4911; 3:pievWu7a6zjkf4Qo5zLQh62u1Rf29XIe3PqnZZmqXuctd8AU3VNOXoAwQ4oJr29w7L1cFTK5VyF1M+z18IZ8FqkoNNETIGDGJ1mx8AojDAYpLFiPHzB/fICWYhzdbKUMbPB+BDFsDHGbzYbkD05p6pynCtXgE4jnc0Bc9EiY0QTP1790bTxh1YOTamEgQJCUxzIeu97ouDNJQqKFXvsejw4KsVcVzV/TLMWp8J70huiCC1UQhbu2R4yKlxAdmCu/; 25:rsQMfNRQgMl4NFktnohAe73WM7YcPvU7hnkWqF2o8UXhN3ZW25Z03Tvs5tQicml/HOLCOW5Ivlo9qTZWtxGHGf6twx4VoWw8n/Xb4ewG5gKdXn9qkp2Z8Q1JfPIwp4GJl0cn56fx0CtJQMr25yUvWmIy6NeUY6odPITfos1k8qst4CSQlPhMEHfRIbnQN83PBkfKGn2tgVIL1kcwqRddpppdWtUqL9KngZ4ExTyPK975f/lzQnamW4w3XsAdjhshhuGlT4NrqnuFQMJFbX1vcPsOsvCJ+55xtfdYlZ/bvdAN14bm5Rv+HRlDq6s1QgyIoE2SbH+PbZM0oBEvj1ZHEg==; 31:6DRYRwcw1v3hFefPkXCSwZDeuhMl+bN2ToaIHivJdtz2zLaejnvSVgxe0cPk1Wys50TjIBp2lTdtFY+HeWbIrEtKSGnIOagJBI8UDxvGj5HbseSE0n1uAee/QkUvtrbhBemozFzlKvHr5QEk4InviSxDNJrecla4rgc9nuTvEpXvJDXOKV6aN7196k16HWTdwjadmfLuc+AELKC/YdF7jhzFTtQNLcRGemoVEJJL7bs= X-MS-TrafficTypeDiagnostic: SN6PR07MB4911: X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4911; 20:XbhXctFKmysC/yc6ukbrCXytH6G7X2j1C2aH2WU7fpjq8osqFLeS+iucBr7kfPSb6xGFFHS/paK//6LoalaglZSXNTQTAb6myrbwkC44+DXeavxlvrRSJacpgNb50yNyx7+cKFuzUix9Zz7lb7x/C4/Wq2Zz6kVp2/rwC5T/OtRbZzdirh55P7pqJI2QEQw9/6Pu1ohzWJ24HF+2qwfrg1O28xtnm1i56UMN2mtPqMZexNBkzxJpcu3iGvJzdsLxrlaBmdyDbpJvwBT/jSeOw/C9XZPU1Pc7WozbTRH0awE+d/2n+eXxHAPc3PpGQ7tvl/a5AFk6ti7n8B/xOhxu0ABacLhMlOyp9OfNLLq8WGsUaSBfJMFeKovJWy0fFV6CYa5H1bJ1w9SMFM0Kg6wcKf7NbDQU9F5lxXlAA57SjdctJhTELQW2l3aBcN+vBqIdvvacnycgIc1lCrCl/vCYTK5Erca0mcFTC/ldK+kSHKyG3bg5jaRkuMgyVSKGQxLPgtWoRnUIlhdLXSVBvGPUadYZ15jG4rHvIg2RGAN30cbiB5/0GorfazXfAkKGCZSMMCoPMzsNwYcADuTJNZa0M2CxLeiGdCWVQrDqmhxwkIU=; 4:Kyt8GlJfUvxOZVRMEejFDituZNhUuc9/ngdK43BCwN9QYT2fjmco+fjFKCvhyaH5m06M2KpQudnXEr5Erj0jB19UoYpSzM+TN1kMcMAwktOhDOLmF8dV9Sqj9pSKCV/sYSG5iMJ56Q078qgb2B23ZxrLIvJbpvnqzeI4ZsaRdIxef5tVbsw7ajDQoIDS0xokDttFunm1UtPT1Vp9juyrpWcLIZvPuH2uu1T068rpbQmLbvrN5XxCtMnYCO9DP6gEQgTR6LiHy2ld959n34m7AA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231254)(944501410)(52105095)(10201501046)(93006095)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:SN6PR07MB4911; BCL:0; PCL:0; RULEID:; SRVR:SN6PR07MB4911; X-Forefront-PRVS: 06973FFAD3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39380400002)(39860400002)(376002)(396003)(346002)(199004)(189003)(6666003)(4326008)(54906003)(76176011)(5660300001)(25786009)(48376002)(50466002)(446003)(386003)(186003)(11346002)(16526019)(2616005)(42882007)(44832011)(51416003)(476003)(66066001)(110136005)(36756003)(316002)(55236004)(2906002)(7736002)(81156014)(81166006)(8936002)(50226002)(106356001)(105586002)(68736007)(52116002)(26005)(956004)(8676002)(305945005)(53936002)(6512007)(47776003)(486006)(478600001)(6486002)(6116002)(72206003)(3846002)(16586007)(6506007)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR07MB4911; H:ajoseph83.caveonetworks.com.caveonetworks.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN6PR07MB4911; 23:YHjjZSNSnzte0pIebznrD9KReb6fEP9q27xaNLyxW?= =?us-ascii?Q?NC7c7B1LMeRUxY/spB7xfmGFvIrXreieQFcio6uRIgdfTSJhtAgEiQ6VUfLJ?= =?us-ascii?Q?glFG7vBvZlq1ihdhTYZs2vvvTOQD+wZE2nxjX6+J9PL0bfNRtUo/94zbfL1d?= =?us-ascii?Q?y9mYul1GO19ztjIwRZbY5sM46N0qhnBJYeO6I8dEI0KcTryrB7RPnXW8SN00?= =?us-ascii?Q?fqX9069CDtmXtUEA3hobvVEExPiSTePzN175RjKlt6ow0eEM/X4WrtgWQ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hJl9ueoZF+E8UHYbSZOiWCsdRtAQK4TFgfYm/Rf4OEZ4FhXpBKsCnTm+6yFkSCRE9ITkbu3T4dqcECrr5OMFKZxXUADZCHsrIFs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4911; 7:+yfW6yBiLLIMI5QgFtd4Wf4UWN7KucfHregpljZGX6/2navvRAdXSbOY80YOQxN8RkEGjNRgAeM5x1QYyRbi+YgNGe9x7kjpa1eDPkwmiwOMt8pUXZd0/uEuuD2Mn9aMNCUyY8m/mzt/G1dDo+ZOVIJyEtTTHl1iQZK02DcZUUAkAA1hxsrTez2GNbijZunL6qkg3eERwRPRt0wKJnLsMd5LMrv/FrmvnDOmsp/4/QfOzgPLI4iJgMHc6DdxdnQo X-MS-Office365-Filtering-Correlation-Id: 0a4fc839-bca6-474d-89d0-08d5cd62c7dc X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2018 17:10:46.4295 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a4fc839-bca6-474d-89d0-08d5cd62c7dc X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB4911 Subject: [dpdk-dev] [PATCH 11/15] examples/l2fwd: move periodic tasks to new function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jun 2018 17:10:51 -0000 Move the periodic operations (stats flush and drain buffers) to a new function. Signed-off-by: Anoob Joseph --- examples/l2fwd/l2fwd_worker.c | 83 ++++++++++++++++++++++++------------------- examples/l2fwd/l2fwd_worker.h | 6 ++++ 2 files changed, 52 insertions(+), 37 deletions(-) diff --git a/examples/l2fwd/l2fwd_worker.c b/examples/l2fwd/l2fwd_worker.c index f73de82..231b849 100644 --- a/examples/l2fwd/l2fwd_worker.c +++ b/examples/l2fwd/l2fwd_worker.c @@ -94,6 +94,45 @@ l2fwd_drain_buffers(struct lcore_queue_conf *qconf) } } +static inline void +l2fwd_periodic_drain_stats_monitor(struct lcore_queue_conf *qconf, + struct tsc_tracker *t, int is_master_core) +{ + uint64_t diff_tsc, cur_tsc; + + cur_tsc = rte_rdtsc(); + + /* + * TX burst queue drain + */ + diff_tsc = cur_tsc - t->prev_tsc; + if (unlikely(diff_tsc > t->drain_tsc)) { + + /* Drain buffers */ + l2fwd_drain_buffers(qconf); + + /* if timer is enabled */ + if (timer_period > 0) { + + /* advance the timer */ + t->timer_tsc += diff_tsc; + + /* if timer has reached its timeout */ + if (unlikely(t->timer_tsc >= timer_period)) { + + /* do this only on master core */ + if (is_master_core) { + print_stats(); + /* reset the timer */ + t->timer_tsc = 0; + } + } + } + + t->prev_tsc = cur_tsc; + } +} + static void l2fwd_mac_updating(struct rte_mbuf *m, unsigned dest_portid) { @@ -135,19 +174,18 @@ l2fwd_main_loop(void) struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; struct rte_mbuf *m; unsigned lcore_id; - uint64_t prev_tsc, diff_tsc, cur_tsc, timer_tsc; unsigned i, j, portid, nb_rx; struct lcore_queue_conf *qconf; - const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) - / US_PER_S * BURST_TX_DRAIN_US; int is_master_core; - - prev_tsc = 0; - timer_tsc = 0; + struct tsc_tracker tsc = {0}; lcore_id = rte_lcore_id(); qconf = &lcore_queue_conf[lcore_id]; + /* Set drain tsc */ + tsc.drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / + US_PER_S * BURST_TX_DRAIN_US; + if (qconf->n_rx_port == 0) { RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id); return; @@ -167,37 +205,8 @@ l2fwd_main_loop(void) while (!force_quit) { - cur_tsc = rte_rdtsc(); - - /* - * TX burst queue drain - */ - diff_tsc = cur_tsc - prev_tsc; - if (unlikely(diff_tsc > drain_tsc)) { - - /* Drain buffers */ - l2fwd_drain_buffers(qconf); - - /* if timer is enabled */ - if (timer_period > 0) { - - /* advance the timer */ - timer_tsc += diff_tsc; - - /* if timer has reached its timeout */ - if (unlikely(timer_tsc >= timer_period)) { - - /* do this only on master core */ - if (is_master_core) { - print_stats(); - /* reset the timer */ - timer_tsc = 0; - } - } - } - - prev_tsc = cur_tsc; - } + /* Do periodic operations (buffer drain & stats monitor) */ + l2fwd_periodic_drain_stats_monitor(qconf, &tsc, is_master_core); /* * Read packet from RX queues diff --git a/examples/l2fwd/l2fwd_worker.h b/examples/l2fwd/l2fwd_worker.h index 8971a6a..65650aa 100644 --- a/examples/l2fwd/l2fwd_worker.h +++ b/examples/l2fwd/l2fwd_worker.h @@ -4,6 +4,12 @@ #ifndef _L2FWD_WORKER_H_ #define _L2FWD_WORKER_H_ +struct tsc_tracker { + uint64_t prev_tsc; + uint64_t timer_tsc; + uint64_t drain_tsc; +}; + int l2fwd_launch_one_lcore(__attribute__((unused)) void *dummy); -- 2.7.4