Skip to content

Commit

Permalink
Merge branch 'taprio-xstats'
Browse files Browse the repository at this point in the history
Vladimir Oltean says:

====================
Fixes for taprio xstats

1. Taprio classes correspond to TXQs, and thus, class stats are TXQ
   stats not TC stats.
2. Drivers reporting taprio xstats should report xstats for *this*
   taprio, not for a previous one.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jun 12, 2023
2 parents f2ea0c3 + f1e668d commit 6513787
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
29 changes: 16 additions & 13 deletions drivers/net/ethernet/freescale/enetc/enetc_qos.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ static int enetc_setup_taprio(struct enetc_ndev_priv *priv,
return 0;
}

static void enetc_reset_taprio_stats(struct enetc_ndev_priv *priv)
{
int i;

for (i = 0; i < priv->num_tx_rings; i++)
priv->tx_ring[i]->stats.win_drop = 0;
}

static void enetc_reset_taprio(struct enetc_ndev_priv *priv)
{
struct enetc_hw *hw = &priv->si->hw;
Expand All @@ -145,6 +153,7 @@ static void enetc_taprio_destroy(struct net_device *ndev)

enetc_reset_taprio(priv);
enetc_reset_tc_mqprio(ndev);
enetc_reset_taprio_stats(priv);
}

static void enetc_taprio_stats(struct net_device *ndev,
Expand All @@ -160,20 +169,14 @@ static void enetc_taprio_stats(struct net_device *ndev,
stats->window_drops = window_drops;
}

static void enetc_taprio_tc_stats(struct net_device *ndev,
struct tc_taprio_qopt_tc_stats *tc_stats)
static void enetc_taprio_queue_stats(struct net_device *ndev,
struct tc_taprio_qopt_queue_stats *queue_stats)
{
struct tc_taprio_qopt_stats *stats = &tc_stats->stats;
struct tc_taprio_qopt_stats *stats = &queue_stats->stats;
struct enetc_ndev_priv *priv = netdev_priv(ndev);
int tc = tc_stats->tc;
u64 window_drops = 0;
int i;
int queue = queue_stats->queue;

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;
stats->window_drops = priv->tx_ring[queue]->stats.win_drop;
}

static int enetc_taprio_replace(struct net_device *ndev,
Expand Down Expand Up @@ -208,8 +211,8 @@ int enetc_setup_tc_taprio(struct net_device *ndev, void *type_data)
case TAPRIO_CMD_STATS:
enetc_taprio_stats(ndev, &offload->stats);
break;
case TAPRIO_CMD_TC_STATS:
enetc_taprio_tc_stats(ndev, &offload->tc_stats);
case TAPRIO_CMD_QUEUE_STATS:
enetc_taprio_queue_stats(ndev, &offload->queue_stats);
break;
default:
err = -EOPNOTSUPP;
Expand Down
10 changes: 5 additions & 5 deletions include/net/pkt_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ enum tc_taprio_qopt_cmd {
TAPRIO_CMD_REPLACE,
TAPRIO_CMD_DESTROY,
TAPRIO_CMD_STATS,
TAPRIO_CMD_TC_STATS,
TAPRIO_CMD_QUEUE_STATS,
};

/**
Expand All @@ -208,8 +208,8 @@ struct tc_taprio_qopt_stats {
u64 tx_overruns;
};

struct tc_taprio_qopt_tc_stats {
int tc;
struct tc_taprio_qopt_queue_stats {
int queue;
struct tc_taprio_qopt_stats stats;
};

Expand All @@ -227,8 +227,8 @@ struct tc_taprio_qopt_offload {
union {
/* TAPRIO_CMD_STATS */
struct tc_taprio_qopt_stats stats;
/* TAPRIO_CMD_TC_STATS */
struct tc_taprio_qopt_tc_stats tc_stats;
/* TAPRIO_CMD_QUEUE_STATS */
struct tc_taprio_qopt_queue_stats queue_stats;
/* TAPRIO_CMD_REPLACE */
struct {
struct tc_mqprio_qopt_offload mqprio;
Expand Down
8 changes: 4 additions & 4 deletions net/sched/sch_taprio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2458,9 +2458,9 @@ static int taprio_dump_class_stats(struct Qdisc *sch, unsigned long cl,
{
struct netdev_queue *dev_queue = taprio_queue_get(sch, cl);
struct tc_taprio_qopt_offload offload = {
.cmd = TAPRIO_CMD_TC_STATS,
.tc_stats = {
.tc = cl - 1,
.cmd = TAPRIO_CMD_QUEUE_STATS,
.queue_stats = {
.queue = cl - 1,
},
};
struct Qdisc *child;
Expand All @@ -2470,7 +2470,7 @@ static int taprio_dump_class_stats(struct Qdisc *sch, unsigned long cl,
qdisc_qstats_copy(d, child) < 0)
return -1;

return taprio_dump_xstats(sch, d, &offload, &offload.tc_stats.stats);
return taprio_dump_xstats(sch, d, &offload, &offload.queue_stats.stats);
}

static void taprio_walk(struct Qdisc *sch, struct qdisc_walker *arg)
Expand Down

0 comments on commit 6513787

Please sign in to comment.