mvebu: remove upstreamed DTS files in 5.10
[openwrt/staging/chunkeey.git] / target / linux / mvebu / patches-5.10 / 003-net-mvneta-introduce-mvneta_update_stats-routine.patch
1 From ff519e2acd463bff6c5bb4e8d7ed350c9bae885b Mon Sep 17 00:00:00 2001
2 From: Lorenzo Bianconi <lorenzo@kernel.org>
3 Date: Sat, 19 Oct 2019 10:13:21 +0200
4 Subject: [PATCH 1/7] net: mvneta: introduce mvneta_update_stats routine
5
6 Introduce mvneta_update_stats routine to collect {rx/tx} statistics
7 (packets and bytes). This is a preliminary patch to add XDP support to
8 mvneta driver
9
10 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
12 ---
13 drivers/net/ethernet/marvell/mvneta.c | 43 ++++++++++++++-------------
14 1 file changed, 22 insertions(+), 21 deletions(-)
15
16 --- a/drivers/net/ethernet/marvell/mvneta.c
17 +++ b/drivers/net/ethernet/marvell/mvneta.c
18 @@ -1913,6 +1913,23 @@ static void mvneta_rxq_drop_pkts(struct
19 }
20 }
21
22 +static void
23 +mvneta_update_stats(struct mvneta_port *pp, u32 pkts,
24 + u32 len, bool tx)
25 +{
26 + struct mvneta_pcpu_stats *stats = this_cpu_ptr(pp->stats);
27 +
28 + u64_stats_update_begin(&stats->syncp);
29 + if (tx) {
30 + stats->tx_packets += pkts;
31 + stats->tx_bytes += len;
32 + } else {
33 + stats->rx_packets += pkts;
34 + stats->rx_bytes += len;
35 + }
36 + u64_stats_update_end(&stats->syncp);
37 +}
38 +
39 static inline
40 int mvneta_rx_refill_queue(struct mvneta_port *pp, struct mvneta_rx_queue *rxq)
41 {
42 @@ -2093,14 +2110,8 @@ static int mvneta_rx_swbm(struct napi_st
43 rxq->left_size = 0;
44 }
45
46 - if (rcvd_pkts) {
47 - struct mvneta_pcpu_stats *stats = this_cpu_ptr(pp->stats);
48 -
49 - u64_stats_update_begin(&stats->syncp);
50 - stats->rx_packets += rcvd_pkts;
51 - stats->rx_bytes += rcvd_bytes;
52 - u64_stats_update_end(&stats->syncp);
53 - }
54 + if (rcvd_pkts)
55 + mvneta_update_stats(pp, rcvd_pkts, rcvd_bytes, false);
56
57 /* return some buffers to hardware queue, one at a time is too slow */
58 refill = mvneta_rx_refill_queue(pp, rxq);
59 @@ -2223,14 +2234,8 @@ err_drop_frame:
60 napi_gro_receive(napi, skb);
61 }
62
63 - if (rcvd_pkts) {
64 - struct mvneta_pcpu_stats *stats = this_cpu_ptr(pp->stats);
65 -
66 - u64_stats_update_begin(&stats->syncp);
67 - stats->rx_packets += rcvd_pkts;
68 - stats->rx_bytes += rcvd_bytes;
69 - u64_stats_update_end(&stats->syncp);
70 - }
71 + if (rcvd_pkts)
72 + mvneta_update_stats(pp, rcvd_pkts, rcvd_bytes, false);
73
74 /* Update rxq management counters */
75 mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_done);
76 @@ -2476,7 +2481,6 @@ static netdev_tx_t mvneta_tx(struct sk_b
77
78 out:
79 if (frags > 0) {
80 - struct mvneta_pcpu_stats *stats = this_cpu_ptr(pp->stats);
81 struct netdev_queue *nq = netdev_get_tx_queue(dev, txq_id);
82
83 netdev_tx_sent_queue(nq, len);
84 @@ -2491,10 +2495,7 @@ out:
85 else
86 txq->pending += frags;
87
88 - u64_stats_update_begin(&stats->syncp);
89 - stats->tx_packets++;
90 - stats->tx_bytes += len;
91 - u64_stats_update_end(&stats->syncp);
92 + mvneta_update_stats(pp, 1, len, true);
93 } else {
94 dev->stats.tx_dropped++;
95 dev_kfree_skb_any(skb);