]> git.itanic.dy.fi Git - linux-stable/commitdiff
net: enetc: report statistics counters for taprio
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 30 May 2023 09:19:48 +0000 (12:19 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 31 May 2023 09:00:30 +0000 (10:00 +0100)
Report the "win_drop" counter from the unstructured ethtool -S as
TCA_TAPRIO_OFFLOAD_STATS_WINDOW_DROPS to the Qdisc layer. It is
available both as a global counter as well as a per-TC one.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/enetc/enetc_qos.c

index 2b8fdfffd02d8f76e1dde0d6cd49c577e961f8b9..71157eba1fbed34c9a38da62e2c4c9804ac8387a 100644 (file)
@@ -147,6 +147,35 @@ static void enetc_taprio_destroy(struct net_device *ndev)
        enetc_reset_tc_mqprio(ndev);
 }
 
+static void enetc_taprio_stats(struct net_device *ndev,
+                              struct tc_taprio_qopt_stats *stats)
+{
+       struct enetc_ndev_priv *priv = netdev_priv(ndev);
+       u64 window_drops = 0;
+       int i;
+
+       for (i = 0; i < priv->num_tx_rings; i++)
+               window_drops += priv->tx_ring[i]->stats.win_drop;
+
+       stats->window_drops = window_drops;
+}
+
+static void enetc_taprio_tc_stats(struct net_device *ndev,
+                                 struct tc_taprio_qopt_tc_stats *tc_stats)
+{
+       struct tc_taprio_qopt_stats *stats = &tc_stats->stats;
+       struct enetc_ndev_priv *priv = netdev_priv(ndev);
+       int tc = tc_stats->tc;
+       u64 window_drops = 0;
+       int i;
+
+       for (i = 0; i < priv->num_tx_rings; i++)
+               if (priv->tx_ring[i]->prio == tc)
+                       window_drops += priv->tx_ring[i]->stats.win_drop;
+
+       stats->window_drops = window_drops;
+}
+
 static int enetc_taprio_replace(struct net_device *ndev,
                                struct tc_taprio_qopt_offload *offload)
 {
@@ -176,6 +205,12 @@ int enetc_setup_tc_taprio(struct net_device *ndev, void *type_data)
        case TAPRIO_CMD_DESTROY:
                enetc_taprio_destroy(ndev);
                break;
+       case TAPRIO_CMD_STATS:
+               enetc_taprio_stats(ndev, &offload->stats);
+               break;
+       case TAPRIO_CMD_TC_STATS:
+               enetc_taprio_tc_stats(ndev, &offload->tc_stats);
+               break;
        default:
                err = -EOPNOTSUPP;
        }