| From 81fcc1775d92a9913299fa3f08a01d38498d6f8b Mon Sep 17 00:00:00 2001 |
| From: Petr Machata <petrm@mellanox.com> |
| Date: Wed, 15 Jan 2020 13:53:49 +0200 |
| Subject: [PATCH] mlxsw: spectrum_qdisc: Include MC TCs in Qdisc counters |
| |
| commit 85005b82e59fa7bb7388b12594ab2067bf73d66c upstream. |
| |
| mlxsw configures Spectrum in such a way that BUM traffic is passed not |
| through its nominal traffic class TC, but through its MC counterpart TC+8. |
| However, when collecting statistics, Qdiscs only look at the nominal TC and |
| ignore the MC TC. |
| |
| Add two helpers to compute the value for logical TC from the constituents, |
| one for backlog, the other for tail drops. Use them throughout instead of |
| going through the xstats pointer directly. |
| |
| Counters for TX bytes and packets are deduced from packet priority |
| counters, and therefore already include BUM traffic. wred_drop counter is |
| irrelevant on MC TCs, because RED is not enabled on them. |
| |
| Fixes: 7b8195306694 ("mlxsw: spectrum: Configure MC-aware mode on mlxsw ports") |
| Signed-off-by: Petr Machata <petrm@mellanox.com> |
| Acked-by: Jiri Pirko <jiri@mellanox.com> |
| Signed-off-by: Ido Schimmel <idosch@mellanox.com> |
| Signed-off-by: David S. Miller <davem@davemloft.net> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c |
| index 720514b5c006..dc63583c4948 100644 |
| --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c |
| +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c |
| @@ -195,6 +195,20 @@ mlxsw_sp_qdisc_get_xstats(struct mlxsw_sp_port *mlxsw_sp_port, |
| return -EOPNOTSUPP; |
| } |
| |
| +static u64 |
| +mlxsw_sp_xstats_backlog(struct mlxsw_sp_port_xstats *xstats, int tclass_num) |
| +{ |
| + return xstats->backlog[tclass_num] + |
| + xstats->backlog[tclass_num + 8]; |
| +} |
| + |
| +static u64 |
| +mlxsw_sp_xstats_tail_drop(struct mlxsw_sp_port_xstats *xstats, int tclass_num) |
| +{ |
| + return xstats->tail_drop[tclass_num] + |
| + xstats->tail_drop[tclass_num + 8]; |
| +} |
| + |
| static void |
| mlxsw_sp_qdisc_bstats_per_priority_get(struct mlxsw_sp_port_xstats *xstats, |
| u8 prio_bitmap, u64 *tx_packets, |
| @@ -269,7 +283,7 @@ mlxsw_sp_setup_tc_qdisc_red_clean_stats(struct mlxsw_sp_port *mlxsw_sp_port, |
| &stats_base->tx_bytes); |
| red_base->prob_mark = xstats->ecn; |
| red_base->prob_drop = xstats->wred_drop[tclass_num]; |
| - red_base->pdrop = xstats->tail_drop[tclass_num]; |
| + red_base->pdrop = mlxsw_sp_xstats_tail_drop(xstats, tclass_num); |
| |
| stats_base->overlimits = red_base->prob_drop + red_base->prob_mark; |
| stats_base->drops = red_base->prob_drop + red_base->pdrop; |
| @@ -369,7 +383,8 @@ mlxsw_sp_qdisc_get_red_xstats(struct mlxsw_sp_port *mlxsw_sp_port, |
| |
| early_drops = xstats->wred_drop[tclass_num] - xstats_base->prob_drop; |
| marks = xstats->ecn - xstats_base->prob_mark; |
| - pdrops = xstats->tail_drop[tclass_num] - xstats_base->pdrop; |
| + pdrops = mlxsw_sp_xstats_tail_drop(xstats, tclass_num) - |
| + xstats_base->pdrop; |
| |
| res->pdrop += pdrops; |
| res->prob_drop += early_drops; |
| @@ -402,9 +417,10 @@ mlxsw_sp_qdisc_get_red_stats(struct mlxsw_sp_port *mlxsw_sp_port, |
| |
| overlimits = xstats->wred_drop[tclass_num] + xstats->ecn - |
| stats_base->overlimits; |
| - drops = xstats->wred_drop[tclass_num] + xstats->tail_drop[tclass_num] - |
| + drops = xstats->wred_drop[tclass_num] + |
| + mlxsw_sp_xstats_tail_drop(xstats, tclass_num) - |
| stats_base->drops; |
| - backlog = xstats->backlog[tclass_num]; |
| + backlog = mlxsw_sp_xstats_backlog(xstats, tclass_num); |
| |
| _bstats_update(stats_ptr->bstats, tx_bytes, tx_packets); |
| stats_ptr->qstats->overlimits += overlimits; |
| @@ -575,9 +591,9 @@ mlxsw_sp_qdisc_get_prio_stats(struct mlxsw_sp_port *mlxsw_sp_port, |
| tx_packets = stats->tx_packets - stats_base->tx_packets; |
| |
| for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { |
| - drops += xstats->tail_drop[i]; |
| + drops += mlxsw_sp_xstats_tail_drop(xstats, i); |
| drops += xstats->wred_drop[i]; |
| - backlog += xstats->backlog[i]; |
| + backlog += mlxsw_sp_xstats_backlog(xstats, i); |
| } |
| drops = drops - stats_base->drops; |
| |
| @@ -613,7 +629,7 @@ mlxsw_sp_setup_tc_qdisc_prio_clean_stats(struct mlxsw_sp_port *mlxsw_sp_port, |
| |
| stats_base->drops = 0; |
| for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { |
| - stats_base->drops += xstats->tail_drop[i]; |
| + stats_base->drops += mlxsw_sp_xstats_tail_drop(xstats, i); |
| stats_base->drops += xstats->wred_drop[i]; |
| } |
| |
| -- |
| 2.7.4 |
| |