From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0079.outbound.protection.outlook.com [104.47.36.79]) by dpdk.org (Postfix) with ESMTP id 7230B1E41E for ; Thu, 14 Jun 2018 13:50:23 +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=3ujizhMt6BxMDVk4rYl+UlWbWEJJgM1y/CxQz4wXMV8=; b=g9sGu1gmX2wsHJiPcab1+2DhE4v3JvEF/xc9nnPXFkk5t2XaxIT81E4qyCAdyYARATDeymLM1UtGRS+ErsuiD/CKF8Hnk5m1N6RtZvpVUHOcfHI4t8I8ARNeu3fjvM5UgURFPlM7NMLqDlbnbhGnZM5+4nwkxEiE0Cmgva9CSCg= 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.863.16; Thu, 14 Jun 2018 11:50: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 17:19:02 +0530 Message-Id: <1528976946-14396-12-git-send-email-anoob.joseph@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528976946-14396-1-git-send-email-anoob.joseph@caviumnetworks.com> References: <1528477766-15788-1-git-send-email-anoob.joseph@caviumnetworks.com> <1528976946-14396-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: PN1PR01CA0095.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00::11) To BN7PR07MB4898.namprd07.prod.outlook.com (2603:10b6:406:ef::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d644f60b-64f8-49a7-3746-08d5d1ed02ab X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(711020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:BN7PR07MB4898; X-Microsoft-Exchange-Diagnostics: 1; BN7PR07MB4898; 3:Kq9xBsBn3eHckMbMjLUemXcQQW3KafDtVjyoA27rBw5aokiJ1tce8mqpY1gA2S7Y7I/x6sJXEexRUbMTFkmd4kiukQGPON6kCtgNGCFKKB5rGfCsPe9Q5QgUsmy8kmDFUrWGtOpmpgUT6ih9tJf5w3y3uOBmxpnJ8K0fI/dpCp3lfwbBKpQTznBvDEq/6csRz8xQVTREJfiQ32r1BhpuDpqG/3XHFquXgdUR6NA/QokcVjIwTAjoUk57cxuP8gGt; 25:r+D0oiYGgjC7Nv1vm587Pk02VV0anBMouuNVl8BmXzSm0cUlhyIJ5Hy9piX1ne2nLwUQoTfxHZeRUjJ1+euECpeyK/D8k21ukc5OxOked+zN+wZveEzt7zQrO1KtUys9FlCd260neQa6TDTkrutCa/N4gpoyJz1U0SGBxjG8chbvDRLUlQNneJlKYcFKlMTIdJW6WZ0yxo4lusDgtQZK5Wxo4eD6cgAVXdR33JL4hlEKDg+fXDGnsWrgIl9DPv8+Ufo8FvaTUSr9g8Ju0aOuYIZ7vLqDrMq6dmgoc3/PB+/mUsTnrgvCwzuXpGdDPHN7tnK4RwNdnC6GmfA+108hDw==; 31:pIeMCmaysPA4pmPXmcZgW6cHrxlKivCVG3fpyWVAZ5XE9KBQQN3V5vUxeFaaMrbsM8YFnZhoL1DluriUj/uCd6mOjcH/Coyf/xm4JF6dSE8HGL9hW24f9IaUxqRITAPoiX5QVEa39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-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)(10201501046)(3231254)(944501410)(52105095)(93006095)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:BN7PR07MB4898; BCL:0; PCL:0; RULEID:; SRVR:BN7PR07MB4898; X-Forefront-PRVS: 0703B549E4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(39380400002)(396003)(376002)(346002)(366004)(199004)(189003)(446003)(956004)(2616005)(305945005)(6666003)(47776003)(476003)(54906003)(44832011)(53936002)(68736007)(486006)(110136005)(8936002)(8676002)(81156014)(16586007)(316002)(81166006)(25786009)(4326008)(7736002)(6116002)(3846002)(11346002)(97736004)(36756003)(106356001)(478600001)(105586002)(42882007)(52116002)(51416003)(26005)(16526019)(186003)(50226002)(66066001)(72206003)(6486002)(2906002)(55236004)(50466002)(575784001)(6512007)(386003)(6506007)(5660300001)(76176011)(48376002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN7PR07MB4898; 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; BN7PR07MB4898; 23:+0+Pm6ZQCqMkxH0/ZZ2lwkhHFWYfTX40FdI7lVHHi?= =?us-ascii?Q?2Jp/53BQa/dJ91ZIJBaRniGDA4mBeJ9Hw06tvjDwtW4TsIj+3YjCD7DVpKEy?= =?us-ascii?Q?9gLBSlIZo8mZJPGb4WChgz0INXZ39aiZX46Wju5du+5rNVQk08zqeIyZJQRl?= =?us-ascii?Q?LEY5+3D63pYr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8lv6Klur0Cvv7yD5/p/O/+tul9jwVcR4irqwa0+RwL6eDJ+t1bdyt3MfEnhaiR6F7/y4wKUreyx3B/pVIjDVN3LSs2uv8EmMx+UWu76mOB0JHpBVCJqkryv8nmr6DXmB59FFEx5+hxTU=; 24:USqu4vdi/8XFvgHVBgzd+JmQ34EwB59PfujEl89uPzocbrxi1jE92sI8VCzyjIq4+K1pUFUvOFIdFJ4P7ptEnkxGAL8lRurIbtjVJ3kLxpU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN7PR07MB4898; 7:vMDcaedMHvH5TAMJNqThTX2KHpNQuYpFn688KyUItEVSPYph0spI8/I8m/h+9M9fjl+FGRx36/A8d4dTrOQc0o0Ey5Mv7d8TkavC/yPaRjrJAFZ9UT56GXy/f7y/83L5QFlr/7kMB/MfkblkTf+7chSCD48ZW9pFgvI5G5fsZ0yLwuVwpyDeqFHvOR3cPvXOZJWz+3VMcQFe508FlE6bDP3ZUlNHFiyfnX5JqTOYhZriXScI0nC8xatgqZzwYirn X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2018 11:50:20.7670 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d644f60b-64f8-49a7-3746-08d5d1ed02ab 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 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 11:50:24 -0000 Move the periodic operations (stats flush and drain buffers) to a new function. Signed-off-by: Anoob Joseph --- 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