Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1203773rbb; Mon, 26 Feb 2024 01:57:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWPaz6w1JD3QLx6A/vLhfZQ7ikl6AC69Gl9kn7+oMSKNbNhOqsvOEsglo6pKx38xwVD4d2qy3wq9sDeMzBYcQv2mFALodTjo60a0vCtMw== X-Google-Smtp-Source: AGHT+IE2+1uoUUfWFYjseygyURg2JTPxyAv5AXpo8wd06QGO7oa/BgW7Es2HrQsBoZo8VB7eV5ak X-Received: by 2002:aa7:d608:0:b0:564:65c5:f048 with SMTP id c8-20020aa7d608000000b0056465c5f048mr4009658edr.28.1708941420679; Mon, 26 Feb 2024 01:57:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708941420; cv=pass; d=google.com; s=arc-20160816; b=i6Igmqg9VyOaphWM147oJ5mtPuUQv/ORHNevOTPa8dEXPK5UQK/+ufoH0Ks04dGOBS ZA2YkYWd91QCbqF0b65b0s46qC5KePeqGuxjVRnhqOLNjW1DlbUvo+/lrQJv9CCFRgW/ axD5FEl37gg0AiQYOZaHNRUvRD8MSHhSpgPApYIbQASNTkPwW9WiTrEjWg5wDkf5vrDe STB7JI/6OfeXrhcq/WPDGUI4F3kt74CKLF2r55OoC3teKLpsi0PhR4akhxJLq7fLh2QE WyQ1uJigrqWugLc7zmnA6N8cjolGavJG8tfiS1634t56mp28yPXd99Jsxl3lR1d/T8Jm YMcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=dJ/TScN96xow2EgjcWkCcR2wGSrDb70yHEKhAIhIqck=; fh=vLQ2QekPF58X9gXufavtU8TE+6hH60IMSGetL2aceqw=; b=jztGedzcESdTm+MZEqwei/5dI8+bIDSxnX5tMU3hTE7KO/TGRAeNhslSTuwQwhv51k FXXKhlUl56hxH1r+s1qYeJYjU9qSgYkhfNfW8CRFIF7PfyIEFgA29jflWSOeHZ6YuyJ8 rB8fF1qs6FAtS1eUx2qukqwJj6Xr/ucArwRNgT1R3Fra2P994K0DA8xAYUbgfQgHvUF2 Eolwyvas2xVIW+9b1M1wa8Z0Li31SqN+zrOjbtwYwZFZ+H1Nuka4uRSP2ohY3h2Yb0si AxVi+bAkQYOslnd6ikL9owygeBrXOtAVowdNUDi13uxMy3zxm9kO6qwMcsHQE3BneVkz lh4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jeLtCvF5; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-81048-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81048-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x94-20020a50bae7000000b00563c2e73cfesi2021885ede.150.2024.02.26.01.57.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:57:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81048-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jeLtCvF5; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-81048-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81048-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 338AD1F240A6 for ; Mon, 26 Feb 2024 09:57:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0677354BD5; Mon, 26 Feb 2024 09:26:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="jeLtCvF5" Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 0AACC335C0; Mon, 26 Feb 2024 09:26:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708939585; cv=none; b=sDCsLmR+slg1v5aa8Q1veoQXhOuNxqYjx+ilkWSPrMq6FDf8gTRh3f4DyreMt4Pbi6wBeE4Qc1B/ormaYY172p5RQjP0obfJvRuGQjttmrvQmVKye+4AvK0q4+nI7Cuh9VQJOHXo4Ms66VSq49Jtw2PlENrohEUPFlCOq6itP8Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708939585; c=relaxed/simple; bh=XwLxxp8u8DvmEjdgtmzsdNA/nMFyAao9iyW50HyGSqc=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F4kXQOgek7s9f0jaL9cJb6lNWOP8wRkZeHkSXoIdysLwOvvx+kVERxi0J69/CAAz/WyRS848fNBI3zqpxYbcSutZDumf6oFW/bJm5vwQUADYU6sOFfQiAo1U9lZsJqnmz0/FdN44ExwhdBzh91UCVPJj9YVmCkRjXyFDcSuXXUU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=jeLtCvF5; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 8654920007; Mon, 26 Feb 2024 09:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708939574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dJ/TScN96xow2EgjcWkCcR2wGSrDb70yHEKhAIhIqck=; b=jeLtCvF51DIye3jd9TDzyVizqTWW0ZkjrTr6zB6ApmN3dCkSvOaMv1ITwAKf8eG/rXsQ7b O2XzGbGiBzFsf7rXcq6WEhPQLZIoEpmR0EEXImxcuSixWK1OE7ZPQ33JDy1RfLTFoli/ZY y9b9UvjEw6QfZ20HsI3BbfCFP+v7uOlRtg3MN3H/K0WN2blm86CKEzOIw3NhIU0n6j0WJC http5/7pXhfjw3qlWgVIzdrLL69waGkW2hnybaReMfji+i46OI+2YTM46LRInjSNgpCpAd o3yTHnLaT8x4TKNzgHoLN0bomHuraPzXRS/N7VDTcoMfBZHiy1DVJWzfpFjuGA== Date: Mon, 26 Feb 2024 10:26:08 +0100 From: =?UTF-8?B?S8O2cnk=?= Maincent To: Rahul Rameshbabu Cc: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Richard Cochran , Tariq Toukan , Gal Pressman , Vadim Fedorenko , Andrew Lunn , Heiner Kallweit , Przemek Kitszel , Ahmed Zaki , Alexander Lobakin , Hangbin Liu , Paul Greenwalt , Justin Stitt , Randy Dunlap , Maxime Chevallier , Wojciech Drewek , Vladimir Oltean , Jiri Pirko , Jacob Keller , Alexandre Torgue , Jose Abreu , Dragos Tatulea , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH RFC net-next v1 4/6] net/mlx5e: Implement ethtool hardware timestamping statistics Message-ID: <20240226102608.135cb11c@kmaincent-XPS-13-7390> In-Reply-To: <20240223192658.45893-5-rrameshbabu@nvidia.com> References: <20240223192658.45893-1-rrameshbabu@nvidia.com> <20240223192658.45893-5-rrameshbabu@nvidia.com> Organization: bootlin X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: kory.maincent@bootlin.com On Fri, 23 Feb 2024 11:24:48 -0800 Rahul Rameshbabu wrote: > Feed driver statistics counters related to hardware timestamping to > standardized ethtool hardware timestamping statistics group. >=20 > Signed-off-by: Rahul Rameshbabu > Reviewed-by: Dragos Tatulea > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c > b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c index > bc31196d348a..836198445726 100644 --- > a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +++ > b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c @@ -1155,6 +1155,74 = @@ > void mlx5e_stats_rmon_get(struct mlx5e_priv *priv, *ranges =3D > mlx5e_rmon_ranges; } > =20 > +void mlx5e_stats_ts_get(struct mlx5e_priv *priv, > + struct ethtool_ts_stats *ts_stats) > +{ > + enum ethtool_ts_stats_layer layer; > + struct mlx5e_ptp *ptp; > + bool tx_ptp_opened; > + int i, j; > + > + mutex_lock(&priv->state_lock); > + > + tx_ptp_opened =3D priv->tx_ptp_opened; > + > + /* NOTE: this needs to be changed whenever ethtool timestamping > + * layer selection is implemented. > + */ > + if (ts_stats->layer =3D=3D ETHTOOL_TS_STATS_LAYER_ACTIVE) > + layer =3D tx_ptp_opened ? ETHTOOL_TS_STATS_LAYER_PHY : > + ETHTOOL_TS_STATS_LAYER_DMA; > + else > + layer =3D ts_stats->layer; > + > + switch (layer) { > + case ETHTOOL_TS_STATS_LAYER_PHY: > + if (!tx_ptp_opened) > + return; > + > + ptp =3D priv->channels.ptp; > + > + ts_stats->pkts =3D 0; > + ts_stats->err =3D 0; > + ts_stats->late =3D 0; > + ts_stats->lost =3D 0; > + > + /* Aggregate stats across all TCs */ > + for (i =3D 0; i < ptp->num_tc; i++) { > + struct mlx5e_ptp_cq_stats *stats =3D > ptp->ptpsq[i].cq_stats; + > + ts_stats->pkts +=3D stats->cqe; > + ts_stats->err +=3D stats->abort + stats->err_cqe; > + ts_stats->late +=3D stats->late_cqe; > + ts_stats->lost +=3D stats->lost_cqe; > + } > + break; > + case ETHTOOL_TS_STATS_LAYER_DMA: > + /* DMA layer will always successfully timestamp packets. > Other > + * counters do not make sense for this layer. > + */ > + ts_stats->pkts =3D 0; > + > + /* Aggregate stats across all SQs */ > + mutex_lock(&priv->state_lock); > + for (j =3D 0; j < priv->channels.num; j++) { > + struct mlx5e_channel *c =3D priv->channels.c[j]; > + > + for (i =3D 0; i < c->num_tc; i++) { > + struct mlx5e_sq_stats *stats =3D > c->sq[i].stats; + > + ts_stats->pkts +=3D stats->timestamps; > + } > + } > + break; > + default: > + break; > + } > + > + mutex_unlock(&priv->state_lock); > +} > + To follow the same logic as my patch series you should use phc qualifier in= stead of the layer. See patch 9 of my series. With HWTSTAMP_PROVIDER_QUALIFIER_PRECISE for the IEEE 1588 which mean the P= HY layer on your case and HWTSTAMP_PROVIDER_QUALIFIER_APPROX for the DMA layer. Even if the timestamp is made physically on the PHY, this driver does not register any phy device. The NIC manages all the network architecture by itself. We decided to use the phc qualifier to fit this use case. The layer description should only be used internally in the kernel when we = are registering a PHY device and using the phy tsinfo/hwtstamp/rxtstamp/tstsamp callbacks. Regards, --=20 K=C3=B6ry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com