mlxsw: spectrum_qdisc: Include MC TCs in Qdisc counters
authorPetr Machata <petrm@mellanox.com>
Wed, 15 Jan 2020 11:53:49 +0000 (13:53 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Jan 2020 12:16:30 +0000 (04:16 -0800)
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>
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c

index 46d43cfd04e9f873fc566aeb13ca32bfe498a904..0124bfe1963b7fc08b8b9732daa4ca410bba3427 100644 (file)
@@ -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;
@@ -370,7 +384,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;
@@ -403,9 +418,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;
@@ -576,9 +592,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;
 
@@ -614,7 +630,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];
        }