aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGal Pressman <galp@mellanox.com>2017-09-13 08:37:50 -0400
committerSaeed Mahameed <saeedm@mellanox.com>2017-09-28 00:23:10 -0400
commit603e1f5bd3ca76f16688e10040545594d2e91ba4 (patch)
tree59bf2b6d1781b18361bd299a8d8892ab0d889eaa
parent1456f69ff5fbba48ed5bc86e858e945e693ba0b7 (diff)
net/mlx5e: Fix calculated checksum offloads counters
Instead of calculating the offloads counters, count them explicitly. The calculations done for these counters would result in bugs in some cases, for example: When running TCP traffic over a VXLAN tunnel with TSO enabled the following counters would increase: tx_csum_partial: 1,333,284 tx_csum_partial_inner: 29,286 tx4_csum_partial_inner: 384 tx7_csum_partial_inner: 8 tx9_csum_partial_inner: 34 tx10_csum_partial_inner: 26,807 tx11_csum_partial_inner: 287 tx12_csum_partial_inner: 27 tx16_csum_partial_inner: 6 tx25_csum_partial_inner: 1,733 Seems like tx_csum_partial increased out of nowhere. The issue is in the following calculation in mlx5e_update_sw_counters: s->tx_csum_partial = s->tx_packets - tx_offload_none - s->tx_csum_partial_inner; While tx_packets increases by the number of GSO segments for each SKB, tx_csum_partial_inner will only increase by one, resulting in wrong tx_csum_partial counter. Fixes: bfe6d8d1d433 ("net/mlx5e: Reorganize ethtool statistics") Signed-off-by: Gal Pressman <galp@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c9
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rx.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_stats.h6
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tx.c1
4 files changed, 13 insertions, 6 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 84b013dc62e9..cc11bbbd0309 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -184,7 +184,6 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
184 struct mlx5e_sw_stats temp, *s = &temp; 184 struct mlx5e_sw_stats temp, *s = &temp;
185 struct mlx5e_rq_stats *rq_stats; 185 struct mlx5e_rq_stats *rq_stats;
186 struct mlx5e_sq_stats *sq_stats; 186 struct mlx5e_sq_stats *sq_stats;
187 u64 tx_offload_none = 0;
188 int i, j; 187 int i, j;
189 188
190 memset(s, 0, sizeof(*s)); 189 memset(s, 0, sizeof(*s));
@@ -199,6 +198,7 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
199 s->rx_lro_bytes += rq_stats->lro_bytes; 198 s->rx_lro_bytes += rq_stats->lro_bytes;
200 s->rx_csum_none += rq_stats->csum_none; 199 s->rx_csum_none += rq_stats->csum_none;
201 s->rx_csum_complete += rq_stats->csum_complete; 200 s->rx_csum_complete += rq_stats->csum_complete;
201 s->rx_csum_unnecessary += rq_stats->csum_unnecessary;
202 s->rx_csum_unnecessary_inner += rq_stats->csum_unnecessary_inner; 202 s->rx_csum_unnecessary_inner += rq_stats->csum_unnecessary_inner;
203 s->rx_xdp_drop += rq_stats->xdp_drop; 203 s->rx_xdp_drop += rq_stats->xdp_drop;
204 s->rx_xdp_tx += rq_stats->xdp_tx; 204 s->rx_xdp_tx += rq_stats->xdp_tx;
@@ -229,14 +229,11 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
229 s->tx_queue_dropped += sq_stats->dropped; 229 s->tx_queue_dropped += sq_stats->dropped;
230 s->tx_xmit_more += sq_stats->xmit_more; 230 s->tx_xmit_more += sq_stats->xmit_more;
231 s->tx_csum_partial_inner += sq_stats->csum_partial_inner; 231 s->tx_csum_partial_inner += sq_stats->csum_partial_inner;
232 tx_offload_none += sq_stats->csum_none; 232 s->tx_csum_none += sq_stats->csum_none;
233 s->tx_csum_partial += sq_stats->csum_partial;
233 } 234 }
234 } 235 }
235 236
236 /* Update calculated offload counters */
237 s->tx_csum_partial = s->tx_packets - tx_offload_none - s->tx_csum_partial_inner;
238 s->rx_csum_unnecessary = s->rx_packets - s->rx_csum_none - s->rx_csum_complete;
239
240 s->link_down_events_phy = MLX5_GET(ppcnt_reg, 237 s->link_down_events_phy = MLX5_GET(ppcnt_reg,
241 priv->stats.pport.phy_counters, 238 priv->stats.pport.phy_counters,
242 counter_set.phys_layer_cntrs.link_down_events); 239 counter_set.phys_layer_cntrs.link_down_events);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index f1dd638384d3..15a1687483cc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -627,6 +627,7 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
627 627
628 if (lro) { 628 if (lro) {
629 skb->ip_summed = CHECKSUM_UNNECESSARY; 629 skb->ip_summed = CHECKSUM_UNNECESSARY;
630 rq->stats.csum_unnecessary++;
630 return; 631 return;
631 } 632 }
632 633
@@ -644,7 +645,9 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
644 skb->csum_level = 1; 645 skb->csum_level = 1;
645 skb->encapsulation = 1; 646 skb->encapsulation = 1;
646 rq->stats.csum_unnecessary_inner++; 647 rq->stats.csum_unnecessary_inner++;
648 return;
647 } 649 }
650 rq->stats.csum_unnecessary++;
648 return; 651 return;
649 } 652 }
650csum_none: 653csum_none:
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index 6d199ffb1c0b..f8637213afc0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -68,6 +68,7 @@ struct mlx5e_sw_stats {
68 u64 rx_xdp_drop; 68 u64 rx_xdp_drop;
69 u64 rx_xdp_tx; 69 u64 rx_xdp_tx;
70 u64 rx_xdp_tx_full; 70 u64 rx_xdp_tx_full;
71 u64 tx_csum_none;
71 u64 tx_csum_partial; 72 u64 tx_csum_partial;
72 u64 tx_csum_partial_inner; 73 u64 tx_csum_partial_inner;
73 u64 tx_queue_stopped; 74 u64 tx_queue_stopped;
@@ -108,6 +109,7 @@ static const struct counter_desc sw_stats_desc[] = {
108 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_drop) }, 109 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_drop) },
109 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_tx) }, 110 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_tx) },
110 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_tx_full) }, 111 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_tx_full) },
112 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_none) },
111 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial) }, 113 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial) },
112 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial_inner) }, 114 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial_inner) },
113 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) }, 115 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) },
@@ -339,6 +341,7 @@ struct mlx5e_rq_stats {
339 u64 packets; 341 u64 packets;
340 u64 bytes; 342 u64 bytes;
341 u64 csum_complete; 343 u64 csum_complete;
344 u64 csum_unnecessary;
342 u64 csum_unnecessary_inner; 345 u64 csum_unnecessary_inner;
343 u64 csum_none; 346 u64 csum_none;
344 u64 lro_packets; 347 u64 lro_packets;
@@ -363,6 +366,7 @@ static const struct counter_desc rq_stats_desc[] = {
363 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, packets) }, 366 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, packets) },
364 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, bytes) }, 367 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, bytes) },
365 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete) }, 368 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete) },
369 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary) },
366 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary_inner) }, 370 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary_inner) },
367 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_none) }, 371 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_none) },
368 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, xdp_drop) }, 372 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, xdp_drop) },
@@ -392,6 +396,7 @@ struct mlx5e_sq_stats {
392 u64 tso_bytes; 396 u64 tso_bytes;
393 u64 tso_inner_packets; 397 u64 tso_inner_packets;
394 u64 tso_inner_bytes; 398 u64 tso_inner_bytes;
399 u64 csum_partial;
395 u64 csum_partial_inner; 400 u64 csum_partial_inner;
396 u64 nop; 401 u64 nop;
397 /* less likely accessed in data path */ 402 /* less likely accessed in data path */
@@ -408,6 +413,7 @@ static const struct counter_desc sq_stats_desc[] = {
408 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_bytes) }, 413 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_bytes) },
409 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_packets) }, 414 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_packets) },
410 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_bytes) }, 415 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_bytes) },
416 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_partial) },
411 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_partial_inner) }, 417 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_partial_inner) },
412 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, nop) }, 418 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, nop) },
413 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_none) }, 419 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_none) },
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index fee43e40fa16..1d6925d4369a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -193,6 +193,7 @@ mlx5e_txwqe_build_eseg_csum(struct mlx5e_txqsq *sq, struct sk_buff *skb, struct
193 sq->stats.csum_partial_inner++; 193 sq->stats.csum_partial_inner++;
194 } else { 194 } else {
195 eseg->cs_flags |= MLX5_ETH_WQE_L4_CSUM; 195 eseg->cs_flags |= MLX5_ETH_WQE_L4_CSUM;
196 sq->stats.csum_partial++;
196 } 197 }
197 } else 198 } else
198 sq->stats.csum_none++; 199 sq->stats.csum_none++;