Re: [PATCH v5 2/2] net: dsa: qca: ar9331: export stats64

From: Jakub Kicinski
Date: Sat Dec 12 2020 - 13:01:38 EST


On Sat, 12 Dec 2020 15:48:52 +0200 Vladimir Oltean wrote:
> > + stats->rx_packets = u64_stats_read(&s->rx64byte) +
> > + u64_stats_read(&s->rx128byte) + u64_stats_read(&s->rx256byte) +
> > + u64_stats_read(&s->rx512byte) + u64_stats_read(&s->rx1024byte) +
> > + u64_stats_read(&s->rx1518byte) + u64_stats_read(&s->rxmaxbyte);
> > + stats->tx_packets = u64_stats_read(&s->tx64byte) +
> > + u64_stats_read(&s->tx128byte) + u64_stats_read(&s->tx256byte) +
> > + u64_stats_read(&s->tx512byte) + u64_stats_read(&s->tx1024byte) +
> > + u64_stats_read(&s->tx1518byte) + u64_stats_read(&s->txmaxbyte);
> > + stats->rx_bytes = u64_stats_read(&s->rxgoodbyte);
> > + stats->tx_bytes = u64_stats_read(&s->txbyte);
> > + stats->rx_errors = u64_stats_read(&s->rxfcserr) +
> > + u64_stats_read(&s->rxalignerr) + u64_stats_read(&s->rxrunt) +
> > + u64_stats_read(&s->rxfragment) + u64_stats_read(&s->rxoverflow);
> > + stats->tx_errors = u64_stats_read(&s->txoversize);
>
> Should tx_errors not also include tx_aborted_errors, tx_fifo_errors,
> tx_window_errors?

Yes.

> > + stats->multicast = u64_stats_read(&s->rxmulti);
> > + stats->collisions = u64_stats_read(&s->txcollision);
> > + stats->rx_length_errors = u64_stats_read(&s->rxrunt) +
> > + u64_stats_read(&s->rxfragment) + u64_stats_read(&s->rxtoolong);
> > + stats->rx_crc_errors = u64_stats_read(&s->rxfcserr) +
> > + u64_stats_read(&s->rxalignerr) + u64_stats_read(&s->rxfragment);

Why would CRC errors include alignment errors and rxfragments?

Besides looks like rxfragment is already counted to length errors.

> > + stats->rx_frame_errors = u64_stats_read(&s->rxalignerr);
> > + stats->rx_missed_errors = u64_stats_read(&s->rxoverflow);
> > + stats->tx_aborted_errors = u64_stats_read(&s->txabortcol);
> > + stats->tx_fifo_errors = u64_stats_read(&s->txunderrun);
> > + stats->tx_window_errors = u64_stats_read(&s->txlatecol);
> > + stats->rx_nohandler = u64_stats_read(&s->filtered);
>
> Should rx_nohandler not be also included in rx_errors?

I don't think drivers should ever touch rx_nohandler, it's a pretty
specific SW stat. But you made me realize that we never specified where
to count frames discarded due to L2 address filtering. It appears that
high speed adapters I was looking at don't have such statistic?

I would go with rx_dropped, if that's what ->filtered is.

We should probably update the doc like this:

diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 874cc12a34d9..82708c6db432 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -75,8 +75,9 @@ struct rtnl_link_stats {
*
* @rx_dropped: Number of packets received but not processed,
* e.g. due to lack of resources or unsupported protocol.
- * For hardware interfaces this counter should not include packets
- * dropped by the device which are counted separately in
+ * For hardware interfaces this counter may include packets discarded
+ * due to L2 address filtering but should not include packets dropped
+ * by the device due to buffer exhaustion which are counted separately in
* @rx_missed_errors (since procfs folds those two counters together).
*
* @tx_dropped: Number of packets dropped on their way to transmission,


> You can probably avoid reading a few of these twice by assigning the
> more specific ones first, then the rx_errors and tx_errors at the end.