Feed driver statistics counters related to hardware timestamping to standardized ethtool hardware timestamping statistics group.
Unified · Split
| @@ -2387,6 +2387,14 @@ static void mlx5e_get_rmon_stats(struct net_device *netdev, · 2386 unmodified lines | ||
| 2387 | 2387 | mlx5e_stats_rmon_get(priv, rmon_stats, ranges); |
| 2388 | 2388 | } |
| 2389 | 2389 | |
| 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 | + | |
| 2390 | 2398 | const struct ethtool_ops mlx5e_ethtool_ops = { |
| 2391 | 2399 | .cap_rss_ctx_supported = true, |
| 2392 | 2400 | .supported_coalesce_params = ETHTOOL_COALESCE_USECS | |
| @@ -2436,5 +2444,6 @@ const struct ethtool_ops mlx5e_ethtool_ops = { · 43 unmodified lines | ||
| 2436 | 2444 | .get_eth_mac_stats = mlx5e_get_eth_mac_stats, |
| 2437 | 2445 | .get_eth_ctrl_stats = mlx5e_get_eth_ctrl_stats, |
| 2438 | 2446 | .get_rmon_stats = mlx5e_get_rmon_stats, |
| 2447 | + .get_ts_stats = mlx5e_get_ts_stats, | |
| 2439 | 2448 | .get_link_ext_stats = mlx5e_get_link_ext_stats |
| 2440 | 2449 | }; |
| @@ -1172,6 +1172,51 @@ void mlx5e_stats_rmon_get(struct mlx5e_priv *priv, · 1171 unmodified lines | ||
| 1172 | 1172 | *ranges = mlx5e_rmon_ranges; |
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 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 | + | |
| 1175 | 1220 | #define PPORT_PHY_STATISTICAL_OFF(c) \ |
| 1176 | 1221 | MLX5_BYTE_OFF(ppcnt_reg, \ |
| 1177 | 1222 | counter_set.phys_layer_statistical_cntrs.c##_high) |
| @@ -128,6 +128,8 @@ void mlx5e_stats_eth_ctrl_get(struct mlx5e_priv *priv, · 127 unmodified lines | ||
| 128 | 128 | void mlx5e_stats_rmon_get(struct mlx5e_priv *priv, |
| 129 | 129 | struct ethtool_rmon_stats *rmon, |
| 130 | 130 | const struct ethtool_rmon_hist_range **ranges); |
| 131 | +void mlx5e_stats_ts_get(struct mlx5e_priv *priv, | |
| 132 | + struct ethtool_ts_stats *ts_stats); | |
| 131 | 133 | void mlx5e_get_link_ext_stats(struct net_device *dev, |
| 132 | 134 | struct ethtool_link_ext_stats *stats); |
| 133 | 135 | |