From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0045.outbound.protection.outlook.com [104.47.36.45]) by dpdk.org (Postfix) with ESMTP id EF40D1B4F2 for ; Wed, 11 Jul 2018 08:08:18 +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=wTUWZ6YXvnUOs7mzK2kAno2elRpdK5zaoty3pQKLr9k=; b=DKaBUOC7mR+QVa6E2isuu7nAVFF5S5hWG8LdnSC1bXW1tLPBCRvLiiUpwVNPKDd8hZ4KVs5rRPZcEmIdTKSc6X1lFjNbPcsgL3Sr+nucMv5O0UQUGvAXzznBwEyPAiD+Vay1LL4QuA/yyPI9cHWmYBK417nWXMe4wrl9pPZ+DAs= 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 BN7PR07MB4898.namprd07.prod.outlook.com (2603:10b6:406:ef::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.21; Wed, 11 Jul 2018 06:08:16 +0000 From: Anoob Joseph To: Bruce Richardson , Pablo de Lara Cc: Anoob Joseph , Jerin Jacob , Narayana Prasad , dev@dpdk.org Date: Wed, 11 Jul 2018 11:37:24 +0530 Message-Id: <1531289248-20025-9-git-send-email-anoob.joseph@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531289248-20025-1-git-send-email-anoob.joseph@caviumnetworks.com> References: <1528976946-14396-1-git-send-email-anoob.joseph@caviumnetworks.com> <1531289248-20025-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: BMXPR01CA0027.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::13) To BN7PR07MB4898.namprd07.prod.outlook.com (2603:10b6:406:ef::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8e3c51fd-4696-421c-e889-08d5e6f4b234 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:BN7PR07MB4898; X-Microsoft-Exchange-Diagnostics: 1; BN7PR07MB4898; 3:8RPOgI3PdO8gWfUb3SvdZ7Fvs3o50RqoTltyWrvEfUsNDvjKSHgqUVwispm9Ijhk3Nzv1bDZGSVjTpe+zxZrkYRlDLPpnh57F+XEB35j42jkaEV2X3SqNu++qxXKxhpTgyZS05059uaN50O8yjSOKgA/B2jwZ4VVCoTDdMTSQqMFAyqHLQ1skOdX44hMwLeA/pKLNh8XFmrFZlYB9wKtKGRewiVK49FK9LZvgnzKC7TmeC+vSul/6p5Gq0OfsoXy; 25:hrgt8dhJFRE3m1JqMIRZ4cByNVNho7mZbM0D/24Ys6zHEw42qgqSKFk99vxIbOseyELm1vHYUsGz+b5ADpSjmgLm4VRRAnLE6LAutS5r2f7sr6G5RX+YlUw9v8bXRu/yXTt/NxUJiZMWDWOsm3tcKfbTF6hX1sdRI5/TB9aLJeloKc5jv7lRZFG5cjdQmjH7wnrkT8yGICAa7DOYhgWBI2hv6JATJ60DyESr+QM7Ee4EKdvvI/TL/Jx5OCrW/xYH3bTv0DoEIyvuqKCbGEn5UAfbQQoXtCKluwuqKSOSXHMb2Cd4Et1MbHfMRKcUyZVgaC9S2aZEHaCk+VPoSlvxkQ==; 31:H2CHQifbfF+DQWKxrayczTHw9bZFi4+wym/sdEal3XQCfsfaGfXDoIfUmUfulgc44cfAfWfdV1Tva4eySJFtnMP/3d5TsG3WIYtpK5Yt+Jgh8uazzCG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ncimjllp4NWw2A== 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)(8121501046)(5005006)(3231311)(944501410)(52105095)(10201501046)(93006095)(3002001)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:BN7PR07MB4898; BCL:0; PCL:0; RULEID:; SRVR:BN7PR07MB4898; X-Forefront-PRVS: 0730093765 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(136003)(39860400002)(366004)(396003)(189003)(199004)(68736007)(81166006)(8676002)(81156014)(44832011)(50466002)(6666003)(25786009)(6512007)(7736002)(4326008)(6486002)(48376002)(8936002)(2906002)(3846002)(478600001)(575784001)(72206003)(305945005)(6116002)(486006)(16586007)(2616005)(54906003)(110136005)(316002)(36756003)(476003)(956004)(446003)(11346002)(47776003)(26005)(42882007)(52116002)(105586002)(186003)(76176011)(16526019)(66066001)(106356001)(51416003)(97736004)(6506007)(55236004)(50226002)(53936002)(5660300001)(386003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN7PR07MB4898; 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; BN7PR07MB4898; 23:2J8SH9rXGZsQ5PzlDdjD/4jk1/xzx2NLhwHTQr4Ss?= =?us-ascii?Q?c3a3GGcaVWk+LPtqbyULcnmkdT4RYBt4bRa2ZQFPeXQEShUO0DN8xOpr4BQl?= =?us-ascii?Q?6XlQQJrnnJU+QpHvDvgX7/7+fTSwnZ43i50RnrIGCorUp7lfjLMJnNCErdOd?= =?us-ascii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Q859X871J?= =?us-ascii?Q?JIKVNOUhmsj7h9MvUQy9cCgqankb8Ol64YELiVNGeqTOByW4r6TkCpyeAfS2?= =?us-ascii?Q?1E5yZh1JaEh0ZAf682hmYCJJ6fyWFBGXfxFA7J2uCufTWJB9lJe4ErxlFBEE?= =?us-ascii?Q?Ymr9fMhxYP1ZWfkA8E2yC+R76xysqgdvXiqGV7m5u1u8BO/X8es0mU3MvEQU?= =?us-ascii?Q?WS53FJZtIbYi848iopHJP1RO1gmKe94AM9c3kdg?= X-Microsoft-Antispam-Message-Info: pVowWTX8jjecM9uWDNdv3J093xWu56sQ4ja19UeEsgKsf1jO1oEcTGqdBoMcVRUSPgpUmcn/h+T81hNuFVl3Tl4dMzTseBurF+ttlHd05fAlsqWmKyiynItC6OXPhz2xZcK2lOIhUtw0BpBx3iIfpGHd3Gw/cjXShH8uRoYIvMVBixC9Hxi+no8vNibHR0ieL2dS7WdD+ONl1fKHFCZk78+1y8R88HPBwz7iU5PhDBMcdWfDBX8GgKNJVcrhfbpkZQXmlQE0dk1RyieA6cNFh1c6Ls9OQjSs2I/vTgpHBDJPrYyJBlY5sac2TJ4WKdWxklj9+pJSlUzDSCd9WcyfSAxaU0xQ4XmoRgviFv5o0UA= X-Microsoft-Exchange-Diagnostics: 1; BN7PR07MB4898; 6:SXlJq3I29XprYMBfX3NWtUho+exvWFld03zOV66y3LZimIC+CiB2olQTz+jf1FrrFfzeNSAxHrimcibeoPL2yHDdtDkIBeZBP8zxp/Ku4wc6OfM348zlwxnvrGZr1NY28E7cXQJxkhVzCuj3dTdVCIYeMZMKb89K5cRFoijokaCF3uD6dZO8zXK+GaGA0F+vYxES6WvhYwbrV7G8ZMZQaNUOLonNRjqkrJNUc8Td+mlXCM+woZYAXIzzFazVneHk8lhM+290Vp/ymh2EW4pcn8kQb7GWJ1LLceO0Lh5jhF8U16gPx+jEQxHWOkxDk3MHuHaP2S+vwFqe98yyAMf1wWeUQApoY93JI8cbqQQrYo/eCzduR5Si119IkEfgXqKeftTqgjx7jiBCctXsH4z4sFgJh+UobxYa7tKiWBiPyV9OAVT34mUOBXEdOS3enbSp31ppuo2z0YFjmnH8zRJesA==; 5:b1tFC4cFXUeSOBxmMJU0e5geIxjwyY237FI/8lw2kcnlj8lchq9RGKMeXhFCcX6yo7oLs+gNfSTkcwhyEjwSNWOQTpXlYij0FOETQ6+pRg8uhYxDFDryVujo1AueWP8Xgp9X2zPmlNqtEOgGQNjOZvDC7YxT4bt8rOub/KK16Ug=; 24:QtpPgOGraAmK0T6VGrGTE+QXU3gQ1fC/eZ0suG51/Io3KlvFG3XhuwKsA17Qr0dhSeXrLmeT4sSrIdcaLd6SnUl9WgwmWKhx7i8dkS9NM5Q= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN7PR07MB4898; 7:XRfwccNcGyJ1p12ZqG92lbTJ7YDqjj1MgImEf04gu6qAQJwfNclGFQ83Gh1gMBRPyPAVDQSCusGm00kPn5OwfcZpHXnUYDfToPxIB7Sibt1vDMo1EkxvpW8T1eDOEGfbRnm+D+/MiT5azTE6XJH9f8SxC7sDOLuIxDKiOy+WpLwpoCtBpMeVH1Au6FEepOnqc7zGvMMgnvQXWkHuVXDyvj9gb7oxE2RZ6lqtR5sOizqYfKpgO6Qn90wdFK90bKaO X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2018 06:08:16.0050 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e3c51fd-4696-421c-e889-08d5e6f4b234 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR07MB4898 Subject: [dpdk-dev] [PATCH v2 08/12] 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: Wed, 11 Jul 2018 06:08:19 -0000 Move the periodic operations (stats flush and drain buffers) to a new function. Signed-off-by: Anoob Joseph --- v2: * No change v1: * Replaced 'unsigned' with 'unsigned int' 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