On Wed, 16 Oct 2019 23:03:06 +0200, Lorenzo Bianconi wrote: > Introduce mvneta_update_stats routine to collect {rx/tx} statistics > (packets and bytes). This is a preliminary patch to add XDP support to > mvneta driver > > Signed-off-by: Lorenzo Bianconi <lore...@kernel.org> > --- > drivers/net/ethernet/marvell/mvneta.c | 41 +++++++++++++-------------- > 1 file changed, 20 insertions(+), 21 deletions(-) > > diff --git a/drivers/net/ethernet/marvell/mvneta.c > b/drivers/net/ethernet/marvell/mvneta.c > index e49820675c8c..128b9fded959 100644 > --- a/drivers/net/ethernet/marvell/mvneta.c > +++ b/drivers/net/ethernet/marvell/mvneta.c > @@ -1900,6 +1900,23 @@ static void mvneta_rxq_drop_pkts(struct mvneta_port > *pp, > } > } > > +static void > +mvneta_update_stats(struct mvneta_port *pp, u32 pkts, > + u32 len, bool tx) > +{ > + struct mvneta_pcpu_stats *stats = this_cpu_ptr(pp->stats); > + > + u64_stats_update_begin(&stats->syncp); > + if (tx) { > + stats->tx_packets += pkts; > + stats->tx_bytes += len; > + } else { > + stats->rx_packets += pkts; > + stats->rx_bytes += len; > + } > + u64_stats_update_end(&stats->syncp); > +} > + > static inline > int mvneta_rx_refill_queue(struct mvneta_port *pp, struct mvneta_rx_queue > *rxq) > { > @@ -2075,14 +2092,7 @@ static int mvneta_rx_swbm(struct napi_struct *napi, > rxq->left_size = 0; > } > > - if (rcvd_pkts) {
nit: you're getting rid of this check in the new helper, perhaps worth mentioning in the commit message why its irrelevant > - struct mvneta_pcpu_stats *stats = this_cpu_ptr(pp->stats); > - > - u64_stats_update_begin(&stats->syncp); > - stats->rx_packets += rcvd_pkts; > - stats->rx_bytes += rcvd_bytes; > - u64_stats_update_end(&stats->syncp); > - } > + mvneta_update_stats(pp, rcvd_pkts, rcvd_bytes, false); > > /* return some buffers to hardware queue, one at a time is too slow */ > refill = mvneta_rx_refill_queue(pp, rxq);