History

net/mlx5e: Implement ethtool hardware timestamping statistics

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

Rahul Rameshbabu committed 2 years ago

Commit 35790321 parent cd429013 files · +56 −0Browse files

Unified · Split

3 files
  1. drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +9 −0
  2. drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +45 −0
  3. drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +2 −0
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c+9−0
@@ -2387,6 +2387,14 @@ static void mlx5e_get_rmon_stats(struct net_device *netdev, · 2386 unmodified lines
23872387 mlx5e_stats_rmon_get(priv, rmon_stats, ranges);
23882388 }
23892389
2390+static void mlx5e_get_ts_stats(struct net_device *netdev,
2391+ struct ethtool_ts_stats *ts_stats)
2392+{
2393+ struct mlx5e_priv *priv = netdev_priv(netdev);
2394+
2395+ mlx5e_stats_ts_get(priv, ts_stats);
2396+}
2397+
23902398 const struct ethtool_ops mlx5e_ethtool_ops = {
23912399 .cap_rss_ctx_supported = true,
23922400 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
@@ -2436,5 +2444,6 @@ const struct ethtool_ops mlx5e_ethtool_ops = { · 43 unmodified lines
24362444 .get_eth_mac_stats = mlx5e_get_eth_mac_stats,
24372445 .get_eth_ctrl_stats = mlx5e_get_eth_ctrl_stats,
24382446 .get_rmon_stats = mlx5e_get_rmon_stats,
2447+ .get_ts_stats = mlx5e_get_ts_stats,
24392448 .get_link_ext_stats = mlx5e_get_link_ext_stats
24402449 };
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c+45−0
@@ -1172,6 +1172,51 @@ void mlx5e_stats_rmon_get(struct mlx5e_priv *priv, · 1171 unmodified lines
11721172 *ranges = mlx5e_rmon_ranges;
11731173 }
11741174
1175+void mlx5e_stats_ts_get(struct mlx5e_priv *priv,
1176+ struct ethtool_ts_stats *ts_stats)
1177+{
1178+ int i, j;
1179+
1180+ mutex_lock(&priv->state_lock);
1181+
1182+ if (priv->tx_ptp_opened) {
1183+ struct mlx5e_ptp *ptp = priv->channels.ptp;
1184+
1185+ ts_stats->pkts = 0;
1186+ ts_stats->err = 0;
1187+ ts_stats->lost = 0;
1188+
1189+ /* Aggregate stats across all TCs */
1190+ for (i = 0; i < ptp->num_tc; i++) {
1191+ struct mlx5e_ptp_cq_stats *stats =
1192+ ptp->ptpsq[i].cq_stats;
1193+
1194+ ts_stats->pkts += stats->cqe;
1195+ ts_stats->err += stats->abort + stats->err_cqe +
1196+ stats->late_cqe;
1197+ ts_stats->lost += stats->lost_cqe;
1198+ }
1199+ } else {
1200+ /* DMA layer will always successfully timestamp packets. Other
1201+ * counters do not make sense for this layer.
1202+ */
1203+ ts_stats->pkts = 0;
1204+
1205+ /* Aggregate stats across all SQs */
1206+ for (j = 0; j < priv->channels.num; j++) {
1207+ struct mlx5e_channel *c = priv->channels.c[j];
1208+
1209+ for (i = 0; i < c->num_tc; i++) {
1210+ struct mlx5e_sq_stats *stats = c->sq[i].stats;
1211+
1212+ ts_stats->pkts += stats->timestamps;
1213+ }
1214+ }
1215+ }
1216+
1217+ mutex_unlock(&priv->state_lock);
1218+}
1219+
11751220 #define PPORT_PHY_STATISTICAL_OFF(c) \
11761221 MLX5_BYTE_OFF(ppcnt_reg, \
11771222 counter_set.phys_layer_statistical_cntrs.c##_high)
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h+2−0
@@ -128,6 +128,8 @@ void mlx5e_stats_eth_ctrl_get(struct mlx5e_priv *priv, · 127 unmodified lines
128128 void mlx5e_stats_rmon_get(struct mlx5e_priv *priv,
129129 struct ethtool_rmon_stats *rmon,
130130 const struct ethtool_rmon_hist_range **ranges);
131+void mlx5e_stats_ts_get(struct mlx5e_priv *priv,
132+ struct ethtool_ts_stats *ts_stats);
131133 void mlx5e_get_link_ext_stats(struct net_device *dev,
132134 struct ethtool_link_ext_stats *stats);
133135