mlxsw: spectrum: Move the ECN-marked packet counter to ethtool
authorPetr Machata <petrm@mellanox.com>
Wed, 26 Feb 2020 08:39:18 +0000 (09:39 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 27 Feb 2020 04:44:42 +0000 (20:44 -0800)
Spectrum-1 and Spectrum-2 do not have a per-TC counter of number of packets
marked by ECN. The value reported currently is the total number of marked
packets. Showing this value at individual TC Qdiscs is misleading.

Move the counter to ethtool instead.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c

index 0e399b0..1aae1c0 100644 (file)
@@ -2228,6 +2228,15 @@ static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_rfc_3635_stats[] = {
 #define MLXSW_SP_PORT_HW_RFC_3635_STATS_LEN \
        ARRAY_SIZE(mlxsw_sp_port_hw_rfc_3635_stats)
 
+static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_ext_stats[] = {
+       {
+               .str = "ecn_marked",
+               .getter = mlxsw_reg_ppcnt_ecn_marked_get,
+       },
+};
+
+#define MLXSW_SP_PORT_HW_EXT_STATS_LEN ARRAY_SIZE(mlxsw_sp_port_hw_ext_stats)
+
 static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_discard_stats[] = {
        {
                .str = "discard_ingress_general",
@@ -2337,6 +2346,7 @@ static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_tc_stats[] = {
                                         MLXSW_SP_PORT_HW_RFC_2863_STATS_LEN + \
                                         MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN + \
                                         MLXSW_SP_PORT_HW_RFC_3635_STATS_LEN + \
+                                        MLXSW_SP_PORT_HW_EXT_STATS_LEN + \
                                         MLXSW_SP_PORT_HW_DISCARD_STATS_LEN + \
                                         (MLXSW_SP_PORT_HW_PRIO_STATS_LEN * \
                                          IEEE_8021QAZ_MAX_TCS) + \
@@ -2398,6 +2408,12 @@ static void mlxsw_sp_port_get_strings(struct net_device *dev,
                        p += ETH_GSTRING_LEN;
                }
 
+               for (i = 0; i < MLXSW_SP_PORT_HW_EXT_STATS_LEN; i++) {
+                       memcpy(p, mlxsw_sp_port_hw_ext_stats[i].str,
+                              ETH_GSTRING_LEN);
+                       p += ETH_GSTRING_LEN;
+               }
+
                for (i = 0; i < MLXSW_SP_PORT_HW_DISCARD_STATS_LEN; i++) {
                        memcpy(p, mlxsw_sp_port_hw_discard_stats[i].str,
                               ETH_GSTRING_LEN);
@@ -2459,6 +2475,10 @@ mlxsw_sp_get_hw_stats_by_group(struct mlxsw_sp_port_hw_stats **p_hw_stats,
                *p_hw_stats = mlxsw_sp_port_hw_rfc_3635_stats;
                *p_len = MLXSW_SP_PORT_HW_RFC_3635_STATS_LEN;
                break;
+       case MLXSW_REG_PPCNT_EXT_CNT:
+               *p_hw_stats = mlxsw_sp_port_hw_ext_stats;
+               *p_len = MLXSW_SP_PORT_HW_EXT_STATS_LEN;
+               break;
        case MLXSW_REG_PPCNT_DISCARD_CNT:
                *p_hw_stats = mlxsw_sp_port_hw_discard_stats;
                *p_len = MLXSW_SP_PORT_HW_DISCARD_STATS_LEN;
@@ -2528,6 +2548,11 @@ static void mlxsw_sp_port_get_stats(struct net_device *dev,
                                  data, data_index);
        data_index += MLXSW_SP_PORT_HW_RFC_3635_STATS_LEN;
 
+       /* Extended Counters */
+       __mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_EXT_CNT, 0,
+                                 data, data_index);
+       data_index += MLXSW_SP_PORT_HW_EXT_STATS_LEN;
+
        /* Discard Counters */
        __mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_DISCARD_CNT, 0,
                                  data, data_index);
index 02526c5..13a054c 100644 (file)
@@ -347,7 +347,6 @@ mlxsw_sp_setup_tc_qdisc_red_clean_stats(struct mlxsw_sp_port *mlxsw_sp_port,
                                               mlxsw_sp_qdisc->prio_bitmap,
                                               &stats_base->tx_packets,
                                               &stats_base->tx_bytes);
-       red_base->prob_mark = xstats->ecn;
        red_base->prob_drop = xstats->wred_drop[tclass_num];
        red_base->pdrop = mlxsw_sp_xstats_tail_drop(xstats, tclass_num);
 
@@ -453,22 +452,19 @@ mlxsw_sp_qdisc_get_red_xstats(struct mlxsw_sp_port *mlxsw_sp_port,
        u8 tclass_num = mlxsw_sp_qdisc->tclass_num;
        struct mlxsw_sp_port_xstats *xstats;
        struct red_stats *res = xstats_ptr;
-       int early_drops, marks, pdrops;
+       int early_drops, pdrops;
 
        xstats = &mlxsw_sp_port->periodic_hw_stats.xstats;
 
        early_drops = xstats->wred_drop[tclass_num] - xstats_base->prob_drop;
-       marks = xstats->ecn - xstats_base->prob_mark;
        pdrops = mlxsw_sp_xstats_tail_drop(xstats, tclass_num) -
                 xstats_base->pdrop;
 
        res->pdrop += pdrops;
        res->prob_drop += early_drops;
-       res->prob_mark += marks;
 
        xstats_base->pdrop += pdrops;
        xstats_base->prob_drop += early_drops;
-       xstats_base->prob_mark += marks;
        return 0;
 }
 
@@ -486,8 +482,7 @@ mlxsw_sp_qdisc_get_red_stats(struct mlxsw_sp_port *mlxsw_sp_port,
        stats_base = &mlxsw_sp_qdisc->stats_base;
 
        mlxsw_sp_qdisc_get_tc_stats(mlxsw_sp_port, mlxsw_sp_qdisc, stats_ptr);
-       overlimits = xstats->wred_drop[tclass_num] + xstats->ecn -
-                    stats_base->overlimits;
+       overlimits = xstats->wred_drop[tclass_num] - stats_base->overlimits;
 
        stats_ptr->qstats->overlimits += overlimits;
        stats_base->overlimits += overlimits;