From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 41DE4A050C for ; Thu, 7 Apr 2022 13:43:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 378B3410DD; Thu, 7 Apr 2022 13:43:07 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2079.outbound.protection.outlook.com [40.107.236.79]) by mails.dpdk.org (Postfix) with ESMTP id 6C25640689; Thu, 7 Apr 2022 13:43:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dC/Nn5xUnmdQmfrdN44cWa+X8cpGGlk52tHjGiMaXkim8wJvOeTZJ8iZC81/Yf4GUgohRqpAgo8J+VM/rwk0mxA0oMPNxd6ZqaSX9itTX0G7I6FndNQ/HUW2PZerV0Num7sm+1SV/Ti9oDaGQ0QZdWbTz5DBKbawgqH08QLEvExG1QIaBkUbt3irZE6tKWWq62AG2tIuOLoI7CSI/3V5Ki57F3v7Xr75yB7skFzQihU3KBW2/vp1e0EHAsv5d8O2zq2VAsTcZuQNe9skRSTwdBhLtC0hXN6AXbaULShnsGwxaehyAhYBdD6o/GHVfH5xj6R0gF3ijV20hHV8g7nx4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Cgs4oLYsGWAE833ywn0mAMjP7a+QUZc7nXoU3nIKaxE=; b=NP/Ketps3re6OeMqWGW8vL2EZQqbrSioSQS7XbgTgUg9JCW+nz61705YC/ngYM2rE/Aj/wjsvuGrb06264us4jHptZBnfP0KuBSGaEwRIh23L1erDFXkCOEwiv7nUc9zbKZEyp2v87UM+5Osb7Z2oazv8lPlvYcHAHZAoyU9KP3OZntP8GLmtgkJMH0RD6OAi4bAgEB4ZnbPXtzXfge7H//YmzudSyLZ32M0A3P3UrVZ+Gk0u4nV5XXurwtwWJzQm7kzwZ34IpswQ4Cn/xhWW4ojVE5a/ULwMLiGUktttqzlhSGCVZoe1r0758O1dgip5fUmoBhxwlNQemc4+aiSqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cgs4oLYsGWAE833ywn0mAMjP7a+QUZc7nXoU3nIKaxE=; b=SsvZ4jl4VMVZOjc7/+nUl3MoQoFD2QdTE3JGsqqun4ZEdRflBX2DcbWQdrLvZo3E+gcsh+BV8zckFqSN0mvVYP7OvxH9mKYA8sqKwP+mRCQ8Y5lNCje8h40NR0yqbRWQAnbGK2SZTr41LWfOPe+NnDiQc99692trWpEUSHWjhM88eDJCMRKQmpX961oRxbeQUPBW6c3IOwOK5ZI/zxwrgc5bPKvvF5EjvyZRxHvDMeL61JChl7JEYfKtcQiQ/LCQ1l56om92nUPOksueJG8ExpW195BMt3dVvn/308R08hFLzukJwERu+Is9SbwEYB9MMvH6+V0Pfx4N29q6T1J/kQ== Received: from MW4PR03CA0355.namprd03.prod.outlook.com (2603:10b6:303:dc::30) by MN2PR12MB3886.namprd12.prod.outlook.com (2603:10b6:208:16a::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.21; Thu, 7 Apr 2022 11:43:03 +0000 Received: from CO1NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::35) by MW4PR03CA0355.outlook.office365.com (2603:10b6:303:dc::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22 via Frontend Transport; Thu, 7 Apr 2022 11:43:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by CO1NAM11FT057.mail.protection.outlook.com (10.13.174.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5144.20 via Frontend Transport; Thu, 7 Apr 2022 11:43:03 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Thu, 7 Apr 2022 11:43:02 +0000 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Thu, 7 Apr 2022 04:43:01 -0700 From: Raja Zidane To: CC: , Subject: [PATCH] examples/l2fwd-crypto: fix stats refresh rate Date: Thu, 7 Apr 2022 14:42:49 +0300 Message-ID: <20220407114249.15024-1-rzidane@nvidia.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55f2ecd2-3f76-41c0-1bb6-08da188bc65f X-MS-TrafficTypeDiagnostic: MN2PR12MB3886:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XrKoAseUeTD+JDezqkuesI4XGXAi1/AW1qfJudpzuTv0q0T2mMV0Fnq4sMkbzjqgk8fRKaNsp6VhTaE0S9ugJ1qMRVK1yhxevmogyq8s+lcm4XBEXdU48Mzy62pCTHTH2xpKPK2Z+uqw4i72Z3EaGdUSFT19IuOzeASBoknj9YfNszuEGR38Yqz/2rRLHFzbjmn22WksrATClrFskXT9+XAivsafBfuueiywt2MSHQT7p1RhzORKfL0/JzU8+avGHW4jJgj+XjFAUPch0Ur5SDYUdbMkQRp9Q2auPNFtYkPYGkrEG1ekBxx1VGPobTX3pzl0X44h+oRULztHiCyo0iHxcbSWTQinjGrbS4hmCc/FaH2M3Yud5IrwE/Ub2bllPyD982moLEvGAMrEA5C2wwus3JC0hLB9JmmV/HC0JteiQyiue3XsK2bszBgp8bPujt1ima+BVXHeGcOWLdIdzjt9eFQkPTSI30fRU8Of4a91bSnoDw38VjC35DrHNmohmFLgNFWvkTHkhAsH9ufiRpBYkHyd2IWtK9hCbkCl5p+xzpUSKTPNY/OuVar52OwZ1H4d/fqixYQG9jYHOkICKi1oxVSv4cTxxEdhpMDiMwtMiWs4X//uVe1gInV6hfj7hZg6Y892sjCV2gNkcy73DFE45gNaqQcBqQzNHilobSvuRJioCyT8aFjYFda6iK/Fz+qOS7iZoGu6/VxLG+eKjA== X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(6286002)(1076003)(2616005)(508600001)(2906002)(26005)(186003)(16526019)(426003)(336012)(5660300002)(47076005)(6666004)(40460700003)(8936002)(83380400001)(7696005)(86362001)(70586007)(36756003)(82310400005)(81166007)(316002)(6916009)(356005)(54906003)(70206006)(36860700001)(450100002)(55016003)(4326008)(8676002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2022 11:43:03.2739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55f2ecd2-3f76-41c0-1bb6-08da188bc65f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3886 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org TIMER_MILLISECOND is defined as the number of cpu cycles per millisecond, current definition is correct for cores with frequency of 2GHZ, for cores with different frequency, it caused different periods between refresh, (i.e. the definition is about 14ms on ARM cores). The devarg that stated the period between stats print was not used, instead, it was always defaulted to 10 seconds (on 2GHZ core). Use dpdk API to get CPU frequency, to define TIMER_MILLISECOND. Use the refresh period devarg instead of defaulting to 10s always. Fixes: 387259bd6c67 ("examples/l2fwd-crypto: add sample application") Cc: stable@dpdk.org Signed-off-by: Raja Zidane Acked-by: Matan Azrad --- examples/l2fwd-crypto/main.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index bbdb263143..b1e2613ccf 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -252,11 +252,9 @@ struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS]; struct l2fwd_crypto_statistics crypto_statistics[RTE_CRYPTO_MAX_DEVS]; /* A tsc-based timer responsible for triggering statistics printout */ -#define TIMER_MILLISECOND 2000000ULL /* around 1ms at 2 Ghz */ +#define TIMER_MILLISECOND (rte_get_tsc_hz() / 1000) #define MAX_TIMER_PERIOD 86400UL /* 1 day max */ - -/* default period is 10 seconds */ -static int64_t timer_period = 10 * TIMER_MILLISECOND * 1000; +#define DEFAULT_TIMER_PERIOD 10UL /* Print out statistics on packets dropped */ static void @@ -894,18 +892,17 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options) } /* if timer is enabled */ - if (timer_period > 0) { + if (options->refresh_period > 0) { /* advance the timer */ timer_tsc += diff_tsc; /* if timer has reached its timeout */ if (unlikely(timer_tsc >= - (uint64_t)timer_period)) { + options->refresh_period)) { /* do this only on main core */ - if (lcore_id == rte_get_main_lcore() - && options->refresh_period) { + if (lcore_id == rte_get_main_lcore()) { print_stats(); timer_tsc = 0; } @@ -1481,7 +1478,8 @@ l2fwd_crypto_default_options(struct l2fwd_crypto_options *options) { options->portmask = 0xffffffff; options->nb_ports_per_lcore = 1; - options->refresh_period = 10000; + options->refresh_period = DEFAULT_TIMER_PERIOD * + TIMER_MILLISECOND * 1000; options->single_lcore = 0; options->sessionless = 0; -- 2.21.0