From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-CO1-obe.outbound.protection.outlook.com (mail-eopbgr690073.outbound.protection.outlook.com [40.107.69.73]) by dpdk.org (Postfix) with ESMTP id 7433D1EA25 for ; Thu, 14 Jun 2018 12:19:24 +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=sYsLFLpU7e23bwaUoXa0pcj75F/xkVKL4feXj2JmHmE=; b=CBPcw4csIBfDFC04lKQhJiCf7l1R651JXb3kEXHQBPT8CVZQiBZ8r5XL0RO65Mb5Pde2oIlR43ZAWQvagSbYhZEF9jF4RbPuvXIjoFw5EFYm/c16uzYtqKoQ7mJHfRsGf74W2xeq2o0OfxVRAZGTHTHbMzmUieDOh1oJ9M8p/PA= 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 BYAPR07MB4902.namprd07.prod.outlook.com (2603:10b6:a02:ef::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.841.19; Thu, 14 Jun 2018 10:19:20 +0000 From: Anoob Joseph To: Bruce Richardson , Pablo de Lara Cc: Anoob Joseph , Jerin Jacob , Narayana Prasad , dev@dpdk.org Date: Thu, 14 Jun 2018 15:47:53 +0530 Message-Id: <1528971477-14156-12-git-send-email-anoob.joseph@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528971477-14156-1-git-send-email-anoob.joseph@caviumnetworks.com> References: <1528477766-15788-1-git-send-email-anoob.joseph@caviumnetworks.com> <1528971477-14156-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: BM1PR0101CA0031.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1a::17) To BYAPR07MB4902.namprd07.prod.outlook.com (2603:10b6:a02:ef::25) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2a2746e-0123-4ada-206e-08d5d1e04c72 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(711020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:BYAPR07MB4902; X-Microsoft-Exchange-Diagnostics: 1; BYAPR07MB4902; 3:hqP/5KUgsa86MwqccOga58RsaO+BscwL1DqCLQVls2k/0uHhlvD8t7d4PtiNbi/xIWKvw/nJaLtzp1n72HY5okjatUCfSSbijeRCphRjfKqZ+ILrvc4JWWnvPnvcnT2v1Wu8hmNVrSjmRHddIQKrzWhaOr6FTlcwV5VGA/hrKAW+Qs69I6oqjT6ynPqj+HF9e71y5v2Eu8IZBNpJXdLQyoWgvjT7rvQKU7OPo0qR1je/CFsJ5UVdkRLHduXYCosx; 25:KSuupfGb7C8JvOnbsM+u4Lo6F2YpkEjb8PvtuUkH5vuIBbwEl8TbAcLeYcNnR1ID+MMOrV7bMBYbk/sVlrNmjQxDDGMAOevo/giTic3aOp4irKoyIobxH7fhwzCbCLtC4bd4tng8nEE3Z0Krw6aSKvHgRl+PwTXhpfYzJJtBo5ACfqnqPsAGOoqmo6LQTNXsJfwxXF2QJq2ORwOpoj4B60G8lYqSRgltL2pPaYenOkyvgOA+O1m/MJJfXT4dddTPdXRccmV5r7w4imTYtKYOIg/SXF6ZWRJVEF/P5i/lTa0Mx+rKYBEKo/hlliONNlL44ds7NM1lAJxXZaQFvcuclA==; 31:xHKlevG2MtNGO5Kul41idtCWGhp6EYjbSE2ad9vHlek+LTkackRxnNYTiGRhmbzMBzFrRf8DxRAZkyk8rG94rgdVPbAkIFZ6CYtLj3ULFd18kPLekSB2TgwoLcsPX3AFalLq6V2WaNE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RVS: 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)(3231254)(944501410)(52105095)(10201501046)(93006095)(3002001)(149027)(150027)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:BYAPR07MB4902; BCL:0; PCL:0; RULEID:; SRVR:BYAPR07MB4902; X-Forefront-PRVS: 0703B549E4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(39860400002)(39380400002)(376002)(396003)(366004)(189003)(199004)(316002)(6666003)(110136005)(68736007)(2906002)(66066001)(54906003)(47776003)(6512007)(5660300001)(50466002)(72206003)(48376002)(97736004)(6116002)(3846002)(53936002)(16586007)(105586002)(478600001)(6486002)(106356001)(6506007)(575784001)(36756003)(11346002)(956004)(25786009)(4326008)(50226002)(16526019)(186003)(81156014)(486006)(81166006)(8676002)(7736002)(26005)(8936002)(2616005)(476003)(386003)(44832011)(55236004)(52116002)(42882007)(51416003)(76176011)(446003)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR07MB4902; H:ajoseph83.caveonetworks.com.caveonetworks.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BYAPR07MB4902; 23:8y8Vnpzp1Uuw2hIH8ZcondYBI/7g9FwEIxR7+d7Zd?= =?us-ascii?Q?QflN8o7wH4HMkv8xvuYog4X1HHKYezQpVWCydpaPsV/XVuMuQgINMVOfSzU6?= =?us-ascii?Q?O1G5iW/nAhYn8em4PHo2kr8fd6gxLs9IGovTGspBvWI/qu2+/S7LoOhU3OVS?= =?us-ascii?Q?/61UsvV66NP39Rf8S5gH/VFkQ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327mbPY8ThbKkklUX0mBMto2TXmAyWVHHG72mbtUFjkDO3/brRq42i90Qfu0fiygP7NG0y6mIAAow0cFN6eyJ6jtXOB2LyjWkf6sVAoZltyBaBpaG7g6KwT30WuMU1dATyJ3xc=; 24:e0aByl0uXeO1jwr8wQu4PMl8D+G+6MZ6eZR70L5HUUqQlG8RTntakPh4XQSNKJeillk7KRq7nRbGjWgWNm6Q/GyJ/rdnCtU8wE1jwjnkEno= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BYAPR07MB4902; 7:84RrfvF/surSHPIMz3wVXNopqUzimQtv1/grVaA+8k18PDoAAHAs39Nrt0CM7fYxsXi1CqLIUVS+w62EX0yxUmkKQuQK4hnCcMBcjpJe7MQXW8Vvx2XMLPsc8xGiMSW8rJiSM9ddlIzJKwC0ZXz2QZpU2lMfllEAPaI8uL/7jg9wIxJDKrvX3Innp2iqGzowFliqWZZW3oFTxJNp2kiPY92W4F1yIcaDSh3R8tRauAfGO/dWWVwFyKqQCNVbwPRp X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2018 10:19:20.4934 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2a2746e-0123-4ada-206e-08d5d1e04c72 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR07MB4902 Subject: [dpdk-dev] [PATCH v1 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: Thu, 14 Jun 2018 10:19:25 -0000 v1: * Replaced 'unsigned' with 'unsigned int' 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 f847832..868d0c6 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 int dest_portid) { @@ -135,19 +174,18 @@ l2fwd_main_loop(void) struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; struct rte_mbuf *m; unsigned int lcore_id; - uint64_t prev_tsc, diff_tsc, cur_tsc, timer_tsc; unsigned int 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