From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from mx04lb.world4you.com (mx04lb.world4you.com [81.19.149.114])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43218170A0B
	for <netdev@vger.kernel.org>; Wed, 14 May 2025 20:57:58 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=81.19.149.114
ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1747256281; cv=none; b=j6Q7S6uI+ZnBwXCFm9PAy7CxDvla1ydysbYb3xXX/1jkLISD0KjPcfDfGpniUV6J8ykaciMDbRVIcKnq2IjOWpTFcCIZdgj2SvtJaUWMolQJE9o+PqVPXWQolSkIPaqZp6w9zdNvmrFP3RoHNhLska3FJZ01Os4DjhVUq7/2no4=
ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1747256281; c=relaxed/simple;
	bh=qLijJVgUZ/xYBQI+/bbJFwBfI82PebA03n7PfKODcRw=;
	h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=V68dLp94SvlI8eTknOPnTou21/0p3D4S7E3+v3z/lHSaDS0p540fH9xWH/HAamOqvEOb+WH+yAt0u/zzFSqFGkK8cDwPRSSLsqP/E6LqbqQ0+h9skAKVmxa5FHmcmIwXPHc6RLlZ8BkOpnYmnWGIGxWq73kfH8LzRuYbd7bc+xg=
ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=engleder-embedded.com; spf=pass smtp.mailfrom=engleder-embedded.com; dkim=pass (1024-bit key) header.d=engleder-embedded.com header.i=@engleder-embedded.com header.b=K1/UoWGM; arc=none smtp.client-ip=81.19.149.114
Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=engleder-embedded.com
Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=engleder-embedded.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=engleder-embedded.com header.i=@engleder-embedded.com header.b="K1/UoWGM"
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
	d=engleder-embedded.com; s=dkim11; h=Content-Transfer-Encoding:MIME-Version:
	Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:
	Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
	:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:
	List-Subscribe:List-Post:List-Owner:List-Archive;
	bh=bEI4T8ulLS9F7I+rTx5RO94AV42+GmGJFlL1uhv6f64=; b=K1/UoWGMY9JAe9j3cm2P311XZR
	DrtIB3Jr1J06ZaC1va9RDzHunRTf2ixDlWfW/y5EPf/kTmGzuf4zkzwLwAjuJyBHVTb5I1Rltg1Du
	orAIdpmdQZp3viOy40qA3YtW+pL38VtTG2iKL5VI3mbBj+2X2jt11zOKZckRcAZvdiwc=;
Received: from [188.22.4.212] (helo=hornet.engleder.at)
	by mx04lb.world4you.com with esmtpsa  (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
	(Exim 4.97.1)
	(envelope-from <gerhard@engleder-embedded.com>)
	id 1uFIDz-0000000062N-496w;
	Wed, 14 May 2025 21:57:08 +0200
From: Gerhard Engleder <gerhard@engleder-embedded.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net,
	kuba@kernel.org,
	edumazet@google.com,
	pabeni@redhat.com,
	andrew+netdev@lunn.ch,
	Gerhard Engleder <gerhard@engleder-embedded.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>
Subject: [PATCH net v2] tsnep: fix timestamping with a stacked DSA driver
Date: Wed, 14 May 2025 21:56:57 +0200
Message-Id: <20250514195657.25874-1-gerhard@engleder-embedded.com>
X-Mailer: git-send-email 2.39.5
Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
List-Id: <netdev.vger.kernel.org>
List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-AV-Do-Run: Yes
X-ACL-Warn: X-W4Y-Internal

This driver is susceptible to a form of the bug explained in commit
c26a2c2ddc01 ("gianfar: Fix TX timestamping with a stacked DSA driver")
and in Documentation/networking/timestamping.rst section "Other caveats
for MAC drivers", specifically it timestamps any skb which has
SKBTX_HW_TSTAMP, and does not consider if timestamping has been enabled
in adapter->hwtstamp_config.tx_type.

Evaluate the proper TX timestamping condition only once on the TX
path (in tsnep_xmit_frame_ring()) and store the result in an additional
TX entry flag. Evaluate the new TX entry flag in the TX confirmation path
(in tsnep_tx_poll()).

This way SKBTX_IN_PROGRESS is set by the driver as required, but never
evaluated. SKBTX_IN_PROGRESS shall not be evaluated as it can be set
by a stacked DSA driver and evaluating it would lead to unwanted
timestamps.

Fixes: 403f69bbdbad ("tsnep: Add TSN endpoint Ethernet MAC driver")
Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
---
v2:
- took over patch from Vladimir Oltean (thank you for your work, I hope
  the Suggested-by is ok for you, I was not sure about Co-developed-by)
- do TX timestamp check only in tsnep_xmit_frame_ring() and store result
  in TX entry flag
---
 drivers/net/ethernet/engleder/tsnep_main.c | 30 ++++++++++++++--------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/engleder/tsnep_main.c b/drivers/net/ethernet/engleder/tsnep_main.c
index 61a23413b577..48e08e550c57 100644
--- a/drivers/net/ethernet/engleder/tsnep_main.c
+++ b/drivers/net/ethernet/engleder/tsnep_main.c
@@ -74,6 +74,8 @@
 #define TSNEP_TX_TYPE_XDP_NDO_MAP_PAGE	(TSNEP_TX_TYPE_XDP_NDO | TSNEP_TX_TYPE_MAP_PAGE)
 #define TSNEP_TX_TYPE_XDP		(TSNEP_TX_TYPE_XDP_TX | TSNEP_TX_TYPE_XDP_NDO)
 #define TSNEP_TX_TYPE_XSK		BIT(12)
+#define TSNEP_TX_TYPE_TSTAMP		BIT(13)
+#define TSNEP_TX_TYPE_SKB_TSTAMP	(TSNEP_TX_TYPE_SKB | TSNEP_TX_TYPE_TSTAMP)
 
 #define TSNEP_XDP_TX		BIT(0)
 #define TSNEP_XDP_REDIRECT	BIT(1)
@@ -393,8 +395,7 @@ static void tsnep_tx_activate(struct tsnep_tx *tx, int index, int length,
 	if (entry->skb) {
 		entry->properties = length & TSNEP_DESC_LENGTH_MASK;
 		entry->properties |= TSNEP_DESC_INTERRUPT_FLAG;
-		if ((entry->type & TSNEP_TX_TYPE_SKB) &&
-		    (skb_shinfo(entry->skb)->tx_flags & SKBTX_IN_PROGRESS))
+		if ((entry->type & TSNEP_TX_TYPE_SKB_TSTAMP) == TSNEP_TX_TYPE_SKB_TSTAMP)
 			entry->properties |= TSNEP_DESC_EXTENDED_WRITEBACK_FLAG;
 
 		/* toggle user flag to prevent false acknowledge
@@ -486,7 +487,8 @@ static int tsnep_tx_map_frag(skb_frag_t *frag, struct tsnep_tx_entry *entry,
 	return mapped;
 }
 
-static int tsnep_tx_map(struct sk_buff *skb, struct tsnep_tx *tx, int count)
+static int tsnep_tx_map(struct sk_buff *skb, struct tsnep_tx *tx, int count,
+			bool do_tstamp)
 {
 	struct device *dmadev = tx->adapter->dmadev;
 	struct tsnep_tx_entry *entry;
@@ -512,6 +514,9 @@ static int tsnep_tx_map(struct sk_buff *skb, struct tsnep_tx *tx, int count)
 				entry->type = TSNEP_TX_TYPE_SKB_INLINE;
 				mapped = 0;
 			}
+
+			if (do_tstamp)
+				entry->type |= TSNEP_TX_TYPE_TSTAMP;
 		} else {
 			skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];
 
@@ -565,11 +570,12 @@ static int tsnep_tx_unmap(struct tsnep_tx *tx, int index, int count)
 static netdev_tx_t tsnep_xmit_frame_ring(struct sk_buff *skb,
 					 struct tsnep_tx *tx)
 {
-	int count = 1;
 	struct tsnep_tx_entry *entry;
+	bool do_tstamp = false;
+	int count = 1;
 	int length;
-	int i;
 	int retval;
+	int i;
 
 	if (skb_shinfo(skb)->nr_frags > 0)
 		count += skb_shinfo(skb)->nr_frags;
@@ -586,7 +592,13 @@ static netdev_tx_t tsnep_xmit_frame_ring(struct sk_buff *skb,
 	entry = &tx->entry[tx->write];
 	entry->skb = skb;
 
-	retval = tsnep_tx_map(skb, tx, count);
+	if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
+	    tx->adapter->hwtstamp_config.tx_type == HWTSTAMP_TX_ON) {
+		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
+		do_tstamp = true;
+	}
+
+	retval = tsnep_tx_map(skb, tx, count, do_tstamp);
 	if (retval < 0) {
 		tsnep_tx_unmap(tx, tx->write, count);
 		dev_kfree_skb_any(entry->skb);
@@ -598,9 +610,6 @@ static netdev_tx_t tsnep_xmit_frame_ring(struct sk_buff *skb,
 	}
 	length = retval;
 
-	if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)
-		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
-
 	for (i = 0; i < count; i++)
 		tsnep_tx_activate(tx, (tx->write + i) & TSNEP_RING_MASK, length,
 				  i == count - 1);
@@ -851,8 +860,7 @@ static bool tsnep_tx_poll(struct tsnep_tx *tx, int napi_budget)
 
 		length = tsnep_tx_unmap(tx, tx->read, count);
 
-		if ((entry->type & TSNEP_TX_TYPE_SKB) &&
-		    (skb_shinfo(entry->skb)->tx_flags & SKBTX_IN_PROGRESS) &&
+		if (((entry->type & TSNEP_TX_TYPE_SKB_TSTAMP) == TSNEP_TX_TYPE_SKB_TSTAMP) &&
 		    (__le32_to_cpu(entry->desc_wb->properties) &
 		     TSNEP_DESC_EXTENDED_WRITEBACK_FLAG)) {
 			struct skb_shared_hwtstamps hwtstamps;
-- 
2.39.5


From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from PA4PR04CU001.outbound.protection.outlook.com (mail-francecentralazon11013011.outbound.protection.outlook.com [40.107.162.11])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 059304B1E4F
	for <netdev@vger.kernel.org>; Thu, 15 May 2025 09:16:40 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.162.11
ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1747300603; cv=fail; b=Vp9+G4l7lNioLlJOJpoFkyt86Fs3DGOLiMNGKfmy7s+1pRxmOXy6V3Yc87k57EjE+Izbx+1//w7BaK7allCjpfhf43Fc5HhdodJ12Db+858tKzLPm0H8C8Ok/yltNVwihUV3FQV0cktgYaZTEjxDcVNgC/M4+sVOMBrHJwA8GQw=
ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1747300603; c=relaxed/simple;
	bh=75+GxHslSkbhajaZS6GFCoeVcKFpzaUZ+7/vaNKgK2w=;
	h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type:
	 Content-Disposition:In-Reply-To:MIME-Version; b=AnA0zrjxtUfDR+/fdJUfiEp2XqV+ljx4ROhItWblsGJTAJxL4CUIZXMED9upOS/bXLGSi5LiF7f8dlxb507fLJ4k+ViRVEZhUBed69LtyYrFM5rNAbt69bo7mkJmYb3wNReVTxiF8/dIZTSpRupE+0I9RiE5bLsf2NGCY0W5spc=
ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=IbievQmi; arc=fail smtp.client-ip=40.107.162.11
Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com
Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="IbievQmi"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=t3Ai0k2x3wE5SeIKzGp3FqDikve4AoCAUqKqA7fFIeVMTRR5499jAYCh1sS4obhO+S8wQG4I8oraXkXoTYj33ObgRHLTFmdpGdk++QtQ6uq4kh06K9LMM4R7qnRU+zTaoLTwV0C4WTTFwnesD/huyXESC4umtt/7ZW8iLK+Ia3u7ff3lGGIA3qeVF28GONU/68NFa29I9UKw6mmcATs5YyzzypCVSOCl4/6NzADaBYaMtWbPsVYWaaxwGSKLMv4xxpW1yM8pHaiLdgnOY7Etm5qakk6DCdYjE6YtplhBA9AbnorO6Pevf0XoUlqEzzXITbl6fkf+JR+NHy27I0v9Fg==
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=hxWmXkb/tth/n/zZ2kNdqOXLTgJWwmCFpjQYHu8ZWi4=;
 b=Hwzu8c0jzEeNjVr/VuWRGaaN0r99uiV29VN80nqPQb+uXal/9R44M+fLG8752q/ITNBfkJ2LXlvVT/8lh8/sHZlg0ZmDzthoC+CNiChpScn2XY90t/foduq3Y4j8kYbCTB/SafAdb9hbhPnVuVtJaMGizisAb/qbTtTaBlTZuP58KVp5c67oya9K6zrvp3vmlrWar0In8thZT7Z2yUC1kgGbT0z8AjSfw5/jroW3gLFXKEK39uCjAvkc63yiqgBUhDcw8ks6v5nQT5132xdvxON3aIZjXH3uOdewQkNEI9Bz2neB5g3+wmaWsQVQ7XnsvaIkHWic/r0o9uJiDGsWPg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass
 header.d=nxp.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=hxWmXkb/tth/n/zZ2kNdqOXLTgJWwmCFpjQYHu8ZWi4=;
 b=IbievQmilxqylyNwEV+2jjEEpVZS/D3q/1D/LU+nILC/I55hzJ+QCNQoY4h/2/O/N5bC4Qbb8ZOggdI/fTdX+MOrlIl3O+mq+ud5cSs+ccZm024HJ66swS/4EVJ2mdm8zFd2u+oxtVb9x8xZh6fPyk49yBd+mCR7qGo/bprhVRD3/JFy+lzH0BPNM6t4P9BxbKqerlQbRBvevJEoBn9vRU6Djf/TXaiwOZ4ghLTHeylPIjTsGWLfbYrXyaYhZaNxz0vdvPVLDUhwdqZFcZ1VQSyHZVt/2wpZC3iM+9vhDJiNwbnYAGEwxv6EI1N3HDe6fOaLcDwjmIKRKFUUkpa7tw==
Authentication-Results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=nxp.com;
Received: from AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14)
 by GVXPR04MB10490.eurprd04.prod.outlook.com (2603:10a6:150:1e2::9) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.32; Thu, 15 May
 2025 09:16:38 +0000
Received: from AM8PR04MB7779.eurprd04.prod.outlook.com
 ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com
 ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.8722.027; Thu, 15 May 2025
 09:16:38 +0000
Date: Thu, 15 May 2025 12:16:35 +0300
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Gerhard Engleder <gerhard@engleder-embedded.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch
Subject: Re: [PATCH net v2] tsnep: fix timestamping with a stacked DSA driver
Message-ID: <20250515091635.gevpm33zszsbfpxu@skbuf>
References: <20250514195657.25874-1-gerhard@engleder-embedded.com>
 <20250514195657.25874-1-gerhard@engleder-embedded.com>
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20250514195657.25874-1-gerhard@engleder-embedded.com>
 <20250514195657.25874-1-gerhard@engleder-embedded.com>
X-ClientProxiedBy: BE1P281CA0458.DEUP281.PROD.OUTLOOK.COM
 (2603:10a6:b10:7f::6) To AM8PR04MB7779.eurprd04.prod.outlook.com
 (2603:10a6:20b:24b::14)
Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
List-Id: <netdev.vger.kernel.org>
List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: AM8PR04MB7779:EE_|GVXPR04MB10490:EE_
X-MS-Office365-Filtering-Correlation-Id: aad88312-a041-470d-4399-08dd93913233
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|7053199007;
X-Microsoft-Antispam-Message-Info:
	=?us-ascii?Q?N7XNU/sqRXOel2vYxhPZ3p0UAOyeT5wsxYzuZO/GFew7CLzesE/4DnS63y48?=
 =?us-ascii?Q?sYGAVn5J+Sl5ekIcMo63XIVIok0+Bjbj3mKPffi60/8cccoSBCTY8IXh6FN+?=
 =?us-ascii?Q?TG9FljsTADGyodo3EXtKLogTIOtK4dfqsmRG8OxqxNIHVqNuZamLWALknbLL?=
 =?us-ascii?Q?ZFl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1fFQGEyke1E31bRL4B8uwbQwLjC5+oImVUq5x+TkF?=
 =?us-ascii?Q?TSeYCt+Px9sE2VaW7GTAmwrcaGj+fJW38u41DQI5geYdYCsxGiPV7N6dxbah?=
 =?us-ascii?Q?rhQq485HJKjMg1QEzm6v/fMIziYm3DtVPv4nmJWZk79BsGvSEeNe0aiDfQ6g?=
 =?us-ascii?Q?LTfutFku5xJvXVxJhThOOg0sE+6eXMPl1Ivj0QYJ4l6Z99Ng8hYY94J9KcY1?=
 =?us-ascii?Q?d1a+3aWRgH7kQROlWy5WyX/RoXTZi/vytYdmrA6OIaiLqTbQ1i431WWjS7Jg?=
 =?us-ascii?Q?t/o8y9o0g//650q+KPKQ6aNnKL/Mb6YpT8YNHNS4XG/eYjBJCQCd1NCRQeQG?=
 =?us-ascii?Q?44UAZJ2zMzz62tE0ETZ0phpjOXeVzsx63ylpu99FmJlfs6aCnJ7X+Wxaikbk?=
 =?us-ascii?Q?JBGAKUMs0ms=3D?=
X-Forefront-Antispam-Report:
	CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016)(7053199007);DIR:OUT;SFP:1101;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0:
	=?us-ascii?Q?pREmOHl/LJ+CpFcu7k49hMwiQFmucS1/gO8tUBQ4FyfwYrZFwtbg/mh1pIG3?=
 =?us-ascii?Q?oGI7CYI0eDetcXXJ3eJ8N5Mk8iz/kvyOeruP5NNYruV71dv5Xr2pFna7q0l4?=
 =?us-ascii?Q?HuI1NU7Hhm49lfoTHhvTzaRijxFaXHD+58xG2Ei+UtMXloAdAoxT745bVY+V?=
 =?us-ascii?Q?yy6+jPwwz0/ZDpD7wlT4ekc3svm7KTAtKNIlOxKfzaSvArny37BKfTkkfvj+?=
 =?us-ascii?Q?Pr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mq/kDifVYjaeHudExAS6xQPTAUB/zqK6j6qprOYskpKdDYEPH4hR7b?=
 =?us-ascii?Q?S2mrE6QyCxrGjqEeg5wXHR1gcgkU6wjCUTbgHjXCU2HgApHdEXk+0YD+ND2Z?=
 =?us-ascii?Q?klb4mx9kRIp7uOi+o14uVeCr93/fYOAGpL9mJR4dT022Gm21YskRl2nsR8nN?=
 =?us-ascii?Q?J80+vcqTz/jLLOKIzpy7rN8sCtAdRkM1QqnEZ1mRp9M1ckrnKJHSoGnl2C06?=
 =?us-ascii?Q?nVYdTeiPi/tMGJBU2rLaSHLWt8+Rn0jW2nSCFHCVokyDyy+92lRPAO+BIpXI?=
 =?us-ascii?Q?zBMVfNVP9W1bfkfuwjGoP2pzXwRlpEdNjitKDI2PVuT8OprtbbZxz6+sftC5?=
 =?us-ascii?Q?eE8NffFbAP/rOy4Oteo9yWbsKO5e92EKYL+1JXRPZafvkbZ1X7R7yIfYTCvO?=
 =?us-ascii?Q?hp0FWPohi1uB4w/C0e0XTNqeBfgOmFY7hBmb/me9DVKS8BZGYJmTn7Fd9UJT?=
 =?us-ascii?Q?OjON3SLKO+WHY93inTSf5VBxT3WNbg+GD15t4D1tJWIDaiEN76rfgA29vIsk?=
 =?us-ascii?Q?AA=3D=3D?=
X-OriginatorOrg: nxp.com
X-MS-Exchange-CrossTenant-Network-Message-Id: aad88312-a041-470d-4399-08dd93913233
X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 09:16:38.0519
 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: Td87/Ni7OX7x21GMk22N71ExoI2+TD02iz0J3iYB0geshttl3XMeLrCNBKWppmCgaB9JStlO/TflmkzT74L5yA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB10490

On Wed, May 14, 2025 at 09:56:57PM +0200, Gerhard Engleder wrote:
> This driver is susceptible to a form of the bug explained in commit
> c26a2c2ddc01 ("gianfar: Fix TX timestamping with a stacked DSA driver")
> and in Documentation/networking/timestamping.rst section "Other caveats
> for MAC drivers", specifically it timestamps any skb which has
> SKBTX_HW_TSTAMP, and does not consider if timestamping has been enabled
> in adapter->hwtstamp_config.tx_type.
> 
> Evaluate the proper TX timestamping condition only once on the TX
> path (in tsnep_xmit_frame_ring()) and store the result in an additional
> TX entry flag. Evaluate the new TX entry flag in the TX confirmation path
> (in tsnep_tx_poll()).
> 
> This way SKBTX_IN_PROGRESS is set by the driver as required, but never
> evaluated. SKBTX_IN_PROGRESS shall not be evaluated as it can be set
> by a stacked DSA driver and evaluating it would lead to unwanted
> timestamps.
> 
> Fixes: 403f69bbdbad ("tsnep: Add TSN endpoint Ethernet MAC driver")
> Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
> ---
> v2:
> - took over patch from Vladimir Oltean (thank you for your work, I hope
>   the Suggested-by is ok for you, I was not sure about Co-developed-by)
> - do TX timestamp check only in tsnep_xmit_frame_ring() and store result
>   in TX entry flag
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3DBBA42A82
	for <netdev@vger.kernel.org>; Thu, 15 May 2025 15:09:55 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201
ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1747321796; cv=none; b=nkUle5GxEKgec5NipKSSkQHMvXIzOwkT6gAiNb0Z7E1B+7JzW80TXbuNNtlVNOlBEooaXhiEg2haS3W7Q033UWEHCYcysTAM6Q7tMap3ONXIvNtV3bwoQ6AvNXK0E7wjRYQx6MPz1GJ/qe9U4OCauIXMad69Je4zBYqg2mgH1pk=
ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1747321796; c=relaxed/simple;
	bh=t883VBpicwCSdqSdAesit+/6+Jz9s+OLDldkgvqbjp8=;
	h=Content-Type:MIME-Version:Subject:From:Message-Id:Date:References:
	 In-Reply-To:To:Cc; b=uDx4I2URVwl39ISLpHQODnvDLLHLDHkgofI1zeLmSVG61xBgFeyGq2o2AF1KRNGfvmKa/hAWcElEqi69IGPu22F2kU9uB1068hENYFiEt0/TEXObMO8fzeJroRIE3GMiXvW+B5Yo7gZEKtv2y64yiaHPiS8F7X49AUA7o3VJ23k=
ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pH1yhpfb; arc=none smtp.client-ip=10.30.226.201
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pH1yhpfb"
Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0105C4CEE7;
	Thu, 15 May 2025 15:09:54 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;
	s=k20201202; t=1747321795;
	bh=t883VBpicwCSdqSdAesit+/6+Jz9s+OLDldkgvqbjp8=;
	h=Subject:From:Date:References:In-Reply-To:To:Cc:From;
	b=pH1yhpfbN9k69Z3zPAbdLKQFnj6hQs6kk9snF+DtzCPMsYZUPVqmRt6rlFXLGrmxp
	 Vjp2GKVKT7ffFRbdEghqc9bHMXPzy1ieM+QL/4nhXbLg4nylBoHpvPAOELnt23grZH
	 F/mWX4lasn8+SsaNaUvBKK8PxHwkMWDtFQQRl5VtBSLOw2kxI/xxTFiTEGtodNoT6o
	 WLeoQgOtNx7Ex1HxkiurDGUVmMWEaH/Bw+xwuy8nWQqaImJM3j1pas/aUPLJC7G+hq
	 rupQb20Kt3XRd6ZSgVV7PPW9rIFAxHULYaiUWW5d2D2LfQZw8PBTNuBSMcdcI0HiGD
	 loZN2kyUcRD9A==
Received: from [10.30.226.235] (localhost [IPv6:::1])
	by aws-us-west-2-korg-oddjob-rhel9-1.codeaurora.org (Postfix) with ESMTP id EB0A63806659;
	Thu, 15 May 2025 15:10:32 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
List-Id: <netdev.vger.kernel.org>
List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: Re: [PATCH net v2] tsnep: fix timestamping with a stacked DSA driver
From: patchwork-bot+netdevbpf@kernel.org
Message-Id: 
 <174732183151.3142925.5290378453132436424.git-patchwork-notify@kernel.org>
Date: Thu, 15 May 2025 15:10:31 +0000
References: <20250514195657.25874-1-gerhard@engleder-embedded.com>
In-Reply-To: <20250514195657.25874-1-gerhard@engleder-embedded.com>
To: Gerhard Engleder <gerhard@engleder-embedded.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
 edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch,
 vladimir.oltean@nxp.com

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 14 May 2025 21:56:57 +0200 you wrote:
> This driver is susceptible to a form of the bug explained in commit
> c26a2c2ddc01 ("gianfar: Fix TX timestamping with a stacked DSA driver")
> and in Documentation/networking/timestamping.rst section "Other caveats
> for MAC drivers", specifically it timestamps any skb which has
> SKBTX_HW_TSTAMP, and does not consider if timestamping has been enabled
> in adapter->hwtstamp_config.tx_type.
> 
> [...]

Here is the summary with links:
  - [net,v2] tsnep: fix timestamping with a stacked DSA driver
    https://git.kernel.org/netdev/net/c/b3ca9eef6646

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



