2024-04-03 21:38:47

by Rahul Rameshbabu

[permalink] [raw]
Subject: [PATCH net-next v2 0/6] ethtool HW timestamping statistics

The goal of this patch series is to introduce a common set of ethtool statistics
for hardware timestamping that a driver implementer can hook into. The
statistics counters added are based on what I believe are common
patterns/behaviors found across various hardware timestamping implementations
seen in the kernel tree today. The mlx5 family of devices is used as the PoC for
this patch series. Other vendors are more than welcome to chime in on this
series.

Changes since RFC v1:
- Dropped the late statistics counter since that was not general enough
- Dropped the layer selection attribute for timestamping statistics
- Take Jakub's suggestion and converted to ETHTOOL_FLAG_STATS
- Provided a working interface to query these new statistics from
tools/net/ynl/ethtool.py

Changes since RFC v2:
- Applied suggestion by Jakub for implementing an enumeration for
ethtool header flags

Changes since v1:
- Fixed scripts/kernel-doc warning in include/linux/ethtool.h

Link: https://lore.kernel.org/netdev/[email protected]/
Link: https://lore.kernel.org/netdev/[email protected]/
Link: https://lore.kernel.org/netdev/[email protected]/
Signed-off-by: Rahul Rameshbabu <[email protected]>
---
Rahul Rameshbabu (6):
ethtool: add interface to read Tx hardware timestamping statistics
net/mlx5e: Introduce lost_cqe statistic counter for PTP Tx port
timestamping CQ
net/mlx5e: Introduce timestamps statistic counter for Tx DMA layer
net/mlx5e: Implement ethtool hardware timestamping statistics
netlink: specs: ethtool: add header-flags enumeration
tools: ynl: ethtool.py: Output timestamping statistics from tsinfo-get
operation

Documentation/netlink/specs/ethtool.yaml | 22 ++++++++
.../ethernet/mellanox/mlx5/counters.rst | 11 ++++
Documentation/networking/ethtool-netlink.rst | 9 ++++
.../net/ethernet/mellanox/mlx5/core/en/ptp.c | 1 +
.../ethernet/mellanox/mlx5/core/en_ethtool.c | 9 ++++
.../ethernet/mellanox/mlx5/core/en_stats.c | 48 +++++++++++++++++
.../ethernet/mellanox/mlx5/core/en_stats.h | 4 ++
.../net/ethernet/mellanox/mlx5/core/en_tx.c | 6 ++-
include/linux/ethtool.h | 27 +++++++++-
include/uapi/linux/ethtool_netlink.h | 25 ++++++---
net/ethtool/tsinfo.c | 52 ++++++++++++++++++-
tools/net/ynl/ethtool.py | 11 +++-
12 files changed, 214 insertions(+), 11 deletions(-)

--
2.42.0



2024-04-03 21:41:57

by Rahul Rameshbabu

[permalink] [raw]
Subject: [PATCH net-next v2 4/6] net/mlx5e: Implement ethtool hardware timestamping statistics

Feed driver statistics counters related to hardware timestamping to
standardized ethtool hardware timestamping statistics group.

Signed-off-by: Rahul Rameshbabu <[email protected]>
Reviewed-by: Dragos Tatulea <[email protected]>
---
.../ethernet/mellanox/mlx5/core/en_ethtool.c | 9 ++++
.../ethernet/mellanox/mlx5/core/en_stats.c | 45 +++++++++++++++++++
.../ethernet/mellanox/mlx5/core/en_stats.h | 2 +
3 files changed, 56 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index cc51ce16df14..d3b77054c30a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -2381,6 +2381,14 @@ static void mlx5e_get_rmon_stats(struct net_device *netdev,
mlx5e_stats_rmon_get(priv, rmon_stats, ranges);
}

+static void mlx5e_get_ts_stats(struct net_device *netdev,
+ struct ethtool_ts_stats *ts_stats)
+{
+ struct mlx5e_priv *priv = netdev_priv(netdev);
+
+ mlx5e_stats_ts_get(priv, ts_stats);
+}
+
const struct ethtool_ops mlx5e_ethtool_ops = {
.cap_rss_ctx_supported = true,
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
@@ -2430,5 +2438,6 @@ const struct ethtool_ops mlx5e_ethtool_ops = {
.get_eth_mac_stats = mlx5e_get_eth_mac_stats,
.get_eth_ctrl_stats = mlx5e_get_eth_ctrl_stats,
.get_rmon_stats = mlx5e_get_rmon_stats,
+ .get_ts_stats = mlx5e_get_ts_stats,
.get_link_ext_stats = mlx5e_get_link_ext_stats
};
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
index a06c6c80e36f..d8cf1fe99fb0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
@@ -1172,6 +1172,51 @@ void mlx5e_stats_rmon_get(struct mlx5e_priv *priv,
*ranges = mlx5e_rmon_ranges;
}

+void mlx5e_stats_ts_get(struct mlx5e_priv *priv,
+ struct ethtool_ts_stats *ts_stats)
+{
+ int i, j;
+
+ mutex_lock(&priv->state_lock);
+
+ if (priv->tx_ptp_opened) {
+ struct mlx5e_ptp *ptp = priv->channels.ptp;
+
+ ts_stats->pkts = 0;
+ ts_stats->err = 0;
+ ts_stats->lost = 0;
+
+ /* Aggregate stats across all TCs */
+ for (i = 0; i < ptp->num_tc; i++) {
+ struct mlx5e_ptp_cq_stats *stats =
+ ptp->ptpsq[i].cq_stats;
+
+ ts_stats->pkts += stats->cqe;
+ ts_stats->err += stats->abort + stats->err_cqe +
+ stats->late_cqe;
+ ts_stats->lost += stats->lost_cqe;
+ }
+ } else {
+ /* DMA layer will always successfully timestamp packets. Other
+ * counters do not make sense for this layer.
+ */
+ ts_stats->pkts = 0;
+
+ /* Aggregate stats across all SQs */
+ for (j = 0; j < priv->channels.num; j++) {
+ struct mlx5e_channel *c = priv->channels.c[j];
+
+ for (i = 0; i < c->num_tc; i++) {
+ struct mlx5e_sq_stats *stats = c->sq[i].stats;
+
+ ts_stats->pkts += stats->timestamps;
+ }
+ }
+ }
+
+ mutex_unlock(&priv->state_lock);
+}
+
#define PPORT_PHY_STATISTICAL_OFF(c) \
MLX5_BYTE_OFF(ppcnt_reg, \
counter_set.phys_layer_statistical_cntrs.c##_high)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index 3c634c5fd420..7b3e6cf1229a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -126,6 +126,8 @@ void mlx5e_stats_eth_ctrl_get(struct mlx5e_priv *priv,
void mlx5e_stats_rmon_get(struct mlx5e_priv *priv,
struct ethtool_rmon_stats *rmon,
const struct ethtool_rmon_hist_range **ranges);
+void mlx5e_stats_ts_get(struct mlx5e_priv *priv,
+ struct ethtool_ts_stats *ts_stats);
void mlx5e_get_link_ext_stats(struct net_device *dev,
struct ethtool_link_ext_stats *stats);

--
2.42.0


2024-04-06 06:11:25

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net-next v2 0/6] ethtool HW timestamping statistics

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <[email protected]>:

On Wed, 3 Apr 2024 14:28:38 -0700 you wrote:
> The goal of this patch series is to introduce a common set of ethtool statistics
> for hardware timestamping that a driver implementer can hook into. The
> statistics counters added are based on what I believe are common
> patterns/behaviors found across various hardware timestamping implementations
> seen in the kernel tree today. The mlx5 family of devices is used as the PoC for
> this patch series. Other vendors are more than welcome to chime in on this
> series.
>
> [...]

Here is the summary with links:
- [net-next,v2,1/6] ethtool: add interface to read Tx hardware timestamping statistics
https://git.kernel.org/netdev/net-next/c/0e9c127729be
- [net-next,v2,2/6] net/mlx5e: Introduce lost_cqe statistic counter for PTP Tx port timestamping CQ
https://git.kernel.org/netdev/net-next/c/adda54018078
- [net-next,v2,3/6] net/mlx5e: Introduce timestamps statistic counter for Tx DMA layer
https://git.kernel.org/netdev/net-next/c/cd429012f078
- [net-next,v2,4/6] net/mlx5e: Implement ethtool hardware timestamping statistics
https://git.kernel.org/netdev/net-next/c/3579032c08c1
- [net-next,v2,5/6] netlink: specs: ethtool: add header-flags enumeration
https://git.kernel.org/netdev/net-next/c/ff8877b04ef2
- [net-next,v2,6/6] tools: ynl: ethtool.py: Output timestamping statistics from tsinfo-get operation
https://git.kernel.org/netdev/net-next/c/2e0e148c7270

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