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 0383145C76; Mon, 4 Nov 2024 13:16:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E71AD40E64; Mon, 4 Nov 2024 13:16:24 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mails.dpdk.org (Postfix) with ESMTP id 3A1AC40BA4; Mon, 4 Nov 2024 13:16:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730722583; x=1762258583; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=9r1/hu3E850j9AnixGWC7civ/KgG5qrXmp8/ffk3Xqg=; b=nkmZQzyBng2saExKwIvucerzYy8yd47czDQviROgVmkIT+7VoDdnsjd3 YQZHn7vsNHtZFsLK9DaKLBQ9iBOJBZ1R7zfRFRIuVUZPcJkcG8SGZrngI hpGjxXpePr0GCEey6z4wCO5CelCFvKx/EBxDunvgd1BgrC9aS3kvnPiY7 zoxM6Mq3nImfe0cRwF9zu2ZoQ/Dqa5jTIBwdf6QOx8LPP4Ql2YnaEdN76 R139hE03b1z4z9le+EhOqfToSZOkysSv5qn/4rqDFuqoQDYRg9XYjq+VM dHZy1bzUzI6CPt9sSrqlcUHxIU4j8Fhsn27f8PnJIteGtCigOjGtLh4WM A==; X-CSE-ConnectionGUID: gRXF9uxdS02MorfX4k6hKA== X-CSE-MsgGUID: xBvw2iW2RfO8GNqfds8MvA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="40965444" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="40965444" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 04:16:22 -0800 X-CSE-ConnectionGUID: 3sTr55m6TOiYW7meI9GoiQ== X-CSE-MsgGUID: 7v4ulwUdSLC1wrWPPVwQJw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,257,1725346800"; d="scan'208";a="114426996" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orviesa002.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 04 Nov 2024 04:16:21 -0800 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 4 Nov 2024 04:16:21 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Mon, 4 Nov 2024 04:16:21 -0800 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.173) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 4 Nov 2024 04:16:20 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aiSHFuORRyzMRWOThBM7DDw2M5NAaW9pKJMCtJ5zmgewimAOWj6Y0S+m+z6YNaOIKRZMpm4UvqG7fo1jFCuA5F8puLPcNfiYTIeeLyH6qUtqTDNtldfMTw12flQYFJlkRzarSnZyUP80cWupz/I5mT578QvYl2zn/E7MN3MhUrkc4EAier6AaXkS60LxnFu4XWcHBAwj627wC0wkd9nrAa3xfteF/DknL31jZJev+xPv3Cyq2LtNxvvcQcXy2U7vliI3LFBegxRqowFIIK1XLuby8Kbs+sclVyVpnmrtoU/xvrEq2v5E1rwkSaUyll5m4oT4ZC3R8wNoJk1DdhDCWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=wxQhInk4O3v0+yDGwLFkHeZ8mV46MjQoUC64Pryepgk=; b=ASVmCbVXlAialc5OCKeTt1vSdAbsn6CEmJjxlIs0l462KzhbnTWOKnUnyRZS5PlsxvZ0tyjqVBxp57cDgBHtn1yVQWiMtO9sLBapx62y0DCXXFNlMADDKckHmT6sPbWoFx4vfjqLqFxe2FM8SAgsIH+6g/0YcOXA8Eg14iuc0aW3zMoblWJdOP3o1l9Gqn/SnwyL8oBUtYQwQDRtxeGC3bHjGl4YExb/B1PpTXwsHVsZsmiFdGUOGspgL0IpCbY1CvXyarAvwfUwmKgOYls9oYonOPLMjSZIi8t9MfjqxbEsw+8MOgWl61P7CewAAWBd9Ujq4pTqttG7ro136p/Tqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by SJ2PR11MB8324.namprd11.prod.outlook.com (2603:10b6:a03:538::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.29; Mon, 4 Nov 2024 12:16:17 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b%4]) with mapi id 15.20.8093.018; Mon, 4 Nov 2024 12:16:17 +0000 Date: Mon, 4 Nov 2024 12:16:11 +0000 From: Bruce Richardson To: Soumyadeep Hore CC: , , , Subject: Re: [PATCH v3] net/ice: fix incorrect reading of PHY timestamp Message-ID: References: <20241030021611.871536-1-soumyadeep.hore@intel.com> <20241104103112.885071-1-soumyadeep.hore@intel.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20241104103112.885071-1-soumyadeep.hore@intel.com> X-ClientProxiedBy: ZR0P278CA0020.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::7) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|SJ2PR11MB8324:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ae81b92-422a-4992-e16a-08dcfcca7be7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?E89cKV7Unl+mi1iycRb+Jg6vQF01msEOpaaRJHhvNiPQK41wBoIAkSxWZu2U?= =?us-ascii?Q?V8CNP+qvioPebXG1vkZXApS0bDKaQwNPPf91NXoIpMx0Z8VfUZ1hvg9+fiAH?= =?us-ascii?Q?GUf053DXSHA1tZFL9Y+nUfH5kFtyp3PBW0f8STu9ReNNKOEE+CdLNds3wmRO?= =?us-ascii?Q?RrlIxx4nbybJI6vIexDXa/R902JYdEhohTVEwyKsFcRp76VJtZ2LrzyFnVcJ?= =?us-ascii?Q?3odnXraO4puTdYeAGG5Ldp51NoGXwzMZS4qziD1LOG34j/lL8h/YmYONFOQt?= =?us-ascii?Q?XZVhixLEVIhAaOID1ZNsSIJh/djCnwzFy+BUTxJBI3M4CDwyCvYFO95SIz2A?= =?us-ascii?Q?TbGSHfhWA7sFqYcBA3EUrSSO8XWDP4RC4pBAD3mp284y6ZorbmW8TL/F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CT4ZeXbmPyYQz/gfvpTXRB04XaxgTiPqluFq/n?= =?us-ascii?Q?NgM=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?F+KtG/LcXfr13tD85yMpnZ7dTRbK4geDRLPdDHfJn9GyPLZHKqz5CS965icE?= =?us-ascii?Q?krM0ZD+7zqV3OYT06xIV6uwi923wGvfGykp3utWwBQ8vHBLunSzycwe4D7z7?= =?us-ascii?Q?Me6xsoE2pU7Bwypr4Ag0p28DOZBW4Zbs/28H2OJJqMBsV2bAQZUfgOkJpC/h?= =?us-ascii?Q?eVgD/1ghD6NaOZhuifNHD1voer66o05ExZjey8AsGPGlYEfe7WZKSkchFPw2?= =?us-ascii?Q?y8EkO3IIU27j/zOWIzr+M6AnRMsQrsOPf/rMNgoSFhMZS/wkmxX7drjfN1pp?= =?us-ascii?Q?NPtsv0ppkXQ+KRHxgu7VBRmrSy88wwqtOvsxbEjaaC+Hr6JQmPiAxuWBWGIa?= =?us-ascii?Q?cmpYXwqkCX05Kah8tobjlL/xe1e1oawepbUQONmuSkGon0cF+fkFPQ9ltDYX?= =?us-ascii?Q?GVhFzxYDyNENs7IvTZYNvNEqbkViQ0UhcK/oZ2MsS9i0kAebW/GZuPBidbZ7?= =?us-ascii?Q?706pjxRweeB9U3+DIQepCUDsheh+A+Lj97EtKh4QaWYEaD31r2jN1qQTDtOv?= =?us-ascii?Q?lRgrO9ydxBhj1Xl5VFM/OA+mjbgPkf6989KMUzZltaMuUyFa28K9VAFC44UY?= =?us-ascii?Q?13V5r6CZtJty1PjEZFx83EkZfhlXQlP69c8gtGmqCbAgHKzFgZU+Vjxmh4D0?=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HSP1LuMYKmXAsqJ4Mc60ntAx9B?= =?us-ascii?Q?KlP/St4cuZutZOXXWNiZFcxt+61GrOPDFxz0mBc/wo/aiW5OHfDwgFlawNIy?= =?us-ascii?Q?qA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 8ae81b92-422a-4992-e16a-08dcfcca7be7 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2024 12:16:17.3795 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hyUshRXX7FZlI3qXeT/6uNmfj+khQJbOkVy/IqBxGf6vprol/j/OmTSqtubDnuEiMqL/712vjyS4wR3z1uGjGG0H5/D0p4iwVuvfhTOkNX4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR11MB8324 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Mon, Nov 04, 2024 at 10:31:12AM +0000, Soumyadeep Hore wrote: > In ICE PMD, previously the ready bitmap checking before reading > PHY timestamp was not present. This caused incorrect Tx > timestamping. > > The ready bitmap checking is enabled and PHY timestamp is read once > the ready bitmap gives positive value. > > Fixes: 881169950d80 ("net/ice/base: implement initial PTP support for E830") > Cc: stable@dpdk.org > > Signed-off-by: Soumyadeep Hore > --- > v3: > - Decreased the end time delay from 1 second to 10 microseconds > --- > v2: > - Addressed Bruce's comments > --- > drivers/net/ice/ice_ethdev.c | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c > index 70298ac330..3c768b6d0b 100644 > --- a/drivers/net/ice/ice_ethdev.c > +++ b/drivers/net/ice/ice_ethdev.c > @@ -6597,10 +6597,27 @@ ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev, > struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); > struct ice_adapter *ad = > ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); > - uint64_t ts_ns, tstamp; > + uint64_t ts_ns, tstamp, tstamp_ready = 0; > + uint64_t end_time; > const uint64_t mask = 0xFFFFFFFF; > int ret; > > + /* Set the end time with a delay of 10 microseconds */ > + end_time = rte_get_timer_cycles() + (rte_get_timer_hz() / 100000); > + > + while (!(tstamp_ready & BIT_ULL(0))) { Nit: in DPDK, we recommend using "== 0" explicitly for numeric comparisons. The "!" should only be used for boolean values, not ints. > + ret = ice_get_phy_tx_tstamp_ready(hw, ad->ptp_tx_block, &tstamp_ready); > + if (ret) { > + PMD_DRV_LOG(ERR, "Failed to get phy ready for timestamp"); > + return -1; > + } > + > + if (rte_get_timer_cycles() > end_time) { > + PMD_DRV_LOG(ERR, "Timeout to get phy ready for timestamp"); > + return -1; > + } Sorry for the last minute feedback here, but shouldn't these two conditions be the other way around? Right now, if you call ice_get_phy_tx_tstamp_ready just as the timer expires, and if the timestamp is actually ready this time, you will exit with error instead of handling the timestamp. Also, a very minor issue, but since you always want to go through the loop at least once, a do { } while(0) might be a better construct. It would avoid you having to initialize tstamp_ready to zero (not that it matters). do { if (rte_get_timer_cycles() > end_time) { /* log error and return */ } if (ice_get_phy_tx_tstamp_ready(...) != 0) { /* error log and return */ } } while((tstamp_ready & BIT_ULL(0)) == 0); > + } > + > ret = ice_read_phy_tstamp(hw, ad->ptp_tx_block, ad->ptp_tx_index, &tstamp); > if (ret || tstamp == 0) { > PMD_DRV_LOG(ERR, "Failed to read phy timestamp"); > -- Regards, /Bruce